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

Add default VS settings to playground #3756

Merged
merged 3 commits into from
Jun 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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