Skip to content

Commit 5fe24d0

Browse files
committed
List failed integration tests
1 parent 639aeb4 commit 5fe24d0

File tree

1 file changed

+34
-12
lines changed

1 file changed

+34
-12
lines changed

itest/rust/src/framework/runner.rs

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub struct IntegrationTests {
2222
total: i64,
2323
passed: i64,
2424
skipped: i64,
25+
failed_list: Vec<String>,
2526
focus_run: bool,
2627
}
2728

@@ -70,6 +71,7 @@ impl IntegrationTests {
7071
let clock = Instant::now();
7172
self.run_rust_tests(rust_tests, scene_tree);
7273
let rust_time = clock.elapsed();
74+
7375
let gdscript_time = if !focus_run {
7476
let extra_duration = self.run_gdscript_tests(gdscript_tests);
7577
Some((clock.elapsed() - rust_time) + extra_duration)
@@ -126,7 +128,7 @@ impl IntegrationTests {
126128
print_test_pre(test.name, test.file.to_string(), &mut last_file, false);
127129
let outcome = run_rust_test(&test, &ctx);
128130

129-
self.update_stats(&outcome);
131+
self.update_stats(&outcome, test.file, test.name);
130132
print_test_post(test.name, outcome);
131133
}
132134
}
@@ -139,7 +141,7 @@ impl IntegrationTests {
139141
let test_file = get_property(&test, "suite_name");
140142
let test_case = get_property(&test, "method_name");
141143

142-
print_test_pre(&test_case, test_file, &mut last_file, true);
144+
print_test_pre(&test_case, test_file.clone(), &mut last_file, true);
143145
let result = test.call("run", &[]);
144146
// In case a test needs to disable error messages to ensure it runs properly.
145147
Engine::singleton().set_print_error_messages(true);
@@ -155,7 +157,7 @@ impl IntegrationTests {
155157
}
156158
let outcome = TestOutcome::from_bool(success);
157159

158-
self.update_stats(&outcome);
160+
self.update_stats(&outcome, &test_file, &test_case);
159161
print_test_post(&test_case, outcome);
160162
}
161163
extra_duration
@@ -202,6 +204,20 @@ impl IntegrationTests {
202204
println!(" Time: {rust_time:.2}s.");
203205
}
204206

207+
if !all_passed {
208+
println!("\n Failed tests:");
209+
let max = 10;
210+
for test in self.failed_list.iter().take(max) {
211+
println!(" * {test}");
212+
}
213+
214+
if self.failed_list.len() > max {
215+
println!(" * ... and {} more.", self.failed_list.len() - max);
216+
}
217+
218+
println!();
219+
}
220+
205221
if focused_run && !allow_focus {
206222
println!(" {FMT_YELLOW}Focus run disallowed; return failure.{FMT_END}");
207223
false
@@ -229,11 +245,15 @@ impl IntegrationTests {
229245

230246
fn conclude_benchmarks(&self) {}
231247

232-
fn update_stats(&mut self, outcome: &TestOutcome) {
248+
fn update_stats(&mut self, outcome: &TestOutcome, test_file: &str, test_name: &str) {
233249
self.total += 1;
234250
match outcome {
235251
TestOutcome::Passed => self.passed += 1,
236-
TestOutcome::Failed => {}
252+
TestOutcome::Failed => self.failed_list.push(format!(
253+
"{} > {}",
254+
extract_file_subtitle(test_file),
255+
test_name
256+
)),
237257
TestOutcome::Skipped => self.skipped += 1,
238258
}
239259
}
@@ -281,19 +301,21 @@ fn print_file_header(file: String, last_file: &mut Option<String>) {
281301
.map_or(true, |last_file| last_file != &file);
282302

283303
if print_file {
284-
let file_subtitle = if let Some(sep_pos) = file.rfind(&['/', '\\']) {
285-
&file[sep_pos + 1..]
286-
} else {
287-
file.as_str()
288-
};
289-
290-
println!("\n {file_subtitle}:");
304+
println!("\n {}:", extract_file_subtitle(&file));
291305
}
292306

293307
// State update for file-category-print
294308
*last_file = Some(file);
295309
}
296310

311+
fn extract_file_subtitle(file: &str) -> &str {
312+
if let Some(sep_pos) = file.rfind(&['/', '\\']) {
313+
&file[sep_pos + 1..]
314+
} else {
315+
file
316+
}
317+
}
318+
297319
/// Prints a test name and its outcome.
298320
///
299321
/// Note that this is run after a test run, so stdout/stderr output during the test will be printed before.

0 commit comments

Comments
 (0)