Skip to content

Commit

Permalink
Merge ExecuteTest back into ExecuteTestInternalAsync (#1237)
Browse files Browse the repository at this point in the history
  • Loading branch information
campersau authored Nov 17, 2024
1 parent d36e103 commit 6f84716
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 171 deletions.
16 changes: 3 additions & 13 deletions TUnit.Core/RunHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace TUnit.Core;

internal static class RunHelpers
{
internal static async Task RunWithTimeoutAsync(Func<CancellationToken, Task> taskDelegate, TimeSpan? timeout, CancellationToken token)
internal static async Task RunWithTimeoutAsync(Func<CancellationToken, Task> taskDelegate, TimeSpan timeout, CancellationToken token)
{
using var cancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(token);

Expand All @@ -23,20 +23,10 @@ internal static async Task RunWithTimeoutAsync(Func<CancellationToken, Task> tas
return;
}
if (timeout.HasValue)
{
taskCompletionSource.TrySetException(new TimeoutException(timeout.Value));
}
else
{
taskCompletionSource.TrySetCanceled(cancellationToken);
}
taskCompletionSource.TrySetException(new TimeoutException(timeout));
});

if (timeout != null)
{
cancellationTokenSource.CancelAfter(timeout.Value);
}
cancellationTokenSource.CancelAfter(timeout);

_ = taskDelegate(cancellationToken).ContinueWith(async t =>
{
Expand Down
3 changes: 1 addition & 2 deletions TUnit.Engine/Framework/TUnitServiceProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,14 @@ public TUnitServiceProvider(IExtension extension,

Disposer = Register(new Disposer(Logger));

var cancellationTokenSource = Register(EngineCancellationToken.CancellationTokenSource);
var testInvoker = Register(new TestInvoker(testHookOrchestrator, Disposer));
var explicitFilterService = Register(new ExplicitFilterService());
var parallelLimitProvider = Register(new ParallelLimitLockProvider());

// TODO
Register(new HookMessagePublisher(extension, messageBus));

var singleTestExecutor = Register(new SingleTestExecutor(extension, cancellationTokenSource, instanceTracker, testInvoker,
var singleTestExecutor = Register(new SingleTestExecutor(extension, instanceTracker, testInvoker,
explicitFilterService, parallelLimitProvider, AssemblyHookOrchestrator, classHookOrchestrator, TestFinder, TUnitMessageBus, Logger, EngineCancellationToken));

TestsExecutor = Register(new TestsExecutor(singleTestExecutor, Logger, CommandLineOptions, EngineCancellationToken));
Expand Down
Loading

0 comments on commit 6f84716

Please sign in to comment.