Skip to content

Commit dc863e1

Browse files
committed
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
1 parent b6cf570 commit dc863e1

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

tests/by-util/test_tac.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,26 @@ fn test_invalid_input() {
8383
let scene = TestScenario::new(util_name!());
8484
let at = &scene.fixtures;
8585

86+
#[cfg(not(windows))]
87+
let not_found_err = "failed to open 'b' for reading: No such file or directory";
88+
#[cfg(windows)]
89+
let not_found_err = "failed to open 'b' for reading: The system cannot find the file specified.";
90+
8691
scene
8792
.ucmd()
8893
.arg("b")
8994
.fails()
90-
.stderr_contains("failed to open 'b' for reading: No such file or directory");
95+
.stderr_contains(not_found_err);
9196

9297
at.mkdir("a");
93-
scene
94-
.ucmd()
95-
.arg("a")
96-
.fails()
97-
.stderr_contains("a: read error: Is a directory");
98+
// On Unix, File::open succeeds on directories but read_to_end fails with EISDIR.
99+
// On Windows, File::open on a directory fails with "Access is denied".
100+
#[cfg(not(windows))]
101+
let dir_err = "a: read error: Is a directory";
102+
#[cfg(windows)]
103+
let dir_err = "failed to open 'a' for reading: Access is denied";
104+
105+
scene.ucmd().arg("a").fails().stderr_contains(dir_err);
98106
}
99107

100108
#[test]
@@ -387,7 +395,7 @@ fn test_failed_write_is_reported() {
387395
.pipe_in("hello")
388396
.set_stdout(std::fs::File::create("/dev/full").unwrap())
389397
.fails()
390-
.stderr_is("tac: failed to write to stdout: No space left on device (os error 28)\n");
398+
.stderr_is("tac: failed to write to stdout: No space left on device\n");
391399
}
392400

393401
#[cfg(target_os = "linux")]

0 commit comments

Comments
 (0)