Strip --minimum-expected-tests on retry attempts in RetryOrchestrator#8719
Merged
Merged
Conversation
The retry orchestrator re-runs only the previously failed tests on retry attempts. When --minimum-expected-tests was specified, the threshold computed against the full test set was inherited by the retry attempt and tripped the policy (exit code 9, MinimumExpectedTestsPolicyViolation), even when the original first attempt satisfied it. Drop --minimum-expected-tests from the per-iteration argument list whenever we are about to issue a retry attempt (i.e. lastListOfFailedId is non-empty). The first attempt still honors the option because it runs the full set. Fixes #5639. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a bug where combining --minimum-expected-tests with --retry-failed-tests would cause retry attempts to fail with MinimumExpectedTestsPolicyViolation (exit code 9), since retries only re-run the failed subset and would never meet the original threshold.
Changes:
- Strip
--minimum-expected-testsfrom per-iteration arguments inRetryOrchestratorwhen launching retry attempts. - Add an acceptance test verifying the scenario across all target frameworks.
Show a summary per file
| File | Description |
|---|---|
| src/Platform/Microsoft.Testing.Extensions.Retry/RetryOrchestrator.cs | Adds RemoveOption call for MinimumExpectedTestsOptionKey in the retry-attempt branch. |
| test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/RetryFailedTestsTests.cs | New acceptance test RetryFailedTests_WithMinimumExpectedTests_StripsThresholdOnRetry. |
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 0
Evangelink
commented
May 31, 2026
Member
Author
Evangelink
left a comment
There was a problem hiding this comment.
✅ 21/21 dimensions clean — no findings.
Summary
The fix is minimal, correctly scoped, and addresses the root cause:
RemoveOption(finalArguments, PlatformCommandLineProvider.MinimumExpectedTestsOptionKey)is placed inside theif (lastListOfFailedId is { Length: > 0 })guard, so the first attempt retains the threshold while every retry attempt—which re-runs only the previously failed subset—has it stripped. That's exactly the right boundary.- The acceptance test
RetryFailedTests_WithMinimumExpectedTests_StripsThresholdOnRetryfollows existing conventions (DynamicData overTargetFrameworks.AllForDynamicData,Guid.NewGuid()result directory, env-var-driven asset behavior) and verifies both the happy-path exit code and the absence of the violation message. - No public API surface was changed; no IPC wire format was altered; no new allocations on hot paths; threading model is unaffected.
Generated by Expert Code Review (on open) for issue #8719 · sonnet46 1.6M
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.
Fixes #5639.
When
--minimum-expected-testswas combined with--retry-failed-tests, the retry attempt (which only re-runs the previously failed tests) inherited the threshold computed against the full first-attempt test set. The retry's much smaller test count then tripped the policy and the run exited with code 9 (MinimumExpectedTestsPolicyViolation), even when the original first attempt satisfied the threshold.This change makes
RetryOrchestratorstrip--minimum-expected-testsfrom the per-iteration argument list before launching any retry attempt (i.e. whenlastListOfFailedIdis non-empty). The first attempt still honors the option because it runs the full set of tests.Adds an acceptance test
RetryFailedTests_WithMinimumExpectedTests_StripsThresholdOnRetrythat exercises the scenario from the issue across all target frameworks and asserts the run completes successfully without the policy violation message.