From da0ada8a3770c8e26cf6690b01db673ccaf8c947 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sat, 30 May 2026 11:33:47 +0200 Subject: [PATCH] test: use platform-specific expected message for nonexistent-file error --- tests/test_grep.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/test_grep.rs b/tests/test_grep.rs index e6faacc..5e487ea 100644 --- a/tests/test_grep.rs +++ b/tests/test_grep.rs @@ -1096,11 +1096,18 @@ fn nonexistent_file_is_error() { #[test] fn nonexistent_file_error_has_no_os_error_suffix() { // GNU prints "grep: : No such file or directory" with no - // " (os error 2)" suffix; strip_errno keeps us byte-compatible. + // " (os error 2)" suffix; strip_errno keeps us byte-compatible. The + // underlying OS message text differs on Windows, but in both cases the + // trailing " (os error N)" must be absent. + #[cfg(not(windows))] + let expected = "grep: does-not-exist: No such file or directory\n"; + #[cfg(windows)] + let expected = "grep: does-not-exist: The system cannot find the file specified.\n"; + let (_s, mut c) = ucmd(); c.args(&["x", "does-not-exist"]) .fails_with_code(2) - .stderr_is("grep: does-not-exist: No such file or directory\n"); + .stderr_is(expected); } #[test]