Skip to content
Merged
Changes from 2 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
17 changes: 15 additions & 2 deletions TUnit.Engine/Services/TestExecution/TestCoordinator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,23 @@ public TestCoordinator(
_eventReceiverOrchestrator = eventReceiverOrchestrator;
}

public async ValueTask ExecuteTestAsync(AbstractExecutableTest test, CancellationToken cancellationToken)
public ValueTask ExecuteTestAsync(AbstractExecutableTest test, CancellationToken cancellationToken)
{
await _executionGuard.TryStartExecutionAsync(test.TestId,
var task = _executionGuard.TryStartExecutionAsync(test.TestId,
() => ExecuteTestInternalAsync(test, cancellationToken));

// Fast path: avoid async state machine when the task completed synchronously
if (task.IsCompletedSuccessfully)
{
return default;
}

return AwaitAndDiscard(task);

static async ValueTask AwaitAndDiscard(ValueTask<bool> t)
{
await t.ConfigureAwait(false);
}
}

private async ValueTask ExecuteTestInternalAsync(AbstractExecutableTest test, CancellationToken cancellationToken)
Expand Down
Loading