@@ -51,6 +51,7 @@ impl BuildMetrics {
51
51
duration_excluding_children_sec : Duration :: ZERO ,
52
52
53
53
children : Vec :: new ( ) ,
54
+ tests : Vec :: new ( ) ,
54
55
} ) ;
55
56
}
56
57
@@ -72,6 +73,16 @@ impl BuildMetrics {
72
73
}
73
74
}
74
75
76
+ pub ( crate ) fn record_test ( & self , name : & str , outcome : TestOutcome ) {
77
+ let mut state = self . state . borrow_mut ( ) ;
78
+ state
79
+ . running_steps
80
+ . last_mut ( )
81
+ . unwrap ( )
82
+ . tests
83
+ . push ( Test { name : name. to_string ( ) , outcome } ) ;
84
+ }
85
+
75
86
fn collect_stats ( & self , state : & mut MetricsState ) {
76
87
let step = state. running_steps . last_mut ( ) . unwrap ( ) ;
77
88
@@ -125,6 +136,14 @@ impl BuildMetrics {
125
136
}
126
137
127
138
fn prepare_json_step ( & self , step : StepMetrics ) -> JsonNode {
139
+ let mut children = Vec :: new ( ) ;
140
+ children. extend ( step. children . into_iter ( ) . map ( |child| self . prepare_json_step ( child) ) ) ;
141
+ children. extend (
142
+ step. tests
143
+ . into_iter ( )
144
+ . map ( |test| JsonNode :: Test { name : test. name , outcome : test. outcome } ) ,
145
+ ) ;
146
+
128
147
JsonNode :: RustbuildStep {
129
148
type_ : step. type_ ,
130
149
debug_repr : step. debug_repr ,
@@ -135,11 +154,7 @@ impl BuildMetrics {
135
154
/ step. duration_excluding_children_sec . as_secs_f64 ( ) ,
136
155
} ,
137
156
138
- children : step
139
- . children
140
- . into_iter ( )
141
- . map ( |child| self . prepare_json_step ( child) )
142
- . collect ( ) ,
157
+ children,
143
158
}
144
159
}
145
160
}
@@ -161,6 +176,12 @@ struct StepMetrics {
161
176
duration_excluding_children_sec : Duration ,
162
177
163
178
children : Vec < StepMetrics > ,
179
+ tests : Vec < Test > ,
180
+ }
181
+
182
+ struct Test {
183
+ name : String ,
184
+ outcome : TestOutcome ,
164
185
}
165
186
166
187
#[ derive( Serialize , Deserialize ) ]
@@ -190,6 +211,19 @@ enum JsonNode {
190
211
191
212
children : Vec < JsonNode > ,
192
213
} ,
214
+ Test {
215
+ name : String ,
216
+ #[ serde( flatten) ]
217
+ outcome : TestOutcome ,
218
+ } ,
219
+ }
220
+
221
+ #[ derive( Serialize , Deserialize ) ]
222
+ #[ serde( tag = "outcome" , rename_all = "snake_case" ) ]
223
+ pub ( crate ) enum TestOutcome {
224
+ Passed ,
225
+ Failed ,
226
+ Ignored { ignore_reason : Option < String > } ,
193
227
}
194
228
195
229
#[ derive( Serialize , Deserialize ) ]
0 commit comments