Skip to content

MTP: ensure post-session display runs after cancellation - #7410

Merged
Amaury Levé (Evangelink) merged 2 commits into
mainfrom
dev/amauryleve/testhost
Feb 16, 2026
Merged

Amaury Levé (Evangelink) merged 2 commits into
mainfrom
dev/amauryleve/testhost

Conversation

@Evangelink

Copy link
Copy Markdown
Member

Summary
Fixes an inconsistency in cancellation flow for MTP test sessions.

CommonHost.ExecuteRequestAsync intentionally calls post-session display outside the cancellation catch, but DisplayAfterSessionEndRunAsync was still receiving the canceled session token.

This change passes CancellationToken.None to ensure final output/session-finishing notifications are not skipped when cancellation is requested.

Changes
Updated CommonTestHost.cs:195 to call post-session display with a non-cancelable token.

Added regression test CommonHostTests.cs verifying canceled sessions still invoke post-session display with a non-cancelable token.

Validation
Ran: dotnet test Microsoft.Testing.Platform.UnitTests.csproj --filter "FullyQualifiedName~CommonHostTests.ExecuteRequestAsync_WhenSessionIsCancelled_UsesCancellationTokenNoneForDisplayAfterSessionEndRun"

Result: pass.

Issue
Closes #6099

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM 🎉

I only reviewed the product change. Please ensure that the added test would have been failing on current main.

@Evangelink

Copy link
Copy Markdown
Member Author

Youssef Fahmy (@Youssef1313) the test fails with

failed ExecuteRequestAsync_WhenSessionIsCancelled_UsesCancellationTokenNoneForDisplayAfterSessionEndRun (151ms)
  Assert.IsFalse failed. 'condition' expression: 'displayAfterToken!.Value.CanBeCanceled'.

I don't know if we want something more strict

@Youssef1313

Youssef Fahmy (Youssef1313) commented Feb 16, 2026 •

Copy link
Copy Markdown
Member

That's good enough, I think. At least for what we have today.

@Evangelink
Amaury Levé (Evangelink) merged commit a061188 into main Feb 16, 2026
10 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the dev/amauryleve/testhost branch February 16, 2026 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Suspicious cancellation logic in MTP

2 participants