From 72a43c8db84eb1550ead175e6c3de3a66cd5e8b3 Mon Sep 17 00:00:00 2001 From: Olivier Tilloy Date: Tue, 23 Apr 2024 22:29:02 +0200 Subject: [PATCH] Update the expected error message for Windows --- tests/integration.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/integration.rs b/tests/integration.rs index ee8f15c..f8ad515 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -31,13 +31,18 @@ fn cannot_read_files() -> Result<(), Box> { let nopath = nofile.into_temp_path(); std::fs::remove_file(&nopath)?; + #[cfg(not(windows))] + let error_message = "No such file or directory"; + #[cfg(windows)] + let error_message = "The system cannot find the file specified."; + let mut cmd = Command::cargo_bin("diffutils")?; cmd.arg(&nopath).arg(file.path()); cmd.assert() .code(predicate::eq(2)) .failure() .stderr(predicate::str::ends_with(format!( - ": {}: No such file or directory\n", + ": {}: {error_message}\n", &nopath.as_os_str().to_string_lossy() ))); @@ -47,7 +52,7 @@ fn cannot_read_files() -> Result<(), Box> { .code(predicate::eq(2)) .failure() .stderr(predicate::str::ends_with(format!( - ": {}: No such file or directory\n", + ": {}: {error_message}\n", &nopath.as_os_str().to_string_lossy() ))); @@ -55,7 +60,7 @@ fn cannot_read_files() -> Result<(), Box> { cmd.arg(&nopath).arg(&nopath); cmd.assert().code(predicate::eq(2)).failure().stderr( predicate::str::contains(format!( - ": {}: No such file or directory\n", + ": {}: {error_message}\n", &nopath.as_os_str().to_string_lossy() )) .count(2),