Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Linq;

using Xunit;
Expand All @@ -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<int> 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);
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Xunit;

namespace Microsoft.DotNet.XHarness.TestRunners.Xunit
Expand All @@ -19,7 +20,7 @@ public abstract class WasmApplicationEntryPoint
protected virtual IEnumerable<string> IncludedMethods { get; set; } = Array.Empty<string>();
protected virtual IEnumerable<string> IncludedNamespaces { get; set; } = Array.Empty<string>();

public int Run()
public async Task<int> Run()
{
var testRunner = new ThreadlessXunitTestRunner();
var filters = new XunitFilters();
Expand All @@ -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;
}
Expand Down