@@ -149,7 +149,7 @@ fn run_unit_tests(
149149 unit : unit. clone ( ) ,
150150 kind : test_kind,
151151 } ;
152- report_test_error ( ws, & options. compile_opts , & unit_err, e) ;
152+ report_test_error ( ws, test_args , & options. compile_opts , & unit_err, e) ;
153153 errors. push ( unit_err) ;
154154 if !options. no_fail_fast {
155155 return Err ( CliError :: code ( code) ) ;
@@ -275,7 +275,7 @@ fn run_doc_tests(
275275 unit : unit. clone ( ) ,
276276 kind : TestKind :: Doctest ,
277277 } ;
278- report_test_error ( ws, & options. compile_opts , & unit_err, e) ;
278+ report_test_error ( ws, test_args , & options. compile_opts , & unit_err, e) ;
279279 errors. push ( unit_err) ;
280280 if !options. no_fail_fast {
281281 return Err ( CliError :: code ( code) ) ;
@@ -407,6 +407,7 @@ fn no_fail_fast_err(
407407/// Displays an error on the console about a test failure.
408408fn report_test_error (
409409 ws : & Workspace < ' _ > ,
410+ test_args : & [ & str ] ,
410411 opts : & ops:: CompileOptions ,
411412 unit_err : & UnitTestError ,
412413 test_error : anyhow:: Error ,
@@ -420,13 +421,23 @@ fn report_test_error(
420421 let mut err = format_err ! ( "{}, to rerun pass `{}`" , which, unit_err. cli_args( ws, opts) ) ;
421422 // Don't show "process didn't exit successfully" for simple errors.
422423 // libtest exits with 101 for normal errors.
423- let is_simple = test_error
424+ let ( is_simple, executed ) = test_error
424425 . downcast_ref :: < ProcessError > ( )
425426 . and_then ( |proc_err| proc_err. code )
426- . map_or ( false , |code| code == 101 ) ;
427+ . map_or ( ( false , false ) , |code| ( code == 101 , true ) ) ;
428+
427429 if !is_simple {
428430 err = test_error. context ( err) ;
429431 }
430432
431433 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+ }
432443}
0 commit comments