Compare only settable tty status flags in restore tests
Root cause
On macOS, term::session::tests::delayed_old_state_drop_preserves_reopened_pty (and the equivalent check in tests/terminal.rs) compared the whole F_GETFL word. Darwin sets 0x10000 in that word as soon as any descriptor sharing the open file description writes. That bit is xnu's FWASWRITTEN fileglob bookkeeping, not O_EVTONLY (which is 0x8000 in sys/fcntl.h). The probe writes through the tty, so the bit appears. Nothing can clear it: a C check on ivar showed before=0x2 after_write=0x10002 after_setfl_orig=0x10002. The restore itself is correct.
Fix
- The tests now compare only the F_SETFL-controlled status bits that
RawTtysaves and restores: APPEND, NONBLOCK, ASYNC and SYNC. - The tests also assert that the mask keeps NONBLOCK, so a missed restore still fails.
- No production code changed.
Validation
| Platform | Tests | Result |
|---|---|---|
| macOS (ivar) | harness-tui lib | 14/14 in 0.03 s, including the previously failing test |
| macOS (ivar) | tests/terminal.rs | 14/14 in 0.60 s |
| Linux (bb1) | harness-tui lib | 14/14 in 0.05 s |
| Linux (bb1) | tests/terminal.rs | 14/14 in 0.16 s |
Negative control: on origin/main, the whole-word comparison fails on macOS with NONBLOCK | RDWR | 0x10000.
Decisions
I kept the restore code unchanged and compared only the settable flags in the tests. Fixing the restore isn't possible, because the extra bit can't be cleared through F_SETFL.
🤖 Generated with Claude Code
Summary by cubic
Fixes the tty restore tests on macOS so they no longer fail after the probe writes.
The tests compared the whole F_GETFL word, but Darwin sets FWASWRITTEN (0x10000) once any descriptor writes to the same open file description, and no process can clear it. The tests now compare only the F_SETFL-controlled bits (APPEND, NONBLOCK, ASYNC, SYNC) that RawTty saves and restores, and assert that mask includes NONBLOCK so a missed restore is still caught. No production code changed.