meta test: retry the fake nix exec when it hits ETXTBSY
This commit is contained in:
parent
fe578c57fd
commit
a684ef1e34
1 changed files with 20 additions and 8 deletions
|
|
@ -2144,14 +2144,26 @@ mod lock_wait_tests {
|
|||
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))
|
||||
.expect("chmod");
|
||||
let err = nix_output_with(
|
||||
fake.as_os_str(),
|
||||
dir.path(),
|
||||
&["flake", "update", "hyperhive"],
|
||||
Duration::from_millis(300),
|
||||
)
|
||||
.await
|
||||
.expect_err("hung nix must time out");
|
||||
// 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(),
|
||||
dir.path(),
|
||||
&["flake", "update", "hyperhive"],
|
||||
Duration::from_millis(300),
|
||||
)
|
||||
.await;
|
||||
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:#}");
|
||||
assert!(
|
||||
msg.contains("nix flake update hyperhive in") && msg.contains("timed out after 0.3s"),
|
||||
|
|
|
|||
Loading…
Reference in a new issue