Skip to content

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

Merged
Evangelink merged 2 commits intomainfrom
dev/amauryleve/testhost
Feb 16, 2026
Merged

MTP: ensure post-session display runs after cancellation#7410
Evangelink merged 2 commits intomainfrom
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

@Youssef1313 Youssef1313 left a comment

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

@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
Copy link
Copy Markdown
Member

Youssef1313 commented Feb 16, 2026

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

@Evangelink Evangelink merged commit a061188 into main Feb 16, 2026
10 checks passed
@Evangelink 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