diff --git a/Cargo.lock b/Cargo.lock index 86dc16a..aa11cc7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -115,7 +115,7 @@ checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" [[package]] name = "diffutils" -version = "0.4.2" +version = "0.5.0" dependencies = [ "assert_cmd", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 2c1b4d9..32e47ed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "diffutils" -version = "0.4.2" +version = "0.5.0" edition = "2021" description = "A CLI app for generating diff files" license = "MIT OR Apache-2.0" diff --git a/tests/integration.rs b/tests/integration.rs index 476660f..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"); @@ -864,6 +879,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()