Skip to content

Commit 982b20d

Browse files
MarcoRossignoliMarco Rossignoli
authored andcommitted
Fix shutdown order for server mode (#3306)
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
1 parent b095754 commit 982b20d

6 files changed

Lines changed: 819 additions & 5 deletions

File tree

samples/Playground/Playground.csproj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@
1212
<ItemGroup>
1313
<ProjectReference Include="$(RepoRoot)src\Platform\Microsoft.Testing.Platform\Microsoft.Testing.Platform.csproj" />
1414
<ProjectReference Include="$(RepoRoot)src\Adapter\MSTest.TestAdapter\MSTest.TestAdapter.csproj" />
15+
<ProjectReference Include="$(RepoRoot)src\Analyzers\MSTest.Analyzers.CodeFixes\MSTest.Analyzers.CodeFixes.csproj"
16+
PrivateAssets="all"
17+
ReferenceOutputAssembly="false"
18+
OutputItemType="Analyzer" />
19+
<ProjectReference Include="$(RepoRoot)src\Analyzers\MSTest.Analyzers\MSTest.Analyzers.csproj"
20+
PrivateAssets="all"
21+
ReferenceOutputAssembly="false"
22+
OutputItemType="Analyzer" />
23+
<PackageReference Include="StreamJsonRpc" />
24+
<ProjectReference Include="$(RepoRoot)src\Platform\Microsoft.Testing.Extensions.Telemetry\Microsoft.Testing.Extensions.Telemetry.csproj" />
1525
</ItemGroup>
1626

1727
<ItemGroup>

samples/Playground/Program.cs

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,37 @@ public static async Task<int> Main(string[] args)
1818
ITestApplicationBuilder testApplicationBuilder = await TestApplication.CreateBuilderAsync(args);
1919
testApplicationBuilder.AddMSTest(() => [Assembly.GetEntryAssembly()!]);
2020

21-
// Enable Trx
22-
// testApplicationBuilder.AddTrxReportProvider();
23-
using ITestApplication testApplication = await testApplicationBuilder.BuildAsync();
24-
return await testApplication.RunAsync();
21+
// Enable Trx
22+
// testApplicationBuilder.AddTrxReportProvider();
23+
24+
// Enable Telemetry
25+
// testApplicationBuilder.AddAppInsightsTelemetryProvider();
26+
using ITestApplication testApplication = await testApplicationBuilder.BuildAsync();
27+
return await testApplication.RunAsync();
28+
}
29+
else
30+
{
31+
Environment.SetEnvironmentVariable("TESTSERVERMODE", "0");
32+
using TestingPlatformClient client = await TestingPlatformClientFactory.StartAsServerAndConnectAsync(Environment.ProcessPath!, enableDiagnostic: true);
33+
34+
await client.InitializeAsync();
35+
List<TestNodeUpdate> testNodeUpdates = new();
36+
ResponseListener discoveryResponse = await client.DiscoverTestsAsync(Guid.NewGuid(), node =>
37+
{
38+
testNodeUpdates.AddRange(node);
39+
return Task.CompletedTask;
40+
});
41+
await discoveryResponse.WaitCompletionAsync();
42+
43+
ResponseListener runRequest = await client.RunTestsAsync(Guid.NewGuid(), testNodeUpdates.Select(x => x.Node).ToArray(), node =>
44+
{
45+
return Task.CompletedTask;
46+
});
47+
await runRequest.WaitCompletionAsync();
48+
49+
await client.ExitAsync();
50+
51+
return 0;
52+
}
2553
}
2654
}

0 commit comments

Comments
 (0)