From 8997ac06b8eea7ae273afe03fc1dcb850057c65b Mon Sep 17 00:00:00 2001 From: Gustavo Noronha Silva Date: Mon, 22 Dec 2025 13:03:44 -0300 Subject: [PATCH 1/2] Use specific locale for cmp_fast_path test The test was failing in the regular MacOS terminal due to it defaulting to LC_ALL=C. Best to standardize like the other tests that check for locale-dependent output. --- tests/integration.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/integration.rs b/tests/integration.rs index 476660f..41c9a84 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -864,6 +864,7 @@ mod cmp { let mut cmd = cargo_bin_cmd!("diffutils"); cmd.arg("cmp"); cmd.arg(&a_path).arg(&b_path); + cmd.env("LC_ALL", "en_US"); cmd.assert() .code(predicate::eq(1)) .failure() From 7ddc6c6c4befe6b648509b1aa3260c573e53cd8a Mon Sep 17 00:00:00 2001 From: Gustavo Noronha Silva Date: Sun, 21 Dec 2025 11:38:30 -0300 Subject: [PATCH 2/2] Make cmp_fast_path more robust On my Mac I see this test fail quite consistently. This change makes it more resilient in systems with slower startup times, while still allowing faster systems to finish as soon as possible. --- tests/integration.rs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/tests/integration.rs b/tests/integration.rs index 41c9a84..b37d7e6 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -825,9 +825,24 @@ mod cmp { .spawn() .unwrap(); - std::thread::sleep(std::time::Duration::from_millis(100)); - - assert_eq!(child.try_wait().unwrap().unwrap().code(), Some(1)); + // Bound the runtime to a very short time that still allows for some resource + // constraint to slow it down while also allowing very fast systems to exit as + // early as possible. + const MAX_TRIES: u8 = 50; + for tries in 0..=MAX_TRIES { + if tries == MAX_TRIES { + panic!("cmp took too long to run, /dev/null optimization probably not working") + } + match child.try_wait() { + Ok(Some(status)) => { + assert_eq!(status.code(), Some(1)); + break; + } + Ok(None) => (), + Err(e) => panic!("{e:#?}"), + } + std::thread::sleep(std::time::Duration::from_millis(10)); + } // Two stdins should be equal let mut cmd = cargo_bin_cmd!("diffutils");