Skip to content

[release/11.0.1xx-preview7] Implement global command-line options for dotnet test (MTP): --timeout and --maximum-failed-tests (#55458) - #55476

Merged
Evangelink merged 1 commit into
dotnet:release/11.0.1xx-preview7from
Evangelink:backport/pr-55458-to-release/11.0.1xx-preview7
Jul 27, 2026
Merged

Evangelink merged 1 commit into
dotnet:release/11.0.1xx-preview7from
Evangelink:backport/pr-55458-to-release/11.0.1xx-preview7

Conversation

@Evangelink

Copy link
Copy Markdown
Member

Backport of #55458 to release/11.0.1xx-preview7.

/cc @Evangelink

Customer Impact

Brings the new global dotnet test (Microsoft.Testing.Platform) command-line options to the preview7 release:

  • --timeout <DURATION> — global test-execution timeout (measured across all test applications; returns TestSessionAborted / exit code 3 on timeout).
  • --maximum-failed-tests <NUMBER> — stops the run once the given number of failures is reached across all test applications (independent of retry bookkeeping).

Both apply globally when placed before --, and can be passed after -- to apply per test application. Implemented via an SDK server-side reverse control pipe that advertises ServerControlPipeName and sends CancelSession to TestFx.

Notes on this manual backport

The automated /backport bot failed because its per-commit git am tried to re-apply the branch's DangerousFileDetector race fix, which already exists on release/11.0.1xx-preview7 (both branches fixed the same race). Re-created manually via git cherry-pick -m 1 of the merge commit (net-diff 3-way merge), which resolved that overlap cleanly — no code conflicts. The result is the same 35-file feature change, with DangerousFileDetector.cs producing no net change on this branch (already present).

Resolves the backport request on #55458. Original issue: #49709.

Copilot AI review requested due to automatic review settings July 27, 2026 12:29
@Evangelink
Evangelink requested review from a team as code owners July 27, 2026 12:29
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
2 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Backports the dotnet test (Microsoft.Testing.Platform) global run-level options --timeout and --maximum-failed-tests into release/11.0.1xx-preview7, including the server-initiated cancellation mechanism via a reverse “server control” pipe.

Changes:

  • Adds new global options (--timeout <DURATION>, --maximum-failed-tests <NUMBER>) with parsing/validation and updated help/localization.
  • Introduces a run-level coordinator (TestRunPolicy) and wires it through MTP execution to trigger cooperative cancellation (with kill fallback).
  • Adds unit + end-to-end tests and updates exit code constants/snapshots.
Show a summary per file
File Description
test/Microsoft.NET.TestFramework/Constants.cs Adds test-framework exit codes for session aborted and max-failed-tests policy.
test/dotnet.Tests/CommandTests/Test/TestRunPolicyTests.cs New unit tests for run-level timeout and max-failures policy behavior (incl. concurrency regression).
test/dotnet.Tests/CommandTests/Test/TestCommandParserTests.cs Parser tests for new global options and forwarding semantics around --.
test/dotnet.Tests/CommandTests/Test/snapshots/MTPHelpSnapshotTests.VerifyMTPHelpOutput.verified.txt Updates MTP help snapshot to include new options and updated minimum-expected-tests wording.
test/dotnet.Tests/CommandTests/Test/ServerControlMessageSerializerTests.cs Serializer contract tests for new reverse control messages and serializer IDs.
test/dotnet.Tests/CommandTests/Test/GivenDotnetTestBuildsAndRunsTests.cs End-to-end tests asserting policy exit codes for max-failed-tests and global timeout.
src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.zh-Hant.xlf Localization updates for new/updated option strings (zh-Hant).
src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.zh-Hans.xlf Localization updates for new/updated option strings (zh-Hans).
src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.tr.xlf Localization updates for new/updated option strings (tr).
src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.ru.xlf Localization updates for new/updated option strings (ru).
src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.pt-BR.xlf Localization updates for new/updated option strings (pt-BR).
src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.pl.xlf Localization updates for new/updated option strings (pl).
src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.ko.xlf Localization updates for new/updated option strings (ko).
src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.ja.xlf Localization updates for new/updated option strings (ja).
src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.it.xlf Localization updates for new/updated option strings (it).
src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.fr.xlf Localization updates for new/updated option strings (fr).
src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.es.xlf Localization updates for new/updated option strings (es).
src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.de.xlf Localization updates for new/updated option strings (de).
src/Cli/Microsoft.DotNet.Cli.Definitions/xlf/CommandDefinitionStrings.cs.xlf Localization updates for new/updated option strings (cs).
src/Cli/Microsoft.DotNet.Cli.Definitions/Commands/Test/TestCommandDefinition.MicrosoftTestingPlatform.cs Defines new options, validators, and timeout parsing for MTP dotnet test.
src/Cli/Microsoft.DotNet.Cli.Definitions/CommandDefinitionStrings.resx Adds/updates option descriptions and validation error strings.
src/Cli/dotnet/Commands/Test/MTP/TestRunPolicy.cs New run-level policy state machine for timeout/max-failures cancellation.
src/Cli/dotnet/Commands/Test/MTP/TestApplicationHandler.cs Reports failed test counts into the run policy.
src/Cli/dotnet/Commands/Test/MTP/TestApplicationActionQueue.cs Stops scheduling and reading work when run-level cancellation triggers.
src/Cli/dotnet/Commands/Test/MTP/TestApplication.cs Implements reverse control pipe + cooperative cancellation request + kill fallback.
src/Cli/dotnet/Commands/Test/MTP/Terminal/TerminalTestReporter.cs Makes cancellation flag thread-safe and adds a policy-driven cancellation marker.
src/Cli/dotnet/Commands/Test/MTP/MicrosoftTestingPlatformTestCommand.cs Instantiates policy from parsed options and maps cancellation reason to exit codes.
src/Cli/dotnet/Commands/Test/MTP/IPC/Serializers/WaitForServerControlRequestSerializer.cs Serializer for reverse-pipe “wait for control message” request.
src/Cli/dotnet/Commands/Test/MTP/IPC/Serializers/ServerControlMessageSerializer.cs Serializer for server-initiated control messages (CancelSession).
src/Cli/dotnet/Commands/Test/MTP/IPC/Serializers/RegisterSerializers.cs Registers new serializers (IDs 13/14).
src/Cli/dotnet/Commands/Test/MTP/IPC/ObjectFieldIds.cs Adds field/serializer ID constants for reverse control messages.
src/Cli/dotnet/Commands/Test/MTP/IPC/Models/WaitForServerControlRequest.cs Model for reverse-pipe control request.
src/Cli/dotnet/Commands/Test/MTP/IPC/Models/ServerControlMessage.cs Model for reverse-pipe control response/message.
src/Cli/dotnet/Commands/Test/MTP/ExitCode.cs Adds exit code constant for “stopped for max failed tests”.
src/Cli/dotnet/Commands/Test/CliConstants.cs Adds handshake property name for reverse control pipe and server-control kind constant.

Copilot's findings

  • Files reviewed: 35/35 changed files
  • Comments generated: 2

Comment on lines 119 to 122
// 1.2.0 adds AzureDevOpsLogMessage (serializer id 11) forwarding; 1.3.0 adds DisplayMessage (serializer id 12) forwarding.
// NOTE: 1.4.0 (the reverse server-control pipe / server-initiated cancellation) is intentionally NOT advertised yet:
// it is a separate, larger feature that is out of scope here.
internal const string SupportedVersions = "1.0.0;1.1.0;1.2.0;1.3.0";

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This backport is a faithful copy of the merged main change (#55458, merge commit 78b84df) — this file is byte-identical to main. The behavior is intentional: the SDK advertises the reverse control pipe via the ServerControlPipeName handshake property rather than by bumping SupportedVersions to 1.4.0, so the comment about 1.4.0 being "out of scope" refers to advertising a new negotiated protocol version, not to the pipe capability itself. Since this matches merged main, any refinement here (clarifying the comment) should be made on main first and flow to the release to avoid divergence.

Comment on lines +619 to +622
if (version.Length > 0)
{
properties.Add(HandshakeMessagePropertyNames.ServerControlPipeName, _controlPipeName);
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as the sibling thread: this is byte-identical to merged main (#55458) and is intentional — ServerControlPipeName is advertised as a handshake property independent of the negotiated protocol version. This applies equally to main; if we want to gate it on >= 1.4.0, that change belongs on main first so the backport stays a faithful copy. Not changing it only on this backport.

@Evangelink
Evangelink enabled auto-merge July 27, 2026 12:38
@Evangelink
Evangelink merged commit 07b7584 into dotnet:release/11.0.1xx-preview7 Jul 27, 2026
28 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview7 milestone Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants