Skip to content

Commit

Permalink
cp: look for specific error messages in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
samueltardieu authored and BenWiederhake committed Sep 8, 2024
1 parent dd9e7ad commit af86aee
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions tests/by-util/test_cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,25 +170,35 @@ fn test_cp_multiple_files() {

#[test]
fn test_cp_multiple_files_with_nonexistent_file() {
#[cfg(windows)]
let error_msg = "The system cannot find the file specified";
#[cfg(not(windows))]
let error_msg = format!("'{TEST_NONEXISTENT_FILE}': No such file or directory");
let (at, mut ucmd) = at_and_ucmd!();
ucmd.arg(TEST_HELLO_WORLD_SOURCE)
.arg(TEST_NONEXISTENT_FILE)
.arg(TEST_HOW_ARE_YOU_SOURCE)
.arg(TEST_COPY_TO_FOLDER)
.fails();
.fails()
.stderr_contains(error_msg);

assert_eq!(at.read(TEST_COPY_TO_FOLDER_FILE), "Hello, World!\n");
assert_eq!(at.read(TEST_HOW_ARE_YOU_DEST), "How are you?\n");
}

#[test]
fn test_cp_multiple_files_with_empty_file_name() {
#[cfg(windows)]
let error_msg = "The system cannot find the path specified";
#[cfg(not(windows))]
let error_msg = "'': No such file or directory";
let (at, mut ucmd) = at_and_ucmd!();
ucmd.arg(TEST_HELLO_WORLD_SOURCE)
.arg("")
.arg(TEST_HOW_ARE_YOU_SOURCE)
.arg(TEST_COPY_TO_FOLDER)
.fails();
.fails()
.stderr_contains(error_msg);

assert_eq!(at.read(TEST_COPY_TO_FOLDER_FILE), "Hello, World!\n");
assert_eq!(at.read(TEST_HOW_ARE_YOU_DEST), "How are you?\n");
Expand Down

0 comments on commit af86aee

Please sign in to comment.