From 15573579cc4d043d6505011becbf82966f5d52b0 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sun, 24 Dec 2023 15:18:31 +0100 Subject: [PATCH] Fix the windows tests --- tests/by-util/test_cp.rs | 15 +++++++++------ tests/by-util/test_ln.rs | 16 ++++++++++------ tests/by-util/test_mv.rs | 33 ++++++++++++++++++++------------- 3 files changed, 39 insertions(+), 25 deletions(-) diff --git a/tests/by-util/test_cp.rs b/tests/by-util/test_cp.rs index eda5dd4c6..07b9620a6 100644 --- a/tests/by-util/test_cp.rs +++ b/tests/by-util/test_cp.rs @@ -3571,12 +3571,15 @@ fn test_cp_seen_file() { at.write("a/f", "a"); at.write("b/f", "b"); - ts.ucmd() - .arg("a/f") - .arg("b/f") - .arg("c") - .fails() - .stderr_contains("will not overwrite just-created 'c/f' with 'b/f'"); + let result = ts.ucmd().arg("a/f").arg("b/f").arg("c").fails(); + #[cfg(not(unix))] + assert!(result + .stderr_str() + .contains("will not overwrite just-created 'c\\f' with 'b/f'")); + #[cfg(unix)] + assert!(result + .stderr_str() + .contains("will not overwrite just-created 'c/f' with 'b/f'")); assert!(at.plus("c").join("f").exists()); diff --git a/tests/by-util/test_ln.rs b/tests/by-util/test_ln.rs index b6453bf43..e51d99732 100644 --- a/tests/by-util/test_ln.rs +++ b/tests/by-util/test_ln.rs @@ -733,12 +733,16 @@ fn test_ln_seen_file() { at.write("a/f", "a"); at.write("b/f", "b"); - ts.ucmd() - .arg("a/f") - .arg("b/f") - .arg("c") - .fails() - .stderr_contains("will not overwrite just-created 'c/f' with 'b/f'"); + let result = ts.ucmd().arg("a/f").arg("b/f").arg("c").fails(); + + #[cfg(not(unix))] + assert!(result + .stderr_str() + .contains("will not overwrite just-created 'c\\f' with 'b/f'")); + #[cfg(unix)] + assert!(result + .stderr_str() + .contains("will not overwrite just-created 'c/f' with 'b/f'")); assert!(at.plus("c").join("f").exists()); // b/f still exists diff --git a/tests/by-util/test_mv.rs b/tests/by-util/test_mv.rs index bc75ada3f..61a4aebf6 100644 --- a/tests/by-util/test_mv.rs +++ b/tests/by-util/test_mv.rs @@ -1480,12 +1480,16 @@ fn test_mv_seen_file() { at.write("a/f", "a"); at.write("b/f", "b"); - ts.ucmd() - .arg("a/f") - .arg("b/f") - .arg("c") - .fails() - .stderr_contains("will not overwrite just-created 'c/f' with 'b/f'"); + let result = ts.ucmd().arg("a/f").arg("b/f").arg("c").fails(); + + #[cfg(not(unix))] + assert!(result + .stderr_str() + .contains("will not overwrite just-created 'c\\f' with 'b/f'")); + #[cfg(unix)] + assert!(result + .stderr_str() + .contains("will not overwrite just-created 'c/f' with 'b/f'")); // a/f has been moved into c/f assert!(at.plus("c").join("f").exists()); @@ -1507,13 +1511,16 @@ fn test_mv_seen_multiple_files_to_directory() { at.write("b/f", "b"); at.write("b/g", "g"); - ts.ucmd() - .arg("a/f") - .arg("b/f") - .arg("b/g") - .arg("c") - .fails() - .stderr_contains("will not overwrite just-created 'c/f' with 'b/f'"); + let result = ts.ucmd().arg("a/f").arg("b/f").arg("b/g").arg("c").fails(); + #[cfg(not(unix))] + assert!(result + .stderr_str() + .contains("will not overwrite just-created 'c\\f' with 'b/f'")); + #[cfg(unix)] + assert!(result + .stderr_str() + .contains("will not overwrite just-created 'c/f' with 'b/f'")); + assert!(!at.plus("a").join("f").exists()); assert!(at.plus("b").join("f").exists()); assert!(!at.plus("b").join("g").exists());