Skip to content

stty: run the tests that were ignored for lack of a tty - #14381

Open
harshasiddartha wants to merge 1 commit into
uutils:mainfrom
harshasiddartha:stty-run-ignored-tty-tests
Open

stty: run the tests that were ignored for lack of a tty#14381
harshasiddartha wants to merge 1 commit into
uutils:mainfrom
harshasiddartha:stty-run-ignored-tty-tests

Conversation

@harshasiddartha

Copy link
Copy Markdown
Contributor

Thirty-one tests in tests/by-util/test_stty.rs were marked #[ignore = "Fails because cargo test does not run in a tty"], so they never ran. They did not actually need the harness to be attached to a terminal: they either used stdin, or called terminal_simulation(true), which gives every new_ucmd!() invocation its own pty, so a setting applied by one invocation could never be seen by the --all read-back in the next one.

They now share a single pty via pty_path() and --file, the way the tests in the same file that already run do. A few assertions were written against output stty does not produce and are corrected: size prints <rows> <columns>, and settings that equal the sane defaults only show up under --all.

Running them uncovered a real bug. cs5/cs6/cs7 are declared as members of the CSIZE group, but the bit was OR'd into the control flags without clearing the group first, so stty cs7 on a terminal already set to cs8 exited 0 and left it at cs8. A flag's group is now cleared before the flag is set.

The read-back assertions compare whole whitespace-delimited tokens rather than substrings. stdout_contains("parenb") also matches -parenb, so those checks passed whether or not the setting had been applied; the same held for icanon and opost. Flipping a setting in one of the converted tests now fails it, where the substring form passed.

On macOS the file goes from 51 passing / 32 ignored to 81 passing / 2 ignored. speed is not implemented in this stty, so test_print_speed stays ignored, now with a reason that says so, and special_settings asserts the operand's current rejection so it is still covered.

Fixes #14370

Thirty-one tests in tests/by-util/test_stty.rs were marked
#[ignore = "Fails because cargo test does not run in a tty"], so
`cargo test` never executed them. They did not need a real terminal:
they either used stdin, or called `terminal_simulation(true)`, which
gives every invocation its own pty, so a setting applied by one
invocation could never be observed by the next one.

Point them at a single pty via `pty_path()` and `--file`, the way the
tests in the same file that already run do, and correct the assertions
that were written against output stty does not produce (`size` prints
"<rows> <columns>", and settings equal to the sane defaults only show
up under `--all`).

Running them uncovered that setting a character size did nothing:
`cs5`/`cs6`/`cs7` were OR'd into the control flags without clearing
CSIZE first, so `stty cs7` on a terminal already set to `cs8` left it
at `cs8`. Clear a flag's group before setting it.

`speed` is not implemented, so test_print_speed stays ignored, now
with a reason that says why.
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/cut/bounded-memory (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/misc/tty-eof (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/tail/truncate is no longer failing!

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.

tests: cargo test doesn't run stty tests

1 participant