@@ -28,12 +28,16 @@ fn gated() {
2828} 
2929
3030#[ cargo_test]  
31- fn  simple ( )  { 
31+ fn  one_logfile_per_invocation ( )  { 
3232    let  p = project ( ) 
3333        . file ( "Cargo.toml" ,  & basic_manifest ( "foo" ,  "0.0.0" ) ) 
3434        . file ( "src/lib.rs" ,  "" ) 
3535        . build ( ) ; 
3636
37+     let  cargo_home = paths:: cargo_home ( ) ; 
38+     let  log_dir = cargo_home. join ( "log" ) ; 
39+ 
40+     // First invocation 
3741    p. cargo ( "check -Zbuild-analysis" ) 
3842        . env ( "CARGO_BUILD_ANALYSIS_ENABLED" ,  "true" ) 
3943        . masquerade_as_nightly_cargo ( & [ "build-analysis" ] ) 
@@ -43,6 +47,33 @@ fn simple() {
4347
4448"# ] ] ) 
4549        . run ( ) ; 
50+ 
51+     assert ! ( log_dir. exists( ) ) ; 
52+     let  entries = std:: fs:: read_dir ( & log_dir) . unwrap ( ) ; 
53+     let  log_files:  Vec < _ >  = entries
54+         . filter_map ( Result :: ok) 
55+         . filter ( |e| e. path ( ) . extension ( ) . and_then ( |s| s. to_str ( ) )  == Some ( "jsonl" ) ) 
56+         . collect ( ) ; 
57+ 
58+     assert_eq ! ( log_files. len( ) ,  1 ) ; 
59+ 
60+     // Second invocation 
61+     p. cargo ( "check -Zbuild-analysis" ) 
62+         . env ( "CARGO_BUILD_ANALYSIS_ENABLED" ,  "true" ) 
63+         . masquerade_as_nightly_cargo ( & [ "build-analysis" ] ) 
64+         . with_stderr_data ( str![ [ r#" 
65+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s 
66+ 
67+ "# ] ] ) 
68+         . run ( ) ; 
69+ 
70+     let  entries = std:: fs:: read_dir ( & log_dir) . unwrap ( ) ; 
71+     let  log_files:  Vec < _ >  = entries
72+         . filter_map ( Result :: ok) 
73+         . filter ( |e| e. path ( ) . extension ( ) . and_then ( |s| s. to_str ( ) )  == Some ( "jsonl" ) ) 
74+         . collect ( ) ; 
75+ 
76+     assert_eq ! ( log_files. len( ) ,  2 ) ; 
4677} 
4778
4879#[ cargo_test]  
0 commit comments