44//! As this module requires additional dependencies not present during local builds, it's cfg'd
55//! away whenever the `build.metrics` config option is not set to `true`.
66
7- use crate :: builder:: Step ;
7+ use crate :: builder:: { Builder , Step } ;
88use crate :: util:: t;
99use crate :: Build ;
1010use serde_derive:: { Deserialize , Serialize } ;
@@ -33,7 +33,12 @@ impl BuildMetrics {
3333 BuildMetrics { state }
3434 }
3535
36- pub ( crate ) fn enter_step < S : Step > ( & self , step : & S ) {
36+ pub ( crate ) fn enter_step < S : Step > ( & self , step : & S , builder : & Builder < ' _ > ) {
37+ // Do not record dry runs, as they'd be duplicates of the actual steps.
38+ if builder. config . dry_run ( ) {
39+ return ;
40+ }
41+
3742 let mut state = self . state . borrow_mut ( ) ;
3843
3944 // Consider all the stats gathered so far as the parent's.
@@ -56,7 +61,12 @@ impl BuildMetrics {
5661 } ) ;
5762 }
5863
59- pub ( crate ) fn exit_step ( & self ) {
64+ pub ( crate ) fn exit_step ( & self , builder : & Builder < ' _ > ) {
65+ // Do not record dry runs, as they'd be duplicates of the actual steps.
66+ if builder. config . dry_run ( ) {
67+ return ;
68+ }
69+
6070 let mut state = self . state . borrow_mut ( ) ;
6171
6272 self . collect_stats ( & mut * state) ;
@@ -74,7 +84,12 @@ impl BuildMetrics {
7484 }
7585 }
7686
77- pub ( crate ) fn record_test ( & self , name : & str , outcome : TestOutcome ) {
87+ pub ( crate ) fn record_test ( & self , name : & str , outcome : TestOutcome , builder : & Builder < ' _ > ) {
88+ // Do not record dry runs, as they'd be duplicates of the actual steps.
89+ if builder. config . dry_run ( ) {
90+ return ;
91+ }
92+
7893 let mut state = self . state . borrow_mut ( ) ;
7994 state
8095 . running_steps
0 commit comments