Skip to content

Commit

Permalink
WASM: Pump the threadpool while running tests so async Tasks work
Browse files Browse the repository at this point in the history
  • Loading branch information
akoeplinger committed Jul 2, 2020
1 parent a24a436 commit d20f126
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Xml.Linq;

using Xunit;
Expand Down Expand Up @@ -52,7 +53,19 @@ public int Run(string assemblyFileName, bool printXml, XunitFilters filters)
testSink.Execution.TestAssemblyFinishedEvent += args => { Console.WriteLine($"Finished {args.Message.TestAssembly.Assembly}{Environment.NewLine}"); };

controller.RunTests(testCasesToRun, resultsSink, testOptions);
resultsSink.Finished.WaitOne();
var threadpoolPump = typeof(ThreadPool).GetMethod("PumpThreadPool", BindingFlags.NonPublic | BindingFlags.Static);

if (threadpoolPump != null)
{
while (!resultsSink.Finished.WaitOne(0))
{
threadpoolPump.Invoke(this, null);
}
}
else
{
resultsSink.Finished.WaitOne();
}

if (printXml)
{
Expand Down

0 comments on commit d20f126

Please sign in to comment.