diff --git a/tests/integration.rs b/tests/integration.rs index 4f66574..864be4a 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -30,13 +30,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() ))); @@ -46,7 +51,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() ))); @@ -54,7 +59,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),