Skip to content

Commit d8601f6

Browse files
committed
[m4] more test fixing
1 parent 62e5c19 commit d8601f6

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

m4/tests/integration_test.rs

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ use std::os::unix::ffi::OsStrExt;
1010
use std::os::unix::process::ExitStatusExt;
1111
use std::path::Path;
1212
use std::process::ExitStatus;
13+
use std::sync::Once;
14+
15+
static BUILD_ONCE: Once = Once::new();
1316

1417
fn init() {
1518
let _ = env_logger::builder()
@@ -92,19 +95,23 @@ fn run_command(input: &Path) -> std::process::Output {
9295
release_path
9396
} else {
9497
// Build debug binary if release doesn't exist
95-
let cargo_build_output = std::process::Command::new("cargo")
96-
.arg("build")
97-
.arg("-p")
98-
.arg("posixutils-m4")
99-
.current_dir(workspace_root)
100-
.output()
101-
.unwrap();
102-
if !cargo_build_output.status.success() {
103-
panic!(
104-
"cargo build failed: {}",
105-
String::from_utf8_lossy(&cargo_build_output.stderr)
106-
);
107-
}
98+
// Use Once to ensure cargo build runs only once, avoiding race conditions
99+
// when multiple .args tests run in parallel
100+
BUILD_ONCE.call_once(|| {
101+
let cargo_build_output = std::process::Command::new("cargo")
102+
.arg("build")
103+
.arg("-p")
104+
.arg("posixutils-m4")
105+
.current_dir(workspace_root)
106+
.output()
107+
.unwrap();
108+
if !cargo_build_output.status.success() {
109+
panic!(
110+
"cargo build failed: {}",
111+
String::from_utf8_lossy(&cargo_build_output.stderr)
112+
);
113+
}
114+
});
108115
debug_path
109116
};
110117

0 commit comments

Comments
 (0)