Skip to content

Commit

Permalink
Add default VS settings to playground (#3756)
Browse files Browse the repository at this point in the history
* Fix which value is used in platform warning

* Add default VS settings to playground
  • Loading branch information
nohwnd authored Jun 16, 2022
1 parent 32d8acf commit 85259a8
Showing 1 changed file with 27 additions and 10 deletions.
37 changes: 27 additions & 10 deletions playground/TestPlatform.Playground/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ static void Main(string[] args)
{
// This project references TranslationLayer, vstest.console, TestHostProvider, testhost and MSTest1 projects, to make sure
// we build all the dependencies of that are used to run tests via VSTestConsoleWrapper. It then copies the components from
// their original build locations, to $(TargetDir)\vstest.console directory, and it's subfolders to create an executable
// their original build locations, to $(TargetDir)\vstest.console directory, and its subfolders to create an executable
// copy of TestPlatform that is similar to what we ship.
//
// The copying might trigger only on re-build, if you see outdated dependencies, Rebuild this project instead of just Build.
Expand All @@ -38,14 +38,30 @@ static void Main(string[] args)

var console = Path.Combine(here, "vstest.console", "vstest.console.exe");

var sourceSettings = @"
<RunSettings>
<RunConfiguration>
<InIsolation>true</InIsolation>
<MaxCpuCount>0</MaxCpuCount>
</RunConfiguration>
</RunSettings>
";
var maxCpuCount = Environment.GetEnvironmentVariable("VSTEST_MAX_CPU_COUNT") ?? "0";
var sourceSettings = $$$"""
<RunSettings>
<RunConfiguration>
<!-- <MaxCpuCount>1</MaxCpuCount> -->
<!-- <TargetPlatform>x86</TargetPlatform> -->
<!-- <TargetFrameworkVersion>net472</TargetFrameworkVersion> -->
<!-- The settings below are what VS sends by default. -->
<CollectSourceInformation>False</CollectSourceInformation>
<DesignMode>True</DesignMode>
</RunConfiguration>
<BoostTestInternalSettings xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<VSProcessId>999999</VSProcessId>
</BoostTestInternalSettings>
<GoogleTestAdapterSettings xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SolutionSettings>
<Settings />
</SolutionSettings>
<ProjectSettings />
</GoogleTestAdapterSettings>
</RunSettings>
""";

var sources = new[] {
Path.Combine(playground, "MSTest1", "bin", "Debug", "net472", "MSTest1.dll"),
Expand Down Expand Up @@ -81,7 +97,7 @@ static void Main(string[] args)
{
EnvironmentVariables = EnvironmentVariables.Variables,
LogFilePath = Path.Combine(here, "logs", "log.txt"),
TraceLevel = TraceLevel.Verbose,
TraceLevel = TraceLevel.Off,
};
var options = new TestPlatformOptions
{
Expand Down Expand Up @@ -110,6 +126,7 @@ static void Main(string[] args)
//r.RunTests(sources, sourceSettings, options, sessionHandler.TestSessionInfo, new TestRunHandler());
var rd = sw.ElapsedMilliseconds;
Console.WriteLine($"Discovery: {discoveryDuration} ms, Run: {rd} ms, Total: {discoveryDuration + rd} ms");
Console.WriteLine($"Settings:\n{sourceSettings}");
}

public class PlaygroundTestDiscoveryHandler : ITestDiscoveryEventsHandler, ITestDiscoveryEventsHandler2
Expand Down

0 comments on commit 85259a8

Please sign in to comment.