mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
cp: look for specific error messages in tests
This commit is contained in:
parent
dd9e7ad363
commit
af86aee6b8
1 changed files with 12 additions and 2 deletions
|
@ -170,12 +170,17 @@ fn test_cp_multiple_files() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_cp_multiple_files_with_nonexistent_file() {
|
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!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
ucmd.arg(TEST_HELLO_WORLD_SOURCE)
|
ucmd.arg(TEST_HELLO_WORLD_SOURCE)
|
||||||
.arg(TEST_NONEXISTENT_FILE)
|
.arg(TEST_NONEXISTENT_FILE)
|
||||||
.arg(TEST_HOW_ARE_YOU_SOURCE)
|
.arg(TEST_HOW_ARE_YOU_SOURCE)
|
||||||
.arg(TEST_COPY_TO_FOLDER)
|
.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_COPY_TO_FOLDER_FILE), "Hello, World!\n");
|
||||||
assert_eq!(at.read(TEST_HOW_ARE_YOU_DEST), "How are you?\n");
|
assert_eq!(at.read(TEST_HOW_ARE_YOU_DEST), "How are you?\n");
|
||||||
|
@ -183,12 +188,17 @@ fn test_cp_multiple_files_with_nonexistent_file() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_cp_multiple_files_with_empty_file_name() {
|
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!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
ucmd.arg(TEST_HELLO_WORLD_SOURCE)
|
ucmd.arg(TEST_HELLO_WORLD_SOURCE)
|
||||||
.arg("")
|
.arg("")
|
||||||
.arg(TEST_HOW_ARE_YOU_SOURCE)
|
.arg(TEST_HOW_ARE_YOU_SOURCE)
|
||||||
.arg(TEST_COPY_TO_FOLDER)
|
.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_COPY_TO_FOLDER_FILE), "Hello, World!\n");
|
||||||
assert_eq!(at.read(TEST_HOW_ARE_YOU_DEST), "How are you?\n");
|
assert_eq!(at.read(TEST_HOW_ARE_YOU_DEST), "How are you?\n");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue