@@ -143,11 +143,17 @@ fn log_msg_timing_info() {
143143 },
144144 "timestamp": "[..]T[..]Z"
145145 },
146+ {
147+ "elapsed": "{...}",
148+ "index": 0,
149+ "reason": "unit-rmeta-finished",
150+ "run_id": "[..]T[..]Z-[..]",
151+ "timestamp": "[..]T[..]Z"
152+ },
146153 {
147154 "elapsed": "{...}",
148155 "index": 0,
149156 "reason": "unit-finished",
150- "rmeta_time": "{...}",
151157 "run_id": "[..]T[..]Z-[..]",
152158 "timestamp": "[..]T[..]Z",
153159 "unlocked": [
@@ -167,11 +173,178 @@ fn log_msg_timing_info() {
167173 },
168174 "timestamp": "[..]T[..]Z"
169175 },
176+ {
177+ "elapsed": "{...}",
178+ "index": 1,
179+ "reason": "unit-rmeta-finished",
180+ "run_id": "[..]T[..]Z-[..]",
181+ "timestamp": "[..]T[..]Z"
182+ },
183+ {
184+ "elapsed": "{...}",
185+ "index": 1,
186+ "reason": "unit-finished",
187+ "run_id": "[..]T[..]Z-[..]",
188+ "timestamp": "[..]T[..]Z"
189+ }
190+ ]
191+ "# ] ]
192+ . is_json ( )
193+ . against_jsonlines ( ) ,
194+ ) ;
195+ }
196+
197+ #[ cargo_test( nightly, reason = "rustc --json=timings is unstable" ) ]
198+ fn log_msg_timing_info_section_timings ( ) {
199+ let p = project ( )
200+ . file (
201+ "Cargo.toml" ,
202+ r#"
203+ [package]
204+ name = "foo"
205+ version = "0.0.0"
206+ edition = "2015"
207+
208+ [dependencies]
209+ bar = { path = "bar" }
210+ "# ,
211+ )
212+ . file ( "src/main.rs" , "fn main() {}" )
213+ . file ( "bar/Cargo.toml" , & basic_manifest ( "bar" , "0.0.0" ) )
214+ . file ( "bar/src/lib.rs" , "" )
215+ . build ( ) ;
216+
217+ p. cargo ( "check -Zbuild-analysis -Zsection-timings" )
218+ . env ( "CARGO_BUILD_ANALYSIS_ENABLED" , "true" )
219+ . masquerade_as_nightly_cargo ( & [ "build-analysis" , "section-timings" ] )
220+ . run ( ) ;
221+
222+ assert_e2e ( ) . eq (
223+ & get_log ( 0 ) ,
224+ str![ [ r#"
225+ [
226+ {
227+ "...": "{...}",
228+ "reason": "build-started"
229+ },
230+ {
231+ "elapsed": "{...}",
232+ "index": 0,
233+ "mode": "check",
234+ "package_id": "path+[ROOTURL]/foo/bar#0.0.0",
235+ "reason": "unit-started",
236+ "run_id": "[..]T[..]Z-[..]",
237+ "target": {
238+ "kind": "lib",
239+ "name": "bar"
240+ },
241+ "timestamp": "[..]T[..]Z"
242+ },
243+ {
244+ "elapsed": "{...}",
245+ "index": 0,
246+ "reason": "unit-section-started",
247+ "run_id": "[..]T[..]Z-[..]",
248+ "section": "codegen",
249+ "timestamp": "[..]T[..]Z"
250+ },
251+ {
252+ "elapsed": "{...}",
253+ "index": 0,
254+ "reason": "unit-rmeta-finished",
255+ "run_id": "[..]T[..]Z-[..]",
256+ "timestamp": "[..]T[..]Z"
257+ },
258+ {
259+ "elapsed": "{...}",
260+ "index": 0,
261+ "reason": "unit-section-finished",
262+ "run_id": "[..]T[..]Z-[..]",
263+ "section": "codegen",
264+ "timestamp": "[..]T[..]Z"
265+ },
266+ {
267+ "elapsed": "{...}",
268+ "index": 0,
269+ "reason": "unit-section-started",
270+ "run_id": "[..]T[..]Z-[..]",
271+ "section": "link",
272+ "timestamp": "[..]T[..]Z"
273+ },
274+ {
275+ "elapsed": "{...}",
276+ "index": 0,
277+ "reason": "unit-section-finished",
278+ "run_id": "[..]T[..]Z-[..]",
279+ "section": "link",
280+ "timestamp": "[..]T[..]Z"
281+ },
282+ {
283+ "elapsed": "{...}",
284+ "index": 0,
285+ "reason": "unit-finished",
286+ "run_id": "[..]T[..]Z-[..]",
287+ "timestamp": "[..]T[..]Z",
288+ "unlocked": [
289+ 1
290+ ]
291+ },
292+ {
293+ "elapsed": "{...}",
294+ "index": 1,
295+ "mode": "check",
296+ "package_id": "path+[ROOTURL]/foo#0.0.0",
297+ "reason": "unit-started",
298+ "run_id": "[..]T[..]Z-[..]",
299+ "target": {
300+ "kind": "bin",
301+ "name": "foo"
302+ },
303+ "timestamp": "[..]T[..]Z"
304+ },
305+ {
306+ "elapsed": "{...}",
307+ "index": 1,
308+ "reason": "unit-section-started",
309+ "run_id": "[..]T[..]Z-[..]",
310+ "section": "codegen",
311+ "timestamp": "[..]T[..]Z"
312+ },
313+ {
314+ "elapsed": "{...}",
315+ "index": 1,
316+ "reason": "unit-rmeta-finished",
317+ "run_id": "[..]T[..]Z-[..]",
318+ "timestamp": "[..]T[..]Z"
319+ },
320+ {
321+ "elapsed": "{...}",
322+ "index": 1,
323+ "reason": "unit-section-finished",
324+ "run_id": "[..]T[..]Z-[..]",
325+ "section": "codegen",
326+ "timestamp": "[..]T[..]Z"
327+ },
328+ {
329+ "elapsed": "{...}",
330+ "index": 1,
331+ "reason": "unit-section-started",
332+ "run_id": "[..]T[..]Z-[..]",
333+ "section": "link",
334+ "timestamp": "[..]T[..]Z"
335+ },
336+ {
337+ "elapsed": "{...}",
338+ "index": 1,
339+ "reason": "unit-section-finished",
340+ "run_id": "[..]T[..]Z-[..]",
341+ "section": "link",
342+ "timestamp": "[..]T[..]Z"
343+ },
170344 {
171345 "elapsed": "{...}",
172346 "index": 1,
173347 "reason": "unit-finished",
174- "rmeta_time": "{...}",
175348 "run_id": "[..]T[..]Z-[..]",
176349 "timestamp": "[..]T[..]Z"
177350 }
@@ -213,6 +386,10 @@ fn log_rebuild_reason_fresh_build() {
213386 "...": "{...}",
214387 "reason": "unit-started"
215388 },
389+ {
390+ "...": "{...}",
391+ "reason": "unit-rmeta-finished"
392+ },
216393 {
217394 "...": "{...}",
218395 "reason": "unit-finished"
@@ -280,6 +457,10 @@ fn log_rebuild_reason_file_changed() {
280457 "...": "{...}",
281458 "reason": "unit-started"
282459 },
460+ {
461+ "...": "{...}",
462+ "reason": "unit-rmeta-finished"
463+ },
283464 {
284465 "...": "{...}",
285466 "reason": "unit-finished"
0 commit comments