Skip to content

test(progress): inject TTY check so non-TTY assertion works under PTY sandboxes - #2616

Merged
max-sixty merged 1 commit into
mainfrom
fix/issue-2615
May 5, 2026
Merged

max-sixty merged 1 commit into
mainfrom
fix/issue-2615

Conversation

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

Problem

progress::imp::tests::test_start_in_non_tty_is_disabled failed when the build environment hands the test process a PTY-backed stderr (e.g., the Nix build sandbox packaging worktrunk for nixpkgs). Progress::start reads std::io::stderr().is_terminal() directly on the process-global fd, so the assertion Progress::start("Copying").0.is_none() only held when the test runner happened to give us a non-TTY stderr — true under cargo test / nextest on 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. start calls it with std::io::stderr().is_terminal() (no behavior change for non-test callers). Tests now pass is_tty explicitly and exercise both branches independently of the ambient stderr fd:

  • test_start_with_non_tty_is_disabled — was the old test, now hard-codes is_tty: false.
  • test_start_with_tty_is_enabled — new, hard-codes is_tty: true and 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 warnings clean.
  • cargo fmt --check clean.

Closes #2615 — automated triage

… 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]>
@max-sixty
max-sixty merged commit 9fe3b6d into main May 5, 2026
25 checks passed
@max-sixty
max-sixty deleted the fix/issue-2615 branch May 5, 2026 05:58
@worktrunk-bot worktrunk-bot mentioned this pull request May 16, 2026
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.

test_start_in_non_tty_is_disabled fails in PTY sandbox environments (e.g. Nix build)

2 participants