From 732dbb3f125ffa8540bba3a6de5e66f39c681fa3 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Tue, 27 Jun 2023 16:46:50 +0200 Subject: [PATCH] cp: fix "unused variable" warning on Windows --- tests/by-util/test_cp.rs | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/tests/by-util/test_cp.rs b/tests/by-util/test_cp.rs index 3a00870c59..3074513de2 100644 --- a/tests/by-util/test_cp.rs +++ b/tests/by-util/test_cp.rs @@ -3127,8 +3127,9 @@ fn test_cp_debug_sparse_auto() { let ts = TestScenario::new(util_name!()); let at = &ts.fixtures; at.touch("a"); - let result = ts - .ucmd() + + #[cfg(not(any(target_os = "linux", target_os = "macos")))] + ts.ucmd() .arg("--debug") .arg("--sparse=auto") .arg("a") @@ -3136,18 +3137,29 @@ fn test_cp_debug_sparse_auto() { .succeeds(); #[cfg(any(target_os = "linux", target_os = "macos"))] - let stdout_str = result.stdout_str(); - - #[cfg(target_os = "macos")] - if !stdout_str - .contains("copy offload: unknown, reflink: unsupported, sparse detection: unsupported") { - panic!("Failure: stdout was \n{stdout_str}"); - } + let result = ts + .ucmd() + .arg("--debug") + .arg("--sparse=auto") + .arg("a") + .arg("b") + .succeeds(); - #[cfg(target_os = "linux")] - if !stdout_str.contains("copy offload: unknown, reflink: unsupported, sparse detection: no") { - panic!("Failure: stdout was \n{stdout_str}"); + let stdout_str = result.stdout_str(); + + #[cfg(target_os = "macos")] + if !stdout_str + .contains("copy offload: unknown, reflink: unsupported, sparse detection: unsupported") + { + panic!("Failure: stdout was \n{stdout_str}"); + } + + #[cfg(target_os = "linux")] + if !stdout_str.contains("copy offload: unknown, reflink: unsupported, sparse detection: no") + { + panic!("Failure: stdout was \n{stdout_str}"); + } } }