Skip to content

Show ansi colors in azdo and gh actions CI #49014

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nohwnd
Copy link
Member

@nohwnd nohwnd commented May 16, 2025

Port of this for new dotnet test experience with MTP microsoft/testfx#5535

Related to #45927

@nohwnd nohwnd marked this pull request as ready for review May 16, 2025 15:09
@Copilot Copilot AI review requested due to automatic review settings May 16, 2025 15:09
Copy link
Contributor

@Copilot 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

Adds CI-friendly ANSI rendering and dark color variants for test output in Azure DevOps and GitHub Actions.

  • Introduce UseCIAnsi flag and simple CI detection to select a CI-compatible ANSI terminal.
  • Implement SimpleTerminalBase and SimpleAnsiTerminal for streamlined ANSI output in CI.
  • Change default terminal colors to darker variants and refactor NonAnsiTerminal to remove duplication.

Reviewed Changes

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

Show a summary per file
File Description
src/Cli/dotnet/Commands/Test/TestingPlatformCommand.cs Add CI detection and pass UseCIAnsi into reporter options
src/Cli/dotnet/Commands/Test/Terminal/TerminalTestReporterOptions.cs Define new UseCIAnsi property
src/Cli/dotnet/Commands/Test/Terminal/TerminalTestReporter.cs Switch to SimpleAnsiTerminal in CI and update default colors
src/Cli/dotnet/Commands/Test/Terminal/SimpleTerminalBase.cs New base class consolidating terminal behaviors
src/Cli/dotnet/Commands/Test/Terminal/SimpleAnsiTerminal.cs Implement simplified ANSI terminal for CI
src/Cli/dotnet/Commands/Test/Terminal/NonAnsiTerminal.cs Refactor to inherit from SimpleTerminal and remove custom batching/progress logic
src/Cli/dotnet/Commands/Test/Terminal/AnsiTerminalTestProgressFrame.cs Update progress frame colors to dark variants
Comments suppressed due to low confidence (3)

src/Cli/dotnet/Commands/Test/TestingPlatformCommand.cs:143

  • CI ANSI output is enabled even when the user requests no ANSI (--no-ansi) because UseCIAnsi is checked without verifying UseAnsi. Change this to if (_options.UseAnsi && _options.UseCIAnsi) so that CI ANSI mode respects the --no-ansi flag.
if (_options.UseCIAnsi)

src/Cli/dotnet/Commands/Test/TestingPlatformCommand.cs:131

  • No tests cover the new CI environment detection or the UseCIAnsi flag. Consider adding unit tests that set TF_BUILD and GITHUB_ACTIONS environment variables to validate that inCI and UseCIAnsi behave as expected.
// TODO: Replace this with proper CI detection that we already have in telemetry. https://github.com/microsoft/testfx/issues/5533#issuecomment-2838893327

src/Cli/dotnet/Commands/Test/Terminal/SimpleTerminalBase.cs:56

  • The new RenderProgress implementation in SimpleTerminalBase dropped the /r indicator for retried failed tests that existed in the original NonAnsiTerminal. This regression means retried counts won’t be shown. Restore the retried-test logic or extend RenderProgress to include p.RetriedFailedTests when > 0.
public void RenderProgress(TestProgressState?[] progress)

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.

1 participant