Skip to content
Merged
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
9 changes: 6 additions & 3 deletions tests/Wolfgang.TryPattern.Tests.Unit/RunAsyncActionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,17 @@ public async Task RunAsync_Action_CancellationToken_when_cancellation_is_request

void Action()
{
actionStarted.TrySetResult(true);

try
{
// Signal "started" only after a full pass of the loop body, so
// every line runs before the test can cancel. Signalling first
// let a fast runner cancel before the first delay, leaving that
// line uncovered on some runs (97.9% on macOS ARM64).
while (true)
{
cts.Token.ThrowIfCancellationRequested();
Task.Delay(10).Wait();
actionStarted.TrySetResult(true);
cts.Token.ThrowIfCancellationRequested();
}
}
catch (OperationCanceledException)
Expand Down
Loading