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
This commit is contained in:
Jake Abendroth
2026-02-23 00:18:42 -08:00
parent b6cf570e3c
commit dc863e110f
+15 -7
View File
@@ -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")]