Skip to content

Fix scan tty test under an ambient LC_ALL (#2216) - #2217

Merged
Mikola Lysenko (mikolalysenko) merged 2 commits into
mainfrom
agent/fix-scan-tty-test-ambient-locale
Nov 24, 2026
Merged

Mikola Lysenko (mikolalysenko) merged 2 commits into
mainfrom
agent/fix-scan-tty-test-ambient-locale

Conversation

@mikolalysenko

@mikolalysenko Mikola Lysenko (mikolalysenko) commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

LLM Description written by Claude Code:claude-fable-5-2

Fixes #2216

Summary

A test-only change, seven lines in crates/socket-patch-cli/tests/scan/scan_tty.rs.
scan_on_a_terminal_shows_what_was_measured now removes LC_ALL and
LC_CTYPE from its PTY child before it sets LANG, so the locale under
test is the one the CLI reads. The CLI is unchanged.

Root cause

The test names the locale of its PTY child with LANG alone. The CLI
(glyphs_enabled in src/ui/mod.rs) reads the first set of LC_ALL,
LC_CTYPE, LANG, as POSIX orders them, and the PTY child inherits
the runner's environment. A runner that exports a UTF-8 LC_ALL, as the
macOS one evidently does, outranks the test's LANG=C, so the row is
drawn with glyphs and the ASCII assertion fails. The CLI is right; the
test's environment was incomplete. Linux legs passed only because their
runner sets no outranking variable.

Evidence

Reproduced on Linux by giving the test run the ambient variable:

ambient environment main this branch
LC_ALL=en_US.UTF-8 fails, same screen as the issue passes
LC_CTYPE=en_US.UTF-8 (same cause) passes
LC_ALL=C LANG=en_US.UTF-8 (the UTF-8 case would fail) passes
none passes passes

Command: <env> cargo test -p socket-patch-cli --test scan scan_on_a_terminal_shows_what_was_measured.

  • All six scan_tty tests pass under LC_ALL=en_US.UTF-8.
  • cargo clippy --locked --workspace --all-features -- -D warnings (CI's
    command) is clean, and rustfmt --check on the file is clean.
  • /code-review high on the diff: no findings. It also ran the other PTY
    tests (the cli, rollback, remove, update and scan binaries)
    under LC_ALL=C and LC_ALL=en_US.UTF-8; all pass, so no other test
    needs the same pin today.

The macOS leg itself doesn't run on a PR push; it runs in the merge queue
and the nightly, which is where this is confirmed for real.

  • CI on this head: ci-ok and clippy are green, with no failed check.

Notes

  • I kept the change in the one test that names a locale, not in the
    shared pty_command helper: clearing the locale for every PTY child
    would also change what package managers spawned under a PTY see.
  • Not part of this PR: cargo clippy -p socket-patch-cli --all-targets --all-features -- -D warnings fails on main with 29 errors in test
    targets (mostly duplicate_mod). CI doesn't lint test targets, and
    none of the errors is in the file changed here.

https://claude.ai/code/session_011f9aeP4nq5sLGtm5TnGDd9


Generated by Claude Code

The test names its locale with LANG alone, so a runner's own LC_ALL
outranks it. Fix follows.

Assisted-by: Claude Code:claude-fable-5-2
The test named its PTY child's locale with LANG alone. The CLI reads
the first set of LC_ALL, LC_CTYPE and LANG, and the child inherits the
runner's environment, so a runner that exports a UTF-8 LC_ALL (the
macOS ones do) outranked the test's LANG=C and the row was drawn with
glyphs. Remove the two outranking variables from the child, so LANG
decides.

Before, LC_ALL=en_US.UTF-8 cargo test ... --test scan
scan_on_a_terminal_shows_what_was_measured failed on Linux as it does
on the macOS nightly; now it passes under any ambient locale.

Fixes #2216

Assisted-by: Claude Code:claude-fable-5-2
@mikolalysenko
Mikola Lysenko (mikolalysenko) marked this pull request as ready for review November 24, 2026 09:32
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

bugbot run


Generated by Claude Code

@cursor

cursor Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Test-only change to environment setup in one scan TTY test; no production code paths affected.

Overview
The PTY integration test scan_on_a_terminal_shows_what_was_measured now strips LC_ALL and LC_CTYPE from the child process before setting LANG, so the locale loop (en_US.UTF-8 vs C) actually controls whether check-mark glyphs appear on screen.

Previously the child inherited a runner-wide LC_ALL (notably on macOS), which outranked the test’s LANG=C and broke ASCII assertions—CLI behavior is unchanged; only this test’s environment is made explicit.

Reviewed by Cursor Bugbot for commit c9b3064. Configure here.

@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

[agent] PR shepherd: review brief for the approver

What it does: Fixes the nightly macOS failure in #2216. The PTY test scan_on_a_terminal_shows_what_was_measured set only LANG for its child, so a runner's own LC_ALL/LC_CTYPE (which the CLI reads first) outranked LANG=C and the ASCII assertion failed. The test now removes those two variables from the child before setting LANG. Test-only; the CLI is unchanged.

Risk: low. One test in one file; no production code, no other test touched.

Look here:

Verified:

  • With LC_ALL=en_US.UTF-8 in the environment, main's version of the test fails at scan_tty.rs:360, the same line as the nightly macOS job on main (run 45335138704); with this PR all six scan_tty tests pass.
  • ci-ok and clippy green on c9b3064; no failed check; no review threads open. CHANGELOG.md untouched.
  • The macOS leg only runs in the merge queue and nightly, so that is where the fix is confirmed on a real macOS runner.

Changes I made: none.

Open questions: none.


Generated by Claude Code

@mikolalysenko Mikola Lysenko (mikolalysenko) added the Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review label Nov 24, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[agent] Reviewed the PTY child setup against the CLI's locale lookup order. Clearing LC_ALL and LC_CTYPE makes the test's explicit LANG control both cases. The ci-ok checks passed on this commit.

Merged via the queue into main with commit 54e3792 Nov 24, 2026
82 of 83 checks passed
@mikolalysenko
Mikola Lysenko (mikolalysenko) deleted the agent/fix-scan-tty-test-ambient-locale branch November 24, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nightly: scan_on_a_terminal_shows_what_was_measured fails on macOS (C locale renders glyphs)

3 participants