Skip to content

Commit 4169478

Browse files
committed
fix(test): use cross-platform assertion for missing file error
The `test_cli_missing_input_file` integration test was failing on Ubuntu/POSIX runners because it asserted the Windows-specific error message fragment "cannot find the file specified" for a non-existent input file. This commit updates the assertion using `predicates::or` to accept either the standard POSIX error message ("No such file or directory") or the Windows fragment, ensuring the test passes on all target platforms (Linux, macOS, Windows).
1 parent bcc6077 commit 4169478

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

tests/cli/errors.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,15 @@ fn test_cli_missing_input_file() {
1313
let mut cmd = get_cmd();
1414
cmd.arg(temp_dir.path().join("nonexistent.md")); // Path that doesn't exist
1515

16-
cmd.assert()
17-
.failure()
18-
.stderr(predicate::str::contains("Error: I/O error:"))
19-
// Adjust assertion for Windows error message fragment
20-
.stderr(predicate::str::contains("cannot find the file specified"));
16+
// Combine predicates to handle both POSIX and Windows error messages
17+
let error_message_predicate = predicate::str::contains("Error: I/O error:") // Common part
18+
.and(
19+
// Must contain common part AND...
20+
predicate::str::contains("No such file or directory") // ...either the POSIX message
21+
.or(predicate::str::contains("cannot find the file specified")), // ...or the Windows message
22+
);
23+
24+
cmd.assert().failure().stderr(error_message_predicate); // Use the combined predicate
2125
}
2226

2327
#[test]

0 commit comments

Comments
 (0)