Repository navigation
test(progress): inject TTY check so non-TTY assertion works under PTY sandboxes - #2616
Merged
Merged
Conversation
… sandboxes `Progress::start` reads the process-global stderr fd via `is_terminal()`, which returns true whenever the build environment hands the test process a PTY-backed stderr (e.g., the Nix build sandbox). The `test_start_in_non_tty_is_disabled` test asserted on that ambient behavior, so it failed in those environments. Extract the dispatch into `start_with(verb, is_tty)` and have `start` call it with `std::io::stderr().is_terminal()`. Tests now pass `is_tty` explicitly and exercise both branches without depending on the environment. Closes #2615 Co-Authored-By: Claude <[email protected]>
Merged
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.
Problem
progress::imp::tests::test_start_in_non_tty_is_disabledfailed when the build environment hands the test process a PTY-backed stderr (e.g., the Nix build sandbox packaging worktrunk for nixpkgs).Progress::startreadsstd::io::stderr().is_terminal()directly on the process-global fd, so the assertionProgress::start("Copying").0.is_none()only held when the test runner happened to give us a non-TTY stderr — true undercargo test/nexteston dev machines and CI, but not under sandboxes that allocate a PTY to capture coloured output.Solution
Extract dispatch into a private
start_with(verb, is_tty)helper.startcalls it withstd::io::stderr().is_terminal()(no behavior change for non-test callers). Tests now passis_ttyexplicitly and exercise both branches independently of the ambient stderr fd:test_start_with_non_tty_is_disabled— was the old test, now hard-codesis_tty: false.test_start_with_tty_is_enabled— new, hard-codesis_tty: trueand confirms the enabled reporter is returned, finishing it cleanly to avoid leaking the ticker thread.Testing
cargo test --lib progress::passes (15/15) on Linux.cargo clippy --lib --bins -- -D warningsclean.cargo fmt --checkclean.Closes #2615 — automated triage