File tree 2 files changed +14
-3
lines changed
2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -171,16 +171,24 @@ pub fn passes_filter(filters: &[String], test_name: &str) -> bool {
171
171
172
172
// ----------------------------------------------------------------------------------------------------------------------------------------------
173
173
// Toolbox for tests
174
+
175
+ /// Swaps panic hooks, to disable printing during expected panics. Also disables gdext's panic printing.
174
176
pub fn suppress_panic_log < R > ( callback : impl FnOnce ( ) -> R ) -> R {
175
- // Exchange panic hook, to disable printing during expected panics. Also disable gdext's panic printing.
177
+ // DISABLE following lines to *temporarily* debug panics.
178
+ // Note that they currently print "itest `{}` failed", even if the test doesn't fail (which isn't usually relevant in suppressed mode).
176
179
let prev_hook = panic:: take_hook ( ) ;
177
180
panic:: set_hook ( Box :: new (
178
181
|_panic_info| { /* suppress panic hook; do nothing */ } ,
179
182
) ) ;
183
+
184
+ // Keep following lines.
180
185
let prev_print_level = godot:: private:: set_error_print_level ( 0 ) ;
181
186
let res = callback ( ) ;
182
- panic:: set_hook ( prev_hook) ;
183
187
godot:: private:: set_error_print_level ( prev_print_level) ;
188
+
189
+ // DISABLE following line to *temporarily* debug panics.
190
+ panic:: set_hook ( prev_hook) ;
191
+
184
192
res
185
193
}
186
194
Original file line number Diff line number Diff line change @@ -444,8 +444,11 @@ fn run_rust_test(test: &RustTestCase, ctx: &TestContext) -> TestOutcome {
444
444
return TestOutcome :: Skipped ;
445
445
}
446
446
447
- // Explicit type to prevent tests from returning a value
447
+ // This will appear in all panics, but those inside expect_panic() are suppressed.
448
+ // So the "itest failed" message will only appear for unexpected panics, where tests indeed fail.
448
449
let err_context = || format ! ( "itest `{}` failed" , test. name) ;
450
+
451
+ // Explicit type to prevent tests from returning a value.
449
452
let success: Result < ( ) , _ > = godot:: private:: handle_panic ( err_context, || ( test. function ) ( ctx) ) ;
450
453
451
454
TestOutcome :: from_bool ( success. is_ok ( ) )
You can’t perform that action at this time.
0 commit comments