Repository navigation
test: add a concurrency stress suite - #376
Merged
Merged
Conversation
tests/Wolfgang.TryPattern.Tests.Concurrency (net10.0) runs concurrent callers through the real thread pool: - Run / RunAsync callers never see each other's value or error message, including async continuations that resume on another pool thread. - A cancellation racing RunAsync(Action)'s Task.Run, or RunAsync<T>'s token check, has exactly two legal outcomes: canceled and the delegate never ran, or the delegate ran once and the call succeeded. STRESS_ITERATIONS scales the rounds (default 100, so it runs in every PR at ~0.5 s). Both race outcomes are observed at the default. No failure-only branches, so the assembly is at 100% line coverage. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Sep 26, 2026
This was referenced Sep 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR is the Try-Pattern slice of #175: a new
tests/Wolfgang.TryPattern.Tests.Concurrencyproject (net10.0) that runs concurrent callers through the real thread pool.Run_Func_when_called_concurrently_each_caller_gets_its_own_valueTry.Run<T>callers each get their own valueRun_Action_when_failing_concurrently_each_caller_gets_its_own_messageErrorMessageRunAsync_Func_when_success_and_failure_interleave_outcomes_stay_with_their_callerTask.Yieldso continuations resume on other pool threadsRunAsync_Action_when_cancellation_races_scheduling_…Task.Runhas exactly two legal outcomes: canceled and the action never ran, or ran once and succeededRunAsync_Func_when_cancellation_races_the_token_check_…RunAsync<T>'sThrowIfCancellationRequested-then-invoke windowWhy not Coyote:
Tryis static andResultis immutable, so there is no shared state for a schedule explorer to find. This follows IAsyncEnumerable-Extensions' concurrency suite, which made the same call.STRESS_ITERATIONSscales the rounds. The default of 100 runs in every PR's Stage 1 in about 0.5 s. The weekly schedule comes in a separate PR, because workflow files are protected.Verification
dotnet build -c Release -p:TreatWarningsAsErrors=true: 0 errors.Task.Runin 19 of 100 rounds and beat the token check in 3 of 100.STRESS_ITERATIONS=5000: 5/5 passed in about 2 s. The cancel won in 2458 and 46 rounds respectively.coverlet.runsettings:Wolfgang.TryPattern.Tests.Concurrencyis at 100%. There are no failure-only branches; each test records its outcomes and asserts once.Refs #175
🤖 Generated with Claude Code