Skip to content

Simplify TerminalOutputDevice#7533

Merged
Youssef1313 merged 1 commit intomainfrom
dev/ygerges/simplify-terminaloutputdevice
Mar 12, 2026
Merged

Simplify TerminalOutputDevice#7533
Youssef1313 merged 1 commit intomainfrom
dev/ygerges/simplify-terminaloutputdevice

Conversation

@Youssef1313
Copy link
Member

@Youssef1313 Youssef1313 commented Mar 12, 2026

The _firstCallTo_OnSessionStartingAsync field is not very trivial to understand at a first glance. So refactoring this out. How it used to work is:

  • It defaults to true.
  • It's set to false in OnTestSessionStartingAsync (this called ONLY in the testhost).
  • End result is
    • in testhost: the value of this field is false
    • in testhost controller: the value of this field is true.
    • So the variable is semantically "is out of process"

Now that we have already HandleProcessRole, I'm using that to directly store the role of the current process.

This also means we no longer need any logic in OnTestSessionStartingAsync and we don't need to implement ITestSessionLifetimeHandler.

Copilot AI review requested due to automatic review settings March 12, 2026 13:09
@Youssef1313 Youssef1313 force-pushed the dev/ygerges/simplify-terminaloutputdevice branch from 5eb4a9c to e66796d Compare March 12, 2026 13:11
@Youssef1313 Youssef1313 enabled auto-merge (squash) March 12, 2026 13:12
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the platform’s terminal output device to rely on the test process role (TestHost/Controller/Orchestrator) rather than ITestSessionLifetimeHandler callbacks for certain behaviors, and updates the Playground sample to always enable TRX reporting.

Changes:

  • Remove ITestSessionLifetimeHandler implementation from TerminalOutputDevice and switch logic to use TestProcessRole.
  • Track process role via HandleProcessRoleAsync and use it to decide when to complete the run and how to classify artifacts as out-of-process.
  • Enable TRX reporting by default in the Playground sample and add the required project reference.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/Platform/Microsoft.Testing.Platform/OutputDevice/TerminalOutputDevice.cs Replace session-lifetime-handler-based state with role-based state for end-of-run and artifact classification.
samples/Playground/Program.cs Enable TRX provider in the sample by default.
samples/Playground/Playground.csproj Add TRX report extension project reference needed by the sample.

You can also share your feedback on Copilot code review. Take the survey.

@Youssef1313 Youssef1313 merged commit 82611a6 into main Mar 12, 2026
10 checks passed
@Youssef1313 Youssef1313 deleted the dev/ygerges/simplify-terminaloutputdevice branch March 12, 2026 14:02
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.

3 participants