File tree Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change @@ -123,3 +123,56 @@ fn log_msg_build_started() {
123123 . against_jsonlines ( ) ,
124124 ) ;
125125}
126+
127+ #[ cargo_test]
128+ fn log_msg_timing_info ( ) {
129+ let p = project ( )
130+ . file (
131+ "Cargo.toml" ,
132+ r#"
133+ [package]
134+ name = "foo"
135+ version = "0.0.0"
136+ edition = "2015"
137+
138+ [dependencies]
139+ bar = { path = "bar" }
140+ "# ,
141+ )
142+ . file ( "src/lib.rs" , "" )
143+ . file ( "bar/Cargo.toml" , & basic_manifest ( "bar" , "0.0.0" ) )
144+ . file ( "bar/src/lib.rs" , "" )
145+ . build ( ) ;
146+
147+ p. cargo ( "check -Zbuild-analysis" )
148+ . env ( "CARGO_BUILD_ANALYSIS_ENABLED" , "true" )
149+ . masquerade_as_nightly_cargo ( & [ "build-analysis" ] )
150+ . run ( ) ;
151+
152+ let cargo_home = paths:: cargo_home ( ) ;
153+ let log_dir = cargo_home. join ( "log" ) ;
154+ assert ! ( log_dir. exists( ) ) ;
155+
156+ let entries = std:: fs:: read_dir ( & log_dir) . unwrap ( ) ;
157+ let log_file = entries
158+ . filter_map ( Result :: ok)
159+ . find ( |e| e. path ( ) . extension ( ) . and_then ( |s| s. to_str ( ) ) == Some ( "jsonl" ) )
160+ . unwrap ( ) ;
161+
162+ let content = std:: fs:: read_to_string ( log_file. path ( ) ) . unwrap ( ) ;
163+
164+ // Current behavior: only build-started, no timing-info logs exist yet
165+ assert_e2e ( ) . eq (
166+ & content,
167+ str![ [ r#"
168+ [
169+ {
170+ "reason": "build-started",
171+ "...": "{...}"
172+ }
173+ ]
174+ "# ] ]
175+ . is_json ( )
176+ . against_jsonlines ( ) ,
177+ ) ;
178+ }
You can’t perform that action at this time.
0 commit comments