File tree Expand file tree Collapse file tree 1 file changed +20
-13
lines changed
Expand file tree Collapse file tree 1 file changed +20
-13
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,9 @@ use std::os::unix::ffi::OsStrExt;
1010use std:: os:: unix:: process:: ExitStatusExt ;
1111use std:: path:: Path ;
1212use std:: process:: ExitStatus ;
13+ use std:: sync:: Once ;
14+
15+ static BUILD_ONCE : Once = Once :: new ( ) ;
1316
1417fn 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
You can’t perform that action at this time.
0 commit comments