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::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
|
||||||
fake.as_os_str(),
|
// early exec can hit ETXTBSY. That is a race in building the fake, not
|
||||||
dir.path(),
|
// in `nix_output_with`: retry it, anything else fails the test.
|
||||||
&["flake", "update", "hyperhive"],
|
let mut tries = 0;
|
||||||
Duration::from_millis(300),
|
let err = loop {
|
||||||
)
|
let res = nix_output_with(
|
||||||
.await
|
fake.as_os_str(),
|
||||||
.expect_err("hung nix must time out");
|
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:#}");
|
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"),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue