mirror of
https://github.com/uutils/diffutils.git
synced 2026-06-10 15:48:59 -07:00
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.
This commit is contained in:
+18
-3
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user