Force rich non-terminal output in tests - #4081
Open
r4victor wants to merge 1 commit into
Open
Conversation
Coding agents run with FORCE_COLOR set, which makes rich colorize even when stdout is a pipe, so CLI tests asserting on plain text failed for agents while passing locally and in CI. DSTACK_CLI_RICH_FORCE_TERMINAL could not prevent it because rich_argparse builds its own console for --help that dstack never constructs. TTY_COMPATIBLE=0 covers every rich console in the process and takes precedence over FORCE_COLOR, which makes the dstack-specific setting redundant.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes CLI tests failing for coding agents (and confusing them), which may run with
FORCE_COLOR=3set. rich then colorizes even though stdout is a pipe, so assertions on plain CLI text see ANSI escapes. The same tests pass in a normal terminal and in CI, whereFORCE_COLORis unset.Two tests were affected, both asserting on
"Usage: dstack":TestDstack::test_prints_help_and_exists_with_0_exit_codeTestAgentIsolation::test_creates_private_cli_home_and_dstack_wrapperDSTACK_CLI_RICH_FORCE_TERMINAL=0could not prevent this: it only reaches the consoles dstack constructs, and--helpis rendered by a consolerich_argparsecreates internally.TTY_COMPATIBLE=0applies to every rich console in the process and is checked ahead ofFORCE_COLOR, so it also covers dstack's own consoles. That makesDSTACK_CLI_RICH_FORCE_TERMINALredundant, so it is removed - it was only ever added to keep control characters out of test output (0256b62) and is undocumented.Verified: full suite green with
FORCE_COLOR=3still set (3271 passed, 1735 skipped); previously 2 failed in the same environment.AI assistance: written with Claude Code.