Watch
0
0
Fork
You've already forked hyperhive
0

meta test: retry the fake nix exec when it hits ETXTBSY

This commit is contained in:
damocles 2026-10-24 09:54:56 +02:00 • committed by mara
commit a684ef1e34

View file

@ -2144,14 +2144,26 @@ mod lock_wait_tests {
std::fs::write(&fake, "#!/bin/sh\nexec sleep 30\n").expect("write"); std::fs::write(&fake, "#!/bin/sh\nexec sleep 30\n").expect("write");
std::fs::set_permissions(&fake, std::os::unix::fs::PermissionsExt::from_mode(0o755)) std::fs::set_permissions(&fake, std::os::unix::fs::PermissionsExt::from_mode(0o755))
.expect("chmod"); .expect("chmod");
let err = nix_output_with( // Parallel tests fork while the script's write fd is still open, so an
// early exec can hit ETXTBSY. That is a race in building the fake, not
// in `nix_output_with`: retry it, anything else fails the test.
let mut tries = 0;
let err = loop {
let res = nix_output_with(
fake.as_os_str(), fake.as_os_str(),
dir.path(), dir.path(),
&["flake", "update", "hyperhive"], &["flake", "update", "hyperhive"],
Duration::from_millis(300), Duration::from_millis(300),
) )
.await .await;
.expect_err("hung nix must time out"); match res {
Err(e) if tries < 20 && format!("{e:#}").contains("Text file busy") => {
tries += 1;
tokio::time::sleep(Duration::from_millis(50)).await;
}
other => break other.expect_err("hung nix must time out"),
}
};
let msg = format!("{err:#}"); let msg = format!("{err:#}");
assert!( assert!(
msg.contains("nix flake update hyperhive in") && msg.contains("timed out after 0.3s"), msg.contains("nix flake update hyperhive in") && msg.contains("timed out after 0.3s"),