diff --git a/tests/by-util/test_cp.rs b/tests/by-util/test_cp.rs index 26a0e1d96..c246d0ef9 100644 --- a/tests/by-util/test_cp.rs +++ b/tests/by-util/test_cp.rs @@ -38,8 +38,6 @@ static TEST_COPY_FROM_FOLDER: &str = "hello_dir_with_file/"; static TEST_COPY_FROM_FOLDER_FILE: &str = "hello_dir_with_file/hello_world.txt"; static TEST_COPY_TO_FOLDER_NEW: &str = "hello_dir_new"; static TEST_COPY_TO_FOLDER_NEW_FILE: &str = "hello_dir_new/hello_world.txt"; -static TEST_PROTECT_BACKUP_SRC: &str = "protected.txt.bak"; -static TEST_PROTECT_BACKUP_DEST: &str = "protected.txt"; #[cfg(any(target_os = "linux", target_os = "android", target_os = "freebsd"))] static TEST_MOUNT_COPY_FROM_FOLDER: &str = "dir_with_mount"; #[cfg(any(target_os = "linux", target_os = "android", target_os = "freebsd"))] @@ -563,20 +561,19 @@ fn test_cp_backup_simple() { #[test] fn test_cp_backup_simple_protect_source() { let (at, mut ucmd) = at_and_ucmd!(); + let source = format!("{}~", TEST_HELLO_WORLD_SOURCE); + at.touch(&source); ucmd.arg("--backup=simple") - .arg("--suffix") - .arg(".bak") - .arg(TEST_PROTECT_BACKUP_SRC) - .arg(TEST_PROTECT_BACKUP_DEST) + .arg(&source) + .arg(TEST_HELLO_WORLD_SOURCE) .fails() .stderr_only(format!( "cp: backing up '{}' might destroy source; '{}' not copied", - TEST_PROTECT_BACKUP_DEST, - TEST_PROTECT_BACKUP_SRC, + TEST_HELLO_WORLD_SOURCE, source, )); - assert_eq!(at.read(TEST_PROTECT_BACKUP_SRC), "original text\n"); - assert_eq!(at.read(TEST_PROTECT_BACKUP_DEST), "new text\n"); + assert_eq!(at.read(TEST_HELLO_WORLD_SOURCE), "Hello, World!\n"); + assert_eq!(at.read(&source), ""); } #[test]