Skip to content

Commit

Permalink
Update the expected error message for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
oSoMoN committed Apr 23, 2024
1 parent c904a8b commit 5c3b17e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,18 @@ fn cannot_read_files() -> Result<(), Box<dyn std::error::Error>> {
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()
)));

Expand All @@ -46,15 +51,15 @@ fn cannot_read_files() -> Result<(), Box<dyn std::error::Error>> {
.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()
)));

let mut cmd = Command::cargo_bin("diffutils")?;
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),
Expand Down

0 comments on commit 5c3b17e

Please sign in to comment.