Skip to content

Commit

Permalink
Fix shutdown order for server mode (#3306)
Browse files Browse the repository at this point in the history
Co-authored-by: Marco Rossignoli <mrossignol@microsoft.com>
# Conflicts:
#	samples/Playground/Playground.csproj
#	samples/Playground/Program.cs
#	samples/Playground/ServerMode/TestingPlatformClientFactory.cs
#	samples/Playground/ServerMode/v1.0.0/TestingPlatformClient.cs
  • Loading branch information
MarcoRossignoli authored and Evangelink committed Aug 5, 2024
1 parent b095754 commit 982b20d
Show file tree
Hide file tree
Showing 6 changed files with 819 additions and 5 deletions.
10 changes: 10 additions & 0 deletions samples/Playground/Playground.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@
<ItemGroup>
<ProjectReference Include="$(RepoRoot)src\Platform\Microsoft.Testing.Platform\Microsoft.Testing.Platform.csproj" />
<ProjectReference Include="$(RepoRoot)src\Adapter\MSTest.TestAdapter\MSTest.TestAdapter.csproj" />
<ProjectReference Include="$(RepoRoot)src\Analyzers\MSTest.Analyzers.CodeFixes\MSTest.Analyzers.CodeFixes.csproj"
PrivateAssets="all"
ReferenceOutputAssembly="false"
OutputItemType="Analyzer" />
<ProjectReference Include="$(RepoRoot)src\Analyzers\MSTest.Analyzers\MSTest.Analyzers.csproj"
PrivateAssets="all"
ReferenceOutputAssembly="false"
OutputItemType="Analyzer" />
<PackageReference Include="StreamJsonRpc" />
<ProjectReference Include="$(RepoRoot)src\Platform\Microsoft.Testing.Extensions.Telemetry\Microsoft.Testing.Extensions.Telemetry.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
36 changes: 32 additions & 4 deletions samples/Playground/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,37 @@ public static async Task<int> Main(string[] args)
ITestApplicationBuilder testApplicationBuilder = await TestApplication.CreateBuilderAsync(args);
testApplicationBuilder.AddMSTest(() => [Assembly.GetEntryAssembly()!]);

// Enable Trx
// testApplicationBuilder.AddTrxReportProvider();
using ITestApplication testApplication = await testApplicationBuilder.BuildAsync();
return await testApplication.RunAsync();
// Enable Trx
// testApplicationBuilder.AddTrxReportProvider();

// Enable Telemetry
// testApplicationBuilder.AddAppInsightsTelemetryProvider();
using ITestApplication testApplication = await testApplicationBuilder.BuildAsync();
return await testApplication.RunAsync();
}
else
{
Environment.SetEnvironmentVariable("TESTSERVERMODE", "0");
using TestingPlatformClient client = await TestingPlatformClientFactory.StartAsServerAndConnectAsync(Environment.ProcessPath!, enableDiagnostic: true);

await client.InitializeAsync();
List<TestNodeUpdate> testNodeUpdates = new();
ResponseListener discoveryResponse = await client.DiscoverTestsAsync(Guid.NewGuid(), node =>
{
testNodeUpdates.AddRange(node);
return Task.CompletedTask;
});
await discoveryResponse.WaitCompletionAsync();

ResponseListener runRequest = await client.RunTestsAsync(Guid.NewGuid(), testNodeUpdates.Select(x => x.Node).ToArray(), node =>
{
return Task.CompletedTask;
});
await runRequest.WaitCompletionAsync();

await client.ExitAsync();

return 0;
}
}
}
Loading

0 comments on commit 982b20d

Please sign in to comment.