Skip to content

Commit bd712d0

Browse files
Remove the TestingPlatformServer if the runner is disabled (#2409) (#2410)
1 parent d4e0298 commit bd712d0

File tree

6 files changed

+74
-13
lines changed

6 files changed

+74
-13
lines changed

eng/Versions.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<MicrosoftTestingExtensionsCodeCoverageVersion>17.10.4-preview.24120.6</MicrosoftTestingExtensionsCodeCoverageVersion>
3737
<!-- Pinned to 4.18.4 for security -->
3838
<MoqVersion>4.18.4</MoqVersion>
39-
<MSBuildStructuredLogger>2.1.858</MSBuildStructuredLogger>
39+
<MSBuildStructuredLogger>2.2.169</MSBuildStructuredLogger>
4040
<PollyVersion>8.2.0</PollyVersion>
4141
<PollyContribWaitAndRetryVersion>1.1.1</PollyContribWaitAndRetryVersion>
4242
<StrongNamerVersion>0.2.5</StrongNamerVersion>

src/Adapter/Build/Common/MSTest.TestAdapter.targets

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<PropertyGroup>
55
<GenerateTestingPlatformEntryPoint Condition=" '$(GenerateTestingPlatformEntryPoint)' == '' ">$(EnableMSTestRunner)</GenerateTestingPlatformEntryPoint>
66
<GenerateProgramFile Condition=" '$(EnableMSTestRunner)' == 'true' ">false</GenerateProgramFile>
7+
<DisableTestingPlatformServerCapability Condition=" '$(EnableMSTestRunner)' == 'false' or '$(EnableMSTestRunner)' == '' " >true</DisableTestingPlatformServerCapability>
78
</PropertyGroup>
89

910
<ItemGroup>

src/Adapter/Build/NetWithWinUI/MSTest.TestAdapter.targets

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<PropertyGroup>
55
<GenerateTestingPlatformEntryPoint Condition=" '$(GenerateTestingPlatformEntryPoint)' == '' ">$(EnableMSTestRunner)</GenerateTestingPlatformEntryPoint>
66
<GenerateProgramFile Condition=" '$(EnableMSTestRunner)' == 'true' ">false</GenerateProgramFile>
7+
<DisableTestingPlatformServerCapability Condition=" '$(EnableMSTestRunner)' == 'false' or '$(EnableMSTestRunner)' == '' " >true</DisableTestingPlatformServerCapability>
78
</PropertyGroup>
89

910
<PropertyGroup Condition=" '$(UseWinUI)' == 'true' ">

src/Adapter/Build/Universal/MSTest.TestAdapter.targets

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<!-- Handle the coexistance between testing platform and Microsoft.NET.Test.Sdk -->
66
<GenerateTestingPlatformEntryPoint Condition=" '$(GenerateTestingPlatformEntryPoint)' == '' ">$(EnableMSTestRunner)</GenerateTestingPlatformEntryPoint>
77
<GenerateProgramFile Condition=" '$(EnableMSTestRunner)' == 'true' ">false</GenerateProgramFile>
8+
<DisableTestingPlatformServerCapability Condition=" '$(EnableMSTestRunner)' == 'false' or '$(EnableMSTestRunner)' == '' " >true</DisableTestingPlatformServerCapability>
89
</PropertyGroup>
910

1011
<Target Name="GetMSTestV2CultureHierarchy">

test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/MSTestRunnerTests.cs

+54-12
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

4+
using Microsoft.Build.Logging.StructuredLogger;
45
using Microsoft.Testing.Platform.Acceptance.IntegrationTests.Helpers;
56

7+
using SL = Microsoft.Build.Logging.StructuredLogger;
8+
using SystemTask = System.Threading.Tasks.Task;
9+
610
namespace Microsoft.Testing.Platform.Acceptance.IntegrationTests;
711

812
[TestGroup]
@@ -19,7 +23,7 @@ public MSTestRunnerTests(ITestExecutionContext testExecutionContext, AcceptanceF
1923
}
2024

2125
[ArgumentsProvider(nameof(GetBuildMatrixTfmBuildVerbConfiguration))]
22-
public async Task EnableMSTestRunner_True_Will_Run_Standalone(string tfm, BuildConfiguration buildConfiguration, Verb verb)
26+
public async SystemTask EnableMSTestRunner_True_Will_Run_Standalone(string tfm, BuildConfiguration buildConfiguration, Verb verb)
2327
{
2428
await Lock.WaitAsync();
2529
try
@@ -39,6 +43,12 @@ public async Task EnableMSTestRunner_True_Will_Run_Standalone(string tfm, BuildC
3943
compilationResult = await DotnetCli.RunAsync(
4044
$"{verb} -m:1 -nodeReuse:false {generator.TargetAssetPath} -c {buildConfiguration} -bl:{binlogFile} -r {RID}",
4145
_acceptanceFixture.NuGetGlobalPackagesFolder.Path);
46+
47+
SL.Build binLog = SL.Serialization.Read(binlogFile);
48+
Assert.IsNotEmpty(binLog.FindChildrenRecursive<AddItem>()
49+
.Where(x => x.Title.Contains("ProjectCapability"))
50+
.Where(x => x.Children.Any(c => ((Item)c).Name == "TestingPlatformServer")));
51+
4252
var testHost = TestInfrastructure.TestHost.LocateFrom(generator.TargetAssetPath, AssetName, tfm, buildConfiguration: buildConfiguration, verb: verb);
4353
var testHostResult = await testHost.ExecuteAsync();
4454
testHostResult.AssertOutputContains("Passed! - Failed: 0, Passed: 1, Skipped: 0, Total: 1");
@@ -50,7 +60,7 @@ public async Task EnableMSTestRunner_True_Will_Run_Standalone(string tfm, BuildC
5060
}
5161

5262
[ArgumentsProvider(nameof(GetBuildMatrixTfmBuildVerbConfiguration))]
53-
public async Task EnableMSTestRunner_True_WithCustomEntryPoint_Will_Run_Standalone(string tfm, BuildConfiguration buildConfiguration, Verb verb)
63+
public async SystemTask EnableMSTestRunner_True_WithCustomEntryPoint_Will_Run_Standalone(string tfm, BuildConfiguration buildConfiguration, Verb verb)
5464
{
5565
await Lock.WaitAsync();
5666
try
@@ -94,21 +104,21 @@ public async Task EnableMSTestRunner_True_WithCustomEntryPoint_Will_Run_Standalo
94104
}
95105

96106
[ArgumentsProvider(nameof(GetBuildMatrixTfmBuildVerbConfiguration))]
97-
public async Task EnableMSTestRunner_False_Will_Run_Empty_Program_EntryPoint_From_Tpv2_SDK(string tfm, BuildConfiguration buildConfiguration, Verb verb)
107+
public async SystemTask EnableMSTestRunner_False_Will_Run_Empty_Program_EntryPoint_From_Tpv2_SDK(string tfm, BuildConfiguration buildConfiguration, Verb verb)
98108
{
99109
await Lock.WaitAsync();
100110
try
101111
{
102112
using TestAsset generator = await TestAsset.GenerateAssetAsync(
103-
AssetName,
104-
CurrentMSTestSourceCode
105-
.PatchCodeWithReplace("$TargetFramework$", $"<TargetFramework>{tfm}</TargetFramework>")
106-
.PatchCodeWithReplace("$MicrosoftNETTestSdkVersion$", MicrosoftNETTestSdkVersion)
107-
.PatchCodeWithReplace("$MSTestVersion$", MSTestVersion)
108-
.PatchCodeWithReplace("$EnableMSTestRunner$", "<EnableMSTestRunner>false</EnableMSTestRunner>")
109-
.PatchCodeWithReplace("$OutputType$", "<OutputType>Exe</OutputType>")
110-
.PatchCodeWithReplace("$Extra$", string.Empty),
111-
addPublicFeeds: true);
113+
AssetName,
114+
CurrentMSTestSourceCode
115+
.PatchCodeWithReplace("$TargetFramework$", $"<TargetFramework>{tfm}</TargetFramework>")
116+
.PatchCodeWithReplace("$MicrosoftNETTestSdkVersion$", MicrosoftNETTestSdkVersion)
117+
.PatchCodeWithReplace("$MSTestVersion$", MSTestVersion)
118+
.PatchCodeWithReplace("$EnableMSTestRunner$", "<EnableMSTestRunner>false</EnableMSTestRunner>")
119+
.PatchCodeWithReplace("$OutputType$", "<OutputType>Exe</OutputType>")
120+
.PatchCodeWithReplace("$Extra$", string.Empty),
121+
addPublicFeeds: true);
112122
string binlogFile = Path.Combine(generator.TargetAssetPath, "msbuild.binlog");
113123
var compilationResult = await DotnetCli.RunAsync($"restore -m:1 -nodeReuse:false {generator.TargetAssetPath} -r {RID}", _acceptanceFixture.NuGetGlobalPackagesFolder.Path);
114124
try
@@ -134,4 +144,36 @@ public async Task EnableMSTestRunner_False_Will_Run_Empty_Program_EntryPoint_Fro
134144
Lock.Release();
135145
}
136146
}
147+
148+
[ArgumentsProvider(nameof(GetBuildMatrixTfmBuildVerbConfiguration))]
149+
public async SystemTask EnableMSTestRunner_False_Wont_Flow_TestingPlatformServer_Capability(string tfm, BuildConfiguration buildConfiguration, Verb verb)
150+
{
151+
await Lock.WaitAsync();
152+
try
153+
{
154+
using TestAsset generator = await TestAsset.GenerateAssetAsync(
155+
AssetName,
156+
CurrentMSTestSourceCode
157+
.PatchCodeWithReplace("$TargetFramework$", $"<TargetFramework>{tfm}</TargetFramework>")
158+
.PatchCodeWithReplace("$MicrosoftNETTestSdkVersion$", MicrosoftNETTestSdkVersion)
159+
.PatchCodeWithReplace("$MSTestVersion$", MSTestVersion)
160+
.PatchCodeWithReplace("$EnableMSTestRunner$", string.Empty)
161+
.PatchCodeWithReplace("$OutputType$", string.Empty)
162+
.PatchCodeWithReplace("$Extra$", string.Empty),
163+
addPublicFeeds: false);
164+
165+
string binlogFile = Path.Combine(generator.TargetAssetPath, "msbuild.binlog");
166+
var compilationResult = await DotnetCli.RunAsync($"restore -m:1 -nodeReuse:false {generator.TargetAssetPath} -r {RID}", _acceptanceFixture.NuGetGlobalPackagesFolder.Path);
167+
compilationResult = await DotnetCli.RunAsync($"{verb} -bl:{binlogFile} -m:1 -nodeReuse:false {generator.TargetAssetPath} -c {buildConfiguration} -r {RID} ", _acceptanceFixture.NuGetGlobalPackagesFolder.Path);
168+
169+
SL.Build binLog = SL.Serialization.Read(binlogFile);
170+
Assert.IsEmpty(binLog.FindChildrenRecursive<AddItem>()
171+
.Where(x => x.Title.Contains("ProjectCapability"))
172+
.Where(x => x.Children.Any(c => ((Item)c).Name == "TestingPlatformServer")));
173+
}
174+
finally
175+
{
176+
Lock.Release();
177+
}
178+
}
137179
}

test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/testsbaseline.txt

+16
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,22 @@ Microsoft.Testing.Platform.Acceptance.IntegrationTests.Microsoft.Testing.Platfor
170170
Microsoft.Testing.Platform.Acceptance.IntegrationTests.Microsoft.Testing.Platform.Acceptance.IntegrationTests.MSTestRunnerTests.EnableMSTestRunner_False_Will_Run_Empty_Program_EntryPoint_From_Tpv2_SDK(string, Microsoft.Testing.TestInfrastructure.BuildConfiguration, Microsoft.Testing.TestInfrastructure.Verb) (net8.0,Debug,publish)
171171
Microsoft.Testing.Platform.Acceptance.IntegrationTests.Microsoft.Testing.Platform.Acceptance.IntegrationTests.MSTestRunnerTests.EnableMSTestRunner_False_Will_Run_Empty_Program_EntryPoint_From_Tpv2_SDK(string, Microsoft.Testing.TestInfrastructure.BuildConfiguration, Microsoft.Testing.TestInfrastructure.Verb) (net8.0,Release,build)
172172
Microsoft.Testing.Platform.Acceptance.IntegrationTests.Microsoft.Testing.Platform.Acceptance.IntegrationTests.MSTestRunnerTests.EnableMSTestRunner_False_Will_Run_Empty_Program_EntryPoint_From_Tpv2_SDK(string, Microsoft.Testing.TestInfrastructure.BuildConfiguration, Microsoft.Testing.TestInfrastructure.Verb) (net8.0,Release,publish)
173+
Microsoft.Testing.Platform.Acceptance.IntegrationTests.Microsoft.Testing.Platform.Acceptance.IntegrationTests.MSTestRunnerTests.EnableMSTestRunner_False_Wont_Flow_TestingPlatformServer_Capability(string, Microsoft.Testing.TestInfrastructure.BuildConfiguration, Microsoft.Testing.TestInfrastructure.Verb) (net462,Debug,build)
174+
Microsoft.Testing.Platform.Acceptance.IntegrationTests.Microsoft.Testing.Platform.Acceptance.IntegrationTests.MSTestRunnerTests.EnableMSTestRunner_False_Wont_Flow_TestingPlatformServer_Capability(string, Microsoft.Testing.TestInfrastructure.BuildConfiguration, Microsoft.Testing.TestInfrastructure.Verb) (net462,Debug,publish)
175+
Microsoft.Testing.Platform.Acceptance.IntegrationTests.Microsoft.Testing.Platform.Acceptance.IntegrationTests.MSTestRunnerTests.EnableMSTestRunner_False_Wont_Flow_TestingPlatformServer_Capability(string, Microsoft.Testing.TestInfrastructure.BuildConfiguration, Microsoft.Testing.TestInfrastructure.Verb) (net462,Release,build)
176+
Microsoft.Testing.Platform.Acceptance.IntegrationTests.Microsoft.Testing.Platform.Acceptance.IntegrationTests.MSTestRunnerTests.EnableMSTestRunner_False_Wont_Flow_TestingPlatformServer_Capability(string, Microsoft.Testing.TestInfrastructure.BuildConfiguration, Microsoft.Testing.TestInfrastructure.Verb) (net462,Release,publish)
177+
Microsoft.Testing.Platform.Acceptance.IntegrationTests.Microsoft.Testing.Platform.Acceptance.IntegrationTests.MSTestRunnerTests.EnableMSTestRunner_False_Wont_Flow_TestingPlatformServer_Capability(string, Microsoft.Testing.TestInfrastructure.BuildConfiguration, Microsoft.Testing.TestInfrastructure.Verb) (net6.0,Debug,build)
178+
Microsoft.Testing.Platform.Acceptance.IntegrationTests.Microsoft.Testing.Platform.Acceptance.IntegrationTests.MSTestRunnerTests.EnableMSTestRunner_False_Wont_Flow_TestingPlatformServer_Capability(string, Microsoft.Testing.TestInfrastructure.BuildConfiguration, Microsoft.Testing.TestInfrastructure.Verb) (net6.0,Debug,publish)
179+
Microsoft.Testing.Platform.Acceptance.IntegrationTests.Microsoft.Testing.Platform.Acceptance.IntegrationTests.MSTestRunnerTests.EnableMSTestRunner_False_Wont_Flow_TestingPlatformServer_Capability(string, Microsoft.Testing.TestInfrastructure.BuildConfiguration, Microsoft.Testing.TestInfrastructure.Verb) (net6.0,Release,build)
180+
Microsoft.Testing.Platform.Acceptance.IntegrationTests.Microsoft.Testing.Platform.Acceptance.IntegrationTests.MSTestRunnerTests.EnableMSTestRunner_False_Wont_Flow_TestingPlatformServer_Capability(string, Microsoft.Testing.TestInfrastructure.BuildConfiguration, Microsoft.Testing.TestInfrastructure.Verb) (net6.0,Release,publish)
181+
Microsoft.Testing.Platform.Acceptance.IntegrationTests.Microsoft.Testing.Platform.Acceptance.IntegrationTests.MSTestRunnerTests.EnableMSTestRunner_False_Wont_Flow_TestingPlatformServer_Capability(string, Microsoft.Testing.TestInfrastructure.BuildConfiguration, Microsoft.Testing.TestInfrastructure.Verb) (net7.0,Debug,build)
182+
Microsoft.Testing.Platform.Acceptance.IntegrationTests.Microsoft.Testing.Platform.Acceptance.IntegrationTests.MSTestRunnerTests.EnableMSTestRunner_False_Wont_Flow_TestingPlatformServer_Capability(string, Microsoft.Testing.TestInfrastructure.BuildConfiguration, Microsoft.Testing.TestInfrastructure.Verb) (net7.0,Debug,publish)
183+
Microsoft.Testing.Platform.Acceptance.IntegrationTests.Microsoft.Testing.Platform.Acceptance.IntegrationTests.MSTestRunnerTests.EnableMSTestRunner_False_Wont_Flow_TestingPlatformServer_Capability(string, Microsoft.Testing.TestInfrastructure.BuildConfiguration, Microsoft.Testing.TestInfrastructure.Verb) (net7.0,Release,build)
184+
Microsoft.Testing.Platform.Acceptance.IntegrationTests.Microsoft.Testing.Platform.Acceptance.IntegrationTests.MSTestRunnerTests.EnableMSTestRunner_False_Wont_Flow_TestingPlatformServer_Capability(string, Microsoft.Testing.TestInfrastructure.BuildConfiguration, Microsoft.Testing.TestInfrastructure.Verb) (net7.0,Release,publish)
185+
Microsoft.Testing.Platform.Acceptance.IntegrationTests.Microsoft.Testing.Platform.Acceptance.IntegrationTests.MSTestRunnerTests.EnableMSTestRunner_False_Wont_Flow_TestingPlatformServer_Capability(string, Microsoft.Testing.TestInfrastructure.BuildConfiguration, Microsoft.Testing.TestInfrastructure.Verb) (net8.0,Debug,build)
186+
Microsoft.Testing.Platform.Acceptance.IntegrationTests.Microsoft.Testing.Platform.Acceptance.IntegrationTests.MSTestRunnerTests.EnableMSTestRunner_False_Wont_Flow_TestingPlatformServer_Capability(string, Microsoft.Testing.TestInfrastructure.BuildConfiguration, Microsoft.Testing.TestInfrastructure.Verb) (net8.0,Debug,publish)
187+
Microsoft.Testing.Platform.Acceptance.IntegrationTests.Microsoft.Testing.Platform.Acceptance.IntegrationTests.MSTestRunnerTests.EnableMSTestRunner_False_Wont_Flow_TestingPlatformServer_Capability(string, Microsoft.Testing.TestInfrastructure.BuildConfiguration, Microsoft.Testing.TestInfrastructure.Verb) (net8.0,Release,build)
188+
Microsoft.Testing.Platform.Acceptance.IntegrationTests.Microsoft.Testing.Platform.Acceptance.IntegrationTests.MSTestRunnerTests.EnableMSTestRunner_False_Wont_Flow_TestingPlatformServer_Capability(string, Microsoft.Testing.TestInfrastructure.BuildConfiguration, Microsoft.Testing.TestInfrastructure.Verb) (net8.0,Release,publish)
173189
Microsoft.Testing.Platform.Acceptance.IntegrationTests.Microsoft.Testing.Platform.Acceptance.IntegrationTests.MSTestRunnerTests.EnableMSTestRunner_True_Will_Run_Standalone(string, Microsoft.Testing.TestInfrastructure.BuildConfiguration, Microsoft.Testing.TestInfrastructure.Verb) (net462,Debug,build)
174190
Microsoft.Testing.Platform.Acceptance.IntegrationTests.Microsoft.Testing.Platform.Acceptance.IntegrationTests.MSTestRunnerTests.EnableMSTestRunner_True_Will_Run_Standalone(string, Microsoft.Testing.TestInfrastructure.BuildConfiguration, Microsoft.Testing.TestInfrastructure.Verb) (net462,Debug,publish)
175191
Microsoft.Testing.Platform.Acceptance.IntegrationTests.Microsoft.Testing.Platform.Acceptance.IntegrationTests.MSTestRunnerTests.EnableMSTestRunner_True_Will_Run_Standalone(string, Microsoft.Testing.TestInfrastructure.BuildConfiguration, Microsoft.Testing.TestInfrastructure.Verb) (net462,Release,build)

0 commit comments

Comments
 (0)