Skip to content

Commit 9a6f307

Browse files
authored
Merge branch 'master' into master
2 parents 5e1a563 + 090e975 commit 9a6f307

File tree

15 files changed

+485
-121
lines changed

15 files changed

+485
-121
lines changed

TestFx.sln

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DoNotParallelizeTestProject
174174
EndProject
175175
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DeploymentTestProject", "test\E2ETests\TestAssets\DeploymentTestProject\DeploymentTestProject.csproj", "{3FCE3987-7C8C-4E12-B54A-C6EC2D9FC7A6}"
176176
EndProject
177+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CompatTestProject", "test\E2ETests\TestAssets\CompatTestProject\CompatTestProject.csproj", "{2D2C5B73-F1F1-47C8-BC5C-A172E9BB3D16}"
178+
EndProject
177179
Global
178180
GlobalSection(SharedMSBuildProjectFiles) = preSolution
179181
src\TestFramework\Extension.Shared\Extension.Shared.projitems*{272ca5e1-8e81-4825-9e47-86cce02f700d}*SharedItemsImports = 13
@@ -987,6 +989,30 @@ Global
987989
{3FCE3987-7C8C-4E12-B54A-C6EC2D9FC7A6}.Release|x64.Build.0 = Release|Any CPU
988990
{3FCE3987-7C8C-4E12-B54A-C6EC2D9FC7A6}.Release|x86.ActiveCfg = Release|Any CPU
989991
{3FCE3987-7C8C-4E12-B54A-C6EC2D9FC7A6}.Release|x86.Build.0 = Release|Any CPU
992+
{2D2C5B73-F1F1-47C8-BC5C-A172E9BB3D16}.Code Analysis Debug|Any CPU.ActiveCfg = Debug|Any CPU
993+
{2D2C5B73-F1F1-47C8-BC5C-A172E9BB3D16}.Code Analysis Debug|Any CPU.Build.0 = Debug|Any CPU
994+
{2D2C5B73-F1F1-47C8-BC5C-A172E9BB3D16}.Code Analysis Debug|ARM.ActiveCfg = Debug|Any CPU
995+
{2D2C5B73-F1F1-47C8-BC5C-A172E9BB3D16}.Code Analysis Debug|ARM.Build.0 = Debug|Any CPU
996+
{2D2C5B73-F1F1-47C8-BC5C-A172E9BB3D16}.Code Analysis Debug|x64.ActiveCfg = Debug|Any CPU
997+
{2D2C5B73-F1F1-47C8-BC5C-A172E9BB3D16}.Code Analysis Debug|x64.Build.0 = Debug|Any CPU
998+
{2D2C5B73-F1F1-47C8-BC5C-A172E9BB3D16}.Code Analysis Debug|x86.ActiveCfg = Debug|Any CPU
999+
{2D2C5B73-F1F1-47C8-BC5C-A172E9BB3D16}.Code Analysis Debug|x86.Build.0 = Debug|Any CPU
1000+
{2D2C5B73-F1F1-47C8-BC5C-A172E9BB3D16}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1001+
{2D2C5B73-F1F1-47C8-BC5C-A172E9BB3D16}.Debug|Any CPU.Build.0 = Debug|Any CPU
1002+
{2D2C5B73-F1F1-47C8-BC5C-A172E9BB3D16}.Debug|ARM.ActiveCfg = Debug|Any CPU
1003+
{2D2C5B73-F1F1-47C8-BC5C-A172E9BB3D16}.Debug|ARM.Build.0 = Debug|Any CPU
1004+
{2D2C5B73-F1F1-47C8-BC5C-A172E9BB3D16}.Debug|x64.ActiveCfg = Debug|Any CPU
1005+
{2D2C5B73-F1F1-47C8-BC5C-A172E9BB3D16}.Debug|x64.Build.0 = Debug|Any CPU
1006+
{2D2C5B73-F1F1-47C8-BC5C-A172E9BB3D16}.Debug|x86.ActiveCfg = Debug|Any CPU
1007+
{2D2C5B73-F1F1-47C8-BC5C-A172E9BB3D16}.Debug|x86.Build.0 = Debug|Any CPU
1008+
{2D2C5B73-F1F1-47C8-BC5C-A172E9BB3D16}.Release|Any CPU.ActiveCfg = Release|Any CPU
1009+
{2D2C5B73-F1F1-47C8-BC5C-A172E9BB3D16}.Release|Any CPU.Build.0 = Release|Any CPU
1010+
{2D2C5B73-F1F1-47C8-BC5C-A172E9BB3D16}.Release|ARM.ActiveCfg = Release|Any CPU
1011+
{2D2C5B73-F1F1-47C8-BC5C-A172E9BB3D16}.Release|ARM.Build.0 = Release|Any CPU
1012+
{2D2C5B73-F1F1-47C8-BC5C-A172E9BB3D16}.Release|x64.ActiveCfg = Release|Any CPU
1013+
{2D2C5B73-F1F1-47C8-BC5C-A172E9BB3D16}.Release|x64.Build.0 = Release|Any CPU
1014+
{2D2C5B73-F1F1-47C8-BC5C-A172E9BB3D16}.Release|x86.ActiveCfg = Release|Any CPU
1015+
{2D2C5B73-F1F1-47C8-BC5C-A172E9BB3D16}.Release|x86.Build.0 = Release|Any CPU
9901016
EndGlobalSection
9911017
GlobalSection(SolutionProperties) = preSolution
9921018
HideSolutionNode = FALSE
@@ -1044,6 +1070,7 @@ Global
10441070
{5A4967CD-B527-4D43-81C2-4CA90EE10222} = {D53BD452-F69F-4FB3-8B98-386EDA28A4C8}
10451071
{8080DE48-CFD9-4F33-908A-8B71108CA223} = {D53BD452-F69F-4FB3-8B98-386EDA28A4C8}
10461072
{3FCE3987-7C8C-4E12-B54A-C6EC2D9FC7A6} = {D53BD452-F69F-4FB3-8B98-386EDA28A4C8}
1073+
{2D2C5B73-F1F1-47C8-BC5C-A172E9BB3D16} = {D53BD452-F69F-4FB3-8B98-386EDA28A4C8}
10471074
EndGlobalSection
10481075
GlobalSection(ExtensibilityGlobals) = postSolution
10491076
SolutionGuid = {31E0F4D5-975A-41CC-933E-545B2201FAF9}

src/Adapter/MSTest.CoreAdapter/Discovery/AssemblyEnumeratorWrapper.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,13 @@ private ICollection<UnitTestElement> GetTestsInIsolation(string fullFilePath, IR
140140
{
141141
using (var isolationHost = PlatformServiceProvider.Instance.CreateTestSourceHost(fullFilePath, runSettings, frameworkHandle: null))
142142
{
143-
var assemblyEnumerator =
144-
isolationHost.CreateInstanceForType(typeof(AssemblyEnumerator), new object[] { MSTestSettings.CurrentSettings }) as AssemblyEnumerator;
143+
// Create an instance of a type defined in adapter so that adapter gets loaded in the child app domain
144+
var assemblyEnumerator = isolationHost.CreateInstanceForType(
145+
typeof(AssemblyEnumerator), new object[] { MSTestSettings.CurrentSettings }) as AssemblyEnumerator;
146+
147+
// After loading adapter reset the child-domain's appbase to point to test source location
148+
isolationHost.UpdateAppBaseToTestSourceLocationAndSetupAssemblyResolver();
149+
145150
return assemblyEnumerator.EnumerateAssembly(fullFilePath, out warnings);
146151
}
147152
}

src/Adapter/MSTest.CoreAdapter/Execution/TestExecutionManager.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,14 @@ private void ExecuteTestsInSource(IEnumerable<TestCase> tests, IRunContext runCo
217217

218218
using (var isolationHost = PlatformServiceProvider.Instance.CreateTestSourceHost(source, runContext?.RunSettings, frameworkHandle))
219219
{
220+
// Create an instance of a type defined in adapter so that adapter gets loaded in the child app domain
220221
var testRunner = isolationHost.CreateInstanceForType(
221222
typeof(UnitTestRunner),
222223
new object[] { MSTestSettings.CurrentSettings }) as UnitTestRunner;
224+
225+
// After loading adapter reset the chils-domain's appbase to point to test source location
226+
isolationHost.UpdateAppBaseToTestSourceLocationAndSetupAssemblyResolver();
227+
223228
PlatformServiceProvider.Instance.AdapterTraceLogger.LogInfo("Created unit-test runner {0}", source);
224229

225230
// Default test set is filtered tests based on user provided filter criteria

src/Adapter/MSTest.CoreAdapter/Execution/TypeCache.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ private TestClassInfo CreateClassInfo(Type classType, TestMethod testMethod)
286286
foreach (var methodInfo in classType.GetTypeInfo().DeclaredMethods)
287287
{
288288
// Update test initialize/cleanup method
289-
this.UpdateInfoIfTestInitializeOrCleanupMethod(classInfo, methodInfo, isBase: false, instanceMethods: instanceMethods, testInitializeAttributeType: testInitializeAttributeType, testCleanupAttributeType: testCleanupAttributeType);
289+
this.UpdateInfoIfTestInitializeOrCleanupMethod(classInfo, methodInfo, isBase: false, instanceMethods: instanceMethods, testInitializeAttributeType: testInitializeAttributeType, testCleanupAttributeType: testCleanupAttributeType);
290290

291291
if (this.IsAssemblyOrClassInitializeMethod(methodInfo, classInitializeAttributeType))
292292
{
@@ -634,6 +634,7 @@ private int GetTestTimeout(MethodInfo methodInfo, TestMethod testMethod)
634634
{
635635
Debug.Assert(methodInfo != null, "TestMethod should be non-null");
636636
var timeoutAttribute = this.reflectionHelper.GetAttribute<TimeoutAttribute>(methodInfo);
637+
var globalTimeout = MSTestSettings.CurrentSettings.TestTimeout;
637638

638639
if (timeoutAttribute != null)
639640
{
@@ -645,6 +646,10 @@ private int GetTestTimeout(MethodInfo methodInfo, TestMethod testMethod)
645646

646647
return timeoutAttribute.Timeout;
647648
}
649+
else if (globalTimeout > 0)
650+
{
651+
return globalTimeout;
652+
}
648653

649654
return TestMethodInfo.TimeoutWhenNotSet;
650655
}

src/Adapter/MSTest.CoreAdapter/MSTestSettings.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public MSTestSettings()
5555
this.ForcedLegacyMode = false;
5656
this.TestSettingsFile = null;
5757
this.DisableParallelization = false;
58+
this.TestTimeout = 0;
5859
}
5960

6061
/// <summary>
@@ -143,6 +144,11 @@ private set
143144
/// </remarks>
144145
public bool DisableParallelization { get; private set; }
145146

147+
/// <summary>
148+
/// Gets specified global test case timeout
149+
/// </summary>
150+
public int TestTimeout { get; private set; }
151+
146152
/// <summary>
147153
/// Populate settings based on existing settings object.
148154
/// </summary>
@@ -157,6 +163,7 @@ public static void PopulateSettings(MSTestSettings settings)
157163
CurrentSettings.ParallelizationWorkers = settings.ParallelizationWorkers;
158164
CurrentSettings.ParallelizationScope = settings.ParallelizationScope;
159165
CurrentSettings.DisableParallelization = settings.DisableParallelization;
166+
CurrentSettings.TestTimeout = settings.TestTimeout;
160167
}
161168

162169
/// <summary>
@@ -274,6 +281,7 @@ private static MSTestSettings ToSettings(XmlReader reader)
274281
// <CaptureTraceOutput>true</CaptureTraceOutput>
275282
// <MapInconclusiveToFailed>false</MapInconclusiveToFailed>
276283
// <EnableBaseClassTestMethodsFromOtherAssemblies>false</EnableBaseClassTestMethodsFromOtherAssemblies>
284+
// <TestTimeout>5000<TestTimeout>
277285
// <Parallelize>
278286
// <Workers>4</Workers>
279287
// <Scope>TestClass</Scope>
@@ -362,6 +370,16 @@ private static MSTestSettings ToSettings(XmlReader reader)
362370
break;
363371
}
364372

373+
case "TESTTIMEOUT":
374+
{
375+
if (int.TryParse(reader.ReadInnerXml(), out int testTimeout) && testTimeout > 0)
376+
{
377+
settings.TestTimeout = testTimeout;
378+
}
379+
380+
break;
381+
}
382+
365383
default:
366384
{
367385
PlatformServiceProvider.Instance.SettingsProvider.Load(reader.ReadSubtree());

0 commit comments

Comments
 (0)