@@ -149,7 +149,7 @@ fn run_unit_tests(
149
149
unit : unit. clone ( ) ,
150
150
kind : test_kind,
151
151
} ;
152
- report_test_error ( ws, & options. compile_opts , & unit_err, e) ;
152
+ report_test_error ( ws, test_args , & options. compile_opts , & unit_err, e) ;
153
153
errors. push ( unit_err) ;
154
154
if !options. no_fail_fast {
155
155
return Err ( CliError :: code ( code) ) ;
@@ -275,7 +275,7 @@ fn run_doc_tests(
275
275
unit : unit. clone ( ) ,
276
276
kind : TestKind :: Doctest ,
277
277
} ;
278
- report_test_error ( ws, & options. compile_opts , & unit_err, e) ;
278
+ report_test_error ( ws, test_args , & options. compile_opts , & unit_err, e) ;
279
279
errors. push ( unit_err) ;
280
280
if !options. no_fail_fast {
281
281
return Err ( CliError :: code ( code) ) ;
@@ -407,6 +407,7 @@ fn no_fail_fast_err(
407
407
/// Displays an error on the console about a test failure.
408
408
fn report_test_error (
409
409
ws : & Workspace < ' _ > ,
410
+ test_args : & [ & str ] ,
410
411
opts : & ops:: CompileOptions ,
411
412
unit_err : & UnitTestError ,
412
413
test_error : anyhow:: Error ,
@@ -420,13 +421,23 @@ fn report_test_error(
420
421
let mut err = format_err ! ( "{}, to rerun pass `{}`" , which, unit_err. cli_args( ws, opts) ) ;
421
422
// Don't show "process didn't exit successfully" for simple errors.
422
423
// libtest exits with 101 for normal errors.
423
- let is_simple = test_error
424
+ let ( is_simple, executed ) = test_error
424
425
. downcast_ref :: < ProcessError > ( )
425
426
. and_then ( |proc_err| proc_err. code )
426
- . map_or ( false , |code| code == 101 ) ;
427
+ . map_or ( ( false , false ) , |code| ( code == 101 , true ) ) ;
428
+
427
429
if !is_simple {
428
430
err = test_error. context ( err) ;
429
431
}
430
432
431
433
crate :: display_error ( & err, & mut ws. config ( ) . shell ( ) ) ;
434
+
435
+ let harness: bool = unit_err. unit . target . harness ( ) ;
436
+ let nocapture: bool = test_args. contains ( & "--nocapture" ) ;
437
+
438
+ if !is_simple && executed && harness && !nocapture {
439
+ drop ( ws. config ( ) . shell ( ) . note (
440
+ "test exited abnormally; to see the full output pass --nocapture to the harness." ,
441
+ ) ) ;
442
+ }
432
443
}
0 commit comments