test(tui): gate ANSI-byte recover_terminal_modes asserts to non-windows

Crossterm routes the same logical commands through the WinAPI console
backend on Windows, so EnableFocusChange / Push keyboard flags /
EnableMouseCapture / EnableBracketedPaste never reach the writer as
ANSI bytes there. Gate the byte-level test with cfg(not(windows)) and
add a windows-only smoke test that just exercises the function for
panic-freedom.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Hunter Bown
2026-05-09 14:43:58 -05:00
parent 8bf7bf8ba6
commit 25f070919c
+13
View File
@@ -36,6 +36,11 @@ fn focus_gained_forces_terminal_viewport_recapture() {
assert!(!terminal_event_needs_viewport_recapture(&Event::FocusLost));
}
// ANSI byte sequences are only written on platforms where crossterm uses the
// ANSI execution path. On Windows the same logical commands route through the
// WinAPI console backend and never reach the writer, so byte-level assertions
// here only make sense on non-Windows targets.
#[cfg(not(windows))]
#[test]
fn recover_terminal_modes_emits_expected_csi_sequences_with_gating() {
let mut all_on: Vec<u8> = Vec::new();
@@ -73,6 +78,14 @@ fn recover_terminal_modes_emits_expected_csi_sequences_with_gating() {
);
}
#[cfg(windows)]
#[test]
fn recover_terminal_modes_runs_without_panic_on_windows() {
let mut buf: Vec<u8> = Vec::new();
recover_terminal_modes(&mut buf, true, true);
recover_terminal_modes(&mut buf, false, false);
}
#[test]
fn terminal_origin_reset_resets_scroll_region_origin_and_clears() {
assert!(