From dc863e110f2a26fd0da45991d3ed10161b69c549 Mon Sep 17 00:00:00 2001 From: Jake Abendroth Date: Tue, 17 Feb 2026 01:30:18 -0800 Subject: [PATCH] fix(tac): update tests for cross-platform error messages and strip_errno - Remove `(os error 28)` from test_failed_write_is_reported expectation to match the intentional strip_errno() behavior --- tests/by-util/test_tac.rs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/tests/by-util/test_tac.rs b/tests/by-util/test_tac.rs index 14177f9e2..4d66d56fd 100644 --- a/tests/by-util/test_tac.rs +++ b/tests/by-util/test_tac.rs @@ -83,18 +83,26 @@ fn test_invalid_input() { let scene = TestScenario::new(util_name!()); let at = &scene.fixtures; + #[cfg(not(windows))] + let not_found_err = "failed to open 'b' for reading: No such file or directory"; + #[cfg(windows)] + let not_found_err = "failed to open 'b' for reading: The system cannot find the file specified."; + scene .ucmd() .arg("b") .fails() - .stderr_contains("failed to open 'b' for reading: No such file or directory"); + .stderr_contains(not_found_err); at.mkdir("a"); - scene - .ucmd() - .arg("a") - .fails() - .stderr_contains("a: read error: Is a directory"); + // On Unix, File::open succeeds on directories but read_to_end fails with EISDIR. + // On Windows, File::open on a directory fails with "Access is denied". + #[cfg(not(windows))] + let dir_err = "a: read error: Is a directory"; + #[cfg(windows)] + let dir_err = "failed to open 'a' for reading: Access is denied"; + + scene.ucmd().arg("a").fails().stderr_contains(dir_err); } #[test] @@ -387,7 +395,7 @@ fn test_failed_write_is_reported() { .pipe_in("hello") .set_stdout(std::fs::File::create("/dev/full").unwrap()) .fails() - .stderr_is("tac: failed to write to stdout: No space left on device (os error 28)\n"); + .stderr_is("tac: failed to write to stdout: No space left on device\n"); } #[cfg(target_os = "linux")]