tests: every temporary path is removed by a guard; no leftovers in /tmp
About 10,000 test leftovers had built up in titan's /tmp. loopd's Home and FakeServer, its fake broker's socket, bxctl's temp sockets, fake loopd and command homes, inferproxy's socket, and a few brokerd and toolkit tests created uniquely named directories or sockets and never removed them, or removed them by hand at the end, which a failing test skips. Each is now a guard removed on drop (bxctl gains tests/support/temp.rs). Two races also left gatewayd homes behind: the test Running only signalled its server to stop, and two Stage structs declared the home first, so it was removed while the server could still write into it. Running's drop now waits for the thread (with a 5-second limit), and every home is declared last. Checked: make gate twice, then the gate and three rounds of gatewayd and loopd tests; no new entry in /tmp; 944 tests pass. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
//! `[runner]` in `brokerd.toml` (M3b spec, section 6). Do not edit.
|
||||
|
||||
#[path = "support/tmp.rs"]
|
||||
mod tmp;
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::time::Duration;
|
||||
|
||||
@@ -88,8 +91,7 @@ fn unknown_runner_keys_are_errors() {
|
||||
|
||||
#[test]
|
||||
fn bad_values_are_errors_that_name_them() {
|
||||
let dir = std::env::temp_dir().join(format!("bx-runner-cfg-{}", std::process::id()));
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
let dir = tmp::TempDir::new("runner-cfg");
|
||||
let cases = [
|
||||
(
|
||||
format!("image = \"x@sha256:{}\"", "0".repeat(63)),
|
||||
@@ -123,14 +125,13 @@ fn bad_values_are_errors_that_name_them() {
|
||||
(format!("image = \"{DIGEST}\"\npodman = \"\""), "podman"),
|
||||
];
|
||||
for (n, (body, word)) in cases.iter().enumerate() {
|
||||
let path = dir.join(format!("c{n}.toml"));
|
||||
let path = dir.path().join(format!("c{n}.toml"));
|
||||
std::fs::write(&path, format!("[runner]\n{body}\n")).unwrap();
|
||||
match Config::load(&path) {
|
||||
Err(ConfigError::Invalid(_, why)) => assert!(why.contains(word), "{body}: {why}"),
|
||||
other => panic!("{body}: expected Invalid, got {other:?}"),
|
||||
}
|
||||
}
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
//! Two small texts from the M3b review: every line `brokerd serve` prints about its runtime starts
|
||||
//! with `brokerd:`, and a bad `[runner]` value is quoted in its error. Do not edit.
|
||||
|
||||
#[path = "support/tmp.rs"]
|
||||
mod tmp;
|
||||
|
||||
#[path = "support/fake_podman.rs"]
|
||||
mod fake_podman;
|
||||
|
||||
@@ -59,8 +62,7 @@ fn the_runtime_notice_starts_with_brokerd() {
|
||||
|
||||
#[test]
|
||||
fn a_bad_runner_value_is_quoted() {
|
||||
let dir = std::env::temp_dir().join(format!("bx-notice-cfg-{}", std::process::id()));
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
let dir = tmp::TempDir::new("notice-cfg");
|
||||
let cases = [
|
||||
("image = \"not by digest\"", "\"not by digest\""),
|
||||
(
|
||||
@@ -69,12 +71,11 @@ fn a_bad_runner_value_is_quoted() {
|
||||
),
|
||||
];
|
||||
for (n, (body, quoted)) in cases.iter().enumerate() {
|
||||
let path = dir.join(format!("q{n}.toml"));
|
||||
let path = dir.path().join(format!("q{n}.toml"));
|
||||
std::fs::write(&path, format!("[runner]\n{body}\n")).unwrap();
|
||||
match Config::load(&path) {
|
||||
Err(ConfigError::Invalid(_, why)) => assert!(why.contains(quoted), "{why}"),
|
||||
other => panic!("{body}: {other:?}"),
|
||||
}
|
||||
}
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user