Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the TestingPlatformServer if the runner is disabled #2409

Merged
merged 1 commit into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Adapter/Build/Common/MSTest.TestAdapter.targets
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<PropertyGroup>
<GenerateTestingPlatformEntryPoint Condition=" '$(GenerateTestingPlatformEntryPoint)' == '' ">$(EnableMSTestRunner)</GenerateTestingPlatformEntryPoint>
<GenerateProgramFile Condition=" '$(EnableMSTestRunner)' == 'true' ">false</GenerateProgramFile>
<DisableTestingPlatformServerCapability Condition=" '$(EnableMSTestRunner)' == 'false' or '$(EnableMSTestRunner)' == '' " >true</DisableTestingPlatformServerCapability>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions src/Adapter/Build/NetWithWinUI/MSTest.TestAdapter.targets
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<PropertyGroup>
<GenerateTestingPlatformEntryPoint Condition=" '$(GenerateTestingPlatformEntryPoint)' == '' ">$(EnableMSTestRunner)</GenerateTestingPlatformEntryPoint>
<GenerateProgramFile Condition=" '$(EnableMSTestRunner)' == 'true' ">false</GenerateProgramFile>
<DisableTestingPlatformServerCapability Condition=" '$(EnableMSTestRunner)' == 'false' or '$(EnableMSTestRunner)' == '' " >true</DisableTestingPlatformServerCapability>
</PropertyGroup>

<PropertyGroup Condition=" '$(UseWinUI)' == 'true' ">
Expand Down
1 change: 1 addition & 0 deletions src/Adapter/Build/Universal/MSTest.TestAdapter.targets
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<!-- Handle the coexistance between testing platform and Microsoft.NET.Test.Sdk -->
<GenerateTestingPlatformEntryPoint Condition=" '$(GenerateTestingPlatformEntryPoint)' == '' ">$(EnableMSTestRunner)</GenerateTestingPlatformEntryPoint>
<GenerateProgramFile Condition=" '$(EnableMSTestRunner)' == 'true' ">false</GenerateProgramFile>
<DisableTestingPlatformServerCapability Condition=" '$(EnableMSTestRunner)' == 'false' or '$(EnableMSTestRunner)' == '' " >true</DisableTestingPlatformServerCapability>
</PropertyGroup>

<Target Name="GetMSTestV2CultureHierarchy">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using Microsoft.Build.Logging.StructuredLogger;
using Microsoft.Testing.Platform.Acceptance.IntegrationTests.Helpers;

using SL = Microsoft.Build.Logging.StructuredLogger;
using SystemTask = System.Threading.Tasks.Task;

namespace Microsoft.Testing.Platform.Acceptance.IntegrationTests;

[TestGroup]
Expand All @@ -19,7 +23,7 @@ public MSTestRunnerTests(ITestExecutionContext testExecutionContext, AcceptanceF
}

[ArgumentsProvider(nameof(GetBuildMatrixTfmBuildVerbConfiguration))]
public async Task EnableMSTestRunner_True_Will_Run_Standalone(string tfm, BuildConfiguration buildConfiguration, Verb verb)
public async SystemTask EnableMSTestRunner_True_Will_Run_Standalone(string tfm, BuildConfiguration buildConfiguration, Verb verb)
{
await Lock.WaitAsync();
try
Expand All @@ -39,6 +43,12 @@ public async Task EnableMSTestRunner_True_Will_Run_Standalone(string tfm, BuildC
compilationResult = await DotnetCli.RunAsync(
$"{verb} -m:1 -nodeReuse:false {generator.TargetAssetPath} -c {buildConfiguration} -bl:{binlogFile} -r {RID}",
_acceptanceFixture.NuGetGlobalPackagesFolder.Path);

SL.Build binLog = SL.Serialization.Read(binlogFile);
Assert.IsNotEmpty(binLog.FindChildrenRecursive<AddItem>()
.Where(x => x.Title.Contains("ProjectCapability"))
.Where(x => x.Children.Any(c => ((Item)c).Name == "TestingPlatformServer")));

var testHost = TestInfrastructure.TestHost.LocateFrom(generator.TargetAssetPath, AssetName, tfm, buildConfiguration: buildConfiguration, verb: verb);
var testHostResult = await testHost.ExecuteAsync();
testHostResult.AssertOutputContains("Passed! - Failed: 0, Passed: 1, Skipped: 0, Total: 1");
Expand All @@ -50,7 +60,7 @@ public async Task EnableMSTestRunner_True_Will_Run_Standalone(string tfm, BuildC
}

[ArgumentsProvider(nameof(GetBuildMatrixTfmBuildVerbConfiguration))]
public async Task EnableMSTestRunner_True_WithCustomEntryPoint_Will_Run_Standalone(string tfm, BuildConfiguration buildConfiguration, Verb verb)
public async SystemTask EnableMSTestRunner_True_WithCustomEntryPoint_Will_Run_Standalone(string tfm, BuildConfiguration buildConfiguration, Verb verb)
{
await Lock.WaitAsync();
try
Expand Down Expand Up @@ -94,21 +104,21 @@ public async Task EnableMSTestRunner_True_WithCustomEntryPoint_Will_Run_Standalo
}

[ArgumentsProvider(nameof(GetBuildMatrixTfmBuildVerbConfiguration))]
public async Task EnableMSTestRunner_False_Will_Run_Empty_Program_EntryPoint_From_Tpv2_SDK(string tfm, BuildConfiguration buildConfiguration, Verb verb)
public async SystemTask EnableMSTestRunner_False_Will_Run_Empty_Program_EntryPoint_From_Tpv2_SDK(string tfm, BuildConfiguration buildConfiguration, Verb verb)
{
await Lock.WaitAsync();
try
{
using TestAsset generator = await TestAsset.GenerateAssetAsync(
AssetName,
CurrentMSTestSourceCode
.PatchCodeWithReplace("$TargetFramework$", $"<TargetFramework>{tfm}</TargetFramework>")
.PatchCodeWithReplace("$MicrosoftNETTestSdkVersion$", MicrosoftNETTestSdkVersion)
.PatchCodeWithReplace("$MSTestVersion$", MSTestVersion)
.PatchCodeWithReplace("$EnableMSTestRunner$", "<EnableMSTestRunner>false</EnableMSTestRunner>")
.PatchCodeWithReplace("$OutputType$", "<OutputType>Exe</OutputType>")
.PatchCodeWithReplace("$Extra$", string.Empty),
addPublicFeeds: true);
AssetName,
CurrentMSTestSourceCode
.PatchCodeWithReplace("$TargetFramework$", $"<TargetFramework>{tfm}</TargetFramework>")
.PatchCodeWithReplace("$MicrosoftNETTestSdkVersion$", MicrosoftNETTestSdkVersion)
.PatchCodeWithReplace("$MSTestVersion$", MSTestVersion)
.PatchCodeWithReplace("$EnableMSTestRunner$", "<EnableMSTestRunner>false</EnableMSTestRunner>")
.PatchCodeWithReplace("$OutputType$", "<OutputType>Exe</OutputType>")
.PatchCodeWithReplace("$Extra$", string.Empty),
addPublicFeeds: true);
string binlogFile = Path.Combine(generator.TargetAssetPath, "msbuild.binlog");
var compilationResult = await DotnetCli.RunAsync($"restore -m:1 -nodeReuse:false {generator.TargetAssetPath} -r {RID}", _acceptanceFixture.NuGetGlobalPackagesFolder.Path);
try
Expand All @@ -134,4 +144,36 @@ public async Task EnableMSTestRunner_False_Will_Run_Empty_Program_EntryPoint_Fro
Lock.Release();
}
}

[ArgumentsProvider(nameof(GetBuildMatrixTfmBuildVerbConfiguration))]
public async SystemTask EnableMSTestRunner_False_Wont_Flow_TestingPlatformServer_Capability(string tfm, BuildConfiguration buildConfiguration, Verb verb)
{
await Lock.WaitAsync();
try
{
TestAsset generator = await TestAsset.GenerateAssetAsync(
AssetName,
CurrentMSTestSourceCode
.PatchCodeWithReplace("$TargetFramework$", $"<TargetFramework>{tfm}</TargetFramework>")
.PatchCodeWithReplace("$MicrosoftNETTestSdkVersion$", MicrosoftNETTestSdkVersion)
.PatchCodeWithReplace("$MSTestVersion$", MSTestVersion)
.PatchCodeWithReplace("$EnableMSTestRunner$", string.Empty)
.PatchCodeWithReplace("$OutputType$", string.Empty)
.PatchCodeWithReplace("$Extra$", string.Empty),
addPublicFeeds: false);

string binlogFile = Path.Combine(generator.TargetAssetPath, "msbuild.binlog");
var compilationResult = await DotnetCli.RunAsync($"restore -m:1 -nodeReuse:false {generator.TargetAssetPath} -r {RID}", _acceptanceFixture.NuGetGlobalPackagesFolder.Path);
compilationResult = await DotnetCli.RunAsync($"{verb} -bl:{binlogFile} -m:1 -nodeReuse:false {generator.TargetAssetPath} -c {buildConfiguration} -r {RID} ", _acceptanceFixture.NuGetGlobalPackagesFolder.Path);

SL.Build binLog = SL.Serialization.Read(binlogFile);
Assert.IsEmpty(binLog.FindChildrenRecursive<AddItem>()
.Where(x => x.Title.Contains("ProjectCapability"))
.Where(x => x.Children.Any(c => ((Item)c).Name == "TestingPlatformServer")));
}
finally
{
Lock.Release();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,22 @@ Microsoft.Testing.Platform.Acceptance.IntegrationTests.Microsoft.Testing.Platfor
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
Expand Down