File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -203,6 +203,7 @@ mod tests {
203203 fmt:: Display ,
204204 path:: { Path , PathBuf } ,
205205 process:: Command ,
206+ sync:: Mutex ,
206207 } ;
207208
208209 use c2rust_analysis_rt:: runtime:: backend:: BackendKind ;
@@ -316,6 +317,14 @@ mod tests {
316317 let metadata_path = exe_dir. join ( "metadata.bc" ) ;
317318 let event_log_path = exe_dir. join ( "event.log.bc" ) ;
318319
320+ /// There can be a race condition in the `cargo run` calls.
321+ /// The `cargo build`s synchronize already, but after building,
322+ /// a second `cargo build` can temporarily move/delete the binary
323+ /// while the first `cargo run` tries to run it.
324+ /// So just use a `Mutex` around the whole thing.
325+ static CARGO_RUN_C2RUST_INSTRUMENT : Mutex < ( ) > = Mutex :: new ( ( ) ) ;
326+
327+ let guard = CARGO_RUN_C2RUST_INSTRUMENT . lock ( ) . unwrap ( ) ;
319328 let mut cmd = Command :: new ( "cargo" ) ;
320329 cmd. current_dir ( repo_dir ( ) ?)
321330 . args ( & [
@@ -344,6 +353,7 @@ mod tests {
344353 . env ( "INSTRUMENT_OUTPUT_APPEND" , "false" ) ;
345354 let status = cmd. status ( ) ?;
346355 ensure ! ( status. success( ) , eyre!( "{cmd:?} failed: {status}" ) ) ;
356+ drop ( guard) ;
347357
348358 let pdg = Pdg :: new ( & metadata_path, & event_log_path) ?;
349359 pdg. graphs . assert_all_tests ( ) ;
You can’t perform that action at this time.
0 commit comments