Skip to content

Commit d96f224

Browse files
maraflewingpavelsavara
authored
[browser] Run tests in parallel (#98492)
Co-authored-by: Larry Ewing <[email protected]> Co-authored-by: Pavel Savara <[email protected]>
1 parent 223e9e7 commit d96f224

File tree

6 files changed

+23
-5
lines changed

6 files changed

+23
-5
lines changed

eng/testing/tests.browser.targets

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
<WasmXHarnessMonoArgs Condition="'$(XunitShowProgress)' == 'true'">$(WasmXHarnessMonoArgs) --setenv=XHARNESS_LOG_TEST_START=true</WasmXHarnessMonoArgs>
9595
<!-- help unit test with PlatformDetection.IsThreadingSupported via IsBrowserThreadingSupported env variable -->
9696
<WasmXHarnessMonoArgs Condition="'$(WasmEnableThreads)' == 'true'">$(WasmXHarnessMonoArgs) --setenv=IsBrowserThreadingSupported=true</WasmXHarnessMonoArgs>
97+
<WasmXHarnessMaxParallelThreads Condition="'$(WasmEnableThreads)' == 'true' and '$(WasmXHarnessMaxParallelThreads)' == ''">8</WasmXHarnessMaxParallelThreads>
9798
</PropertyGroup>
9899

99100
<PropertyGroup Condition="'$(RunScriptCommand)' == ''">
@@ -112,6 +113,7 @@
112113
<_XHarnessArgs Condition="'$(WasmXHarnessArgsCli)' != ''" >$(_XHarnessArgs) $(WasmXHarnessArgsCli)</_XHarnessArgs>
113114

114115
<_AppArgs Condition="'$(WasmEnableThreads)' == 'true'">$(_AppArgs) -threads</_AppArgs>
116+
<_AppArgs Condition="'$(WasmXHarnessMaxParallelThreads)' != ''">$(_AppArgs) -parallelThreads $(WasmXHarnessMaxParallelThreads)</_AppArgs>
115117
<!-- There are two flavors of WasmXHarnessArgs and WasmXHarnessMonoArgs, one is MSBuild property and the other is environment variable -->
116118
<RunScriptCommand Condition="'$(OS)' != 'Windows_NT'">$HARNESS_RUNNER $(_XHarnessArgs) %24XHARNESS_ARGS %24WasmXHarnessArgs -- $(WasmXHarnessMonoArgs) %24WasmXHarnessMonoArgs $(_AppArgs) %24WasmTestAppArgs</RunScriptCommand>
117119
<RunScriptCommand Condition="'$(OS)' == 'Windows_NT'">%HARNESS_RUNNER% $(_XHarnessArgs) %XHARNESS_ARGS% %WasmXHarnessArgs% -- $(WasmXHarnessMonoArgs) %WasmXHarnessMonoArgs% $(_AppArgs) %WasmTestAppArgs%</RunScriptCommand>

src/libraries/Common/tests/WasmTestRunner/WasmTestRunner.cs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
public class WasmTestRunner : WasmApplicationEntryPoint
1111
{
12-
// TODO: Set max threads for run in parallel
13-
// protected override int? MaxParallelThreads => RunInParallel ? 8 : base.MaxParallelThreads;
12+
protected int MaxParallelThreadsFromArg { get; set; }
13+
protected override int? MaxParallelThreads => RunInParallel ? MaxParallelThreadsFromArg : base.MaxParallelThreads;
1414

1515
public static async Task<int> Main(string[] args)
1616
{
@@ -65,9 +65,11 @@ public static async Task<int> Main(string[] args)
6565
break;
6666
case "-threads":
6767
runner.IsThreadless = false;
68-
// TODO: Enable run in parallel
69-
// runner.RunInParallel = true;
70-
// Console.WriteLine($"Running in parallel with {runner.MaxParallelThreads} threads.");
68+
break;
69+
case "-parallelThreads":
70+
runner.MaxParallelThreadsFromArg = Math.Max(1, int.Parse(args[i + 1]));
71+
runner.RunInParallel = runner.MaxParallelThreadsFromArg > 1;
72+
i++;
7173
break;
7274
case "-verbosity":
7375
runner.MinimumLogLevel = Enum.Parse<MinimumLogLevel>(args[i + 1]);
@@ -105,4 +107,12 @@ public static async Task<int> Main(string[] args)
105107

106108
return res;
107109
}
110+
111+
public override Task RunAsync()
112+
{
113+
if (RunInParallel)
114+
Console.WriteLine($"Running in parallel with {MaxParallelThreads} threads.");
115+
116+
return base.RunAsync();
117+
}
108118
}

src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
<!-- This WASM test is problematic and slow right now. This sets the xharness timeout but there is also override in sendtohelix-browser.targets -->
1919
<WasmXHarnessTestsTimeout>01:15:00</WasmXHarnessTestsTimeout>
20+
<WasmXHarnessMaxParallelThreads>1</WasmXHarnessMaxParallelThreads>
2021
</PropertyGroup>
2122

2223
<ItemGroup>

src/libraries/System.Runtime.InteropServices.JavaScript/tests/System.Runtime.InteropServices.JavaScript.UnitTests/System.Runtime.InteropServices.JavaScript.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
1515
<!-- to see timing and which test aborted the runtime -->
1616
<XunitShowProgress>true</XunitShowProgress>
17+
<WasmXHarnessMaxParallelThreads>1</WasmXHarnessMaxParallelThreads>
1718
</PropertyGroup>
1819
<!-- Make debugging easier -->
1920
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">

src/libraries/System.Runtime/tests/System.Buffers.Tests/System.Buffers.Tests.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
<IncludeRemoteExecutor>true</IncludeRemoteExecutor>
66
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
77
</PropertyGroup>
8+
<PropertyGroup Condition="'$(TargetOS)' == 'browser'">
9+
<WasmXHarnessMaxParallelThreads>1</WasmXHarnessMaxParallelThreads>
10+
</PropertyGroup>
811
<ItemGroup>
912
<Compile Include="ArrayPool\ArrayPoolTest.cs" />
1013
<Compile Include="ArrayPool\CollectionTests.cs" />

src/libraries/System.Text.Json/tests/System.Text.Json.Tests/System.Text.Json.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<XunitShowProgress>true</XunitShowProgress>
2222
<!-- This WASM test is problematic and slow right now. This sets the xharness timeout but there is also override in sendtohelix-browser.targets -->
2323
<WasmXHarnessTestsTimeout>01:15:00</WasmXHarnessTestsTimeout>
24+
<WasmXHarnessMaxParallelThreads>1</WasmXHarnessMaxParallelThreads>
2425
</PropertyGroup>
2526
<ItemGroup Condition="'$(ContinuousIntegrationBuild)' == 'true'">
2627
<HighAotMemoryUsageAssembly Include="System.Text.Json.Tests.dll" />

0 commit comments

Comments
 (0)