diff --git a/src/Microsoft.DotNet.XHarness.TestRunners.Xunit/ThreadlessXunitTestRunner.cs b/src/Microsoft.DotNet.XHarness.TestRunners.Xunit/ThreadlessXunitTestRunner.cs index 4e343c4ae..b1d5e317a 100644 --- a/src/Microsoft.DotNet.XHarness.TestRunners.Xunit/ThreadlessXunitTestRunner.cs +++ b/src/Microsoft.DotNet.XHarness.TestRunners.Xunit/ThreadlessXunitTestRunner.cs @@ -9,6 +9,7 @@ using System.Linq; using System.Reflection; using System.Threading; +using System.Threading.Tasks; using System.Xml.Linq; using Xunit; @@ -18,7 +19,7 @@ namespace Microsoft.DotNet.XHarness.TestRunners.Xunit { internal class ThreadlessXunitTestRunner { - public int Run(string assemblyFileName, bool printXml, XunitFilters filters) + public async Task Run(string assemblyFileName, bool printXml, XunitFilters filters) { var configuration = new TestAssemblyConfiguration() { ShadowCopy = false, ParallelizeAssembly = false, ParallelizeTestCollections = false, MaxParallelThreads = 1, PreEnumerateTheories = false }; var discoveryOptions = TestFrameworkOptions.ForDiscovery(configuration); @@ -57,20 +58,10 @@ public int Run(string assemblyFileName, bool printXml, XunitFilters filters) testSink.Execution.TestAssemblyFinishedEvent += args => { Console.WriteLine($"Finished: {assemblyFileName}"); }; controller.RunTests(testCasesToRun, resultsSink, testOptions); - var threadpoolPump = typeof(ThreadPool).GetMethod("PumpThreadPool", BindingFlags.NonPublic | BindingFlags.Static); - var timerPump = Type.GetType("System.Threading.TimerQueue")?.GetMethod("PumpTimerQueue", BindingFlags.NonPublic | BindingFlags.Static); - if (threadpoolPump != null && timerPump != null) + while (!resultsSink.Finished.WaitOne(0)) { - while (!resultsSink.Finished.WaitOne(0)) - { - threadpoolPump.Invoke(this, null); - timerPump.Invoke(this, null); - } - } - else - { - resultsSink.Finished.WaitOne(); + await Task.Delay(1); } if (printXml) diff --git a/src/Microsoft.DotNet.XHarness.TestRunners.Xunit/WasmApplicationEntryPoint.cs b/src/Microsoft.DotNet.XHarness.TestRunners.Xunit/WasmApplicationEntryPoint.cs index 43c845738..16da134bf 100644 --- a/src/Microsoft.DotNet.XHarness.TestRunners.Xunit/WasmApplicationEntryPoint.cs +++ b/src/Microsoft.DotNet.XHarness.TestRunners.Xunit/WasmApplicationEntryPoint.cs @@ -6,6 +6,7 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; using Xunit; namespace Microsoft.DotNet.XHarness.TestRunners.Xunit @@ -19,7 +20,7 @@ public abstract class WasmApplicationEntryPoint protected virtual IEnumerable IncludedMethods { get; set; } = Array.Empty(); protected virtual IEnumerable IncludedNamespaces { get; set; } = Array.Empty(); - public int Run() + public async Task Run() { var testRunner = new ThreadlessXunitTestRunner(); var filters = new XunitFilters(); @@ -30,7 +31,7 @@ public int Run() foreach (var cl in IncludedClasses) filters.IncludedClasses.Add(cl); foreach (var me in IncludedMethods) filters.IncludedMethods.Add(me); - var result = testRunner.Run(TestAssembly, printXml: true, filters); + var result = await testRunner.Run(TestAssembly, printXml: true, filters); return result; }