@@ -459,7 +459,12 @@ fn run_test(
459
459
let stdin = child. stdin . as_mut ( ) . expect ( "Failed to open stdin" ) ;
460
460
stdin. write_all ( test. as_bytes ( ) ) . expect ( "could write out test sources" ) ;
461
461
}
462
- let output = child. wait_with_output ( ) . expect ( "Failed to read stdout" ) ;
462
+ let output = if is_multiple_tests {
463
+ let status = child. wait ( ) . expect ( "Failed to wait" ) ;
464
+ process:: Output { status, stdout : Vec :: new ( ) , stderr : Vec :: new ( ) }
465
+ } else {
466
+ child. wait_with_output ( ) . expect ( "Failed to read stdout" )
467
+ } ;
463
468
464
469
struct Bomb < ' a > ( & ' a str ) ;
465
470
impl Drop for Bomb < ' _ > {
@@ -540,17 +545,17 @@ fn run_test(
540
545
cmd. output ( )
541
546
} ;
542
547
match result {
543
- Err ( e) => return Err ( TestFailure :: ExecutionError ( e) ) ,
548
+ Err ( e) => Err ( TestFailure :: ExecutionError ( e) ) ,
544
549
Ok ( out) => {
545
550
if lang_string. should_panic && out. status . success ( ) {
546
- return Err ( TestFailure :: UnexpectedRunPass ) ;
551
+ Err ( TestFailure :: UnexpectedRunPass )
547
552
} else if !lang_string. should_panic && !out. status . success ( ) {
548
- return Err ( TestFailure :: ExecutionFailure ( out) ) ;
553
+ Err ( TestFailure :: ExecutionFailure ( out) )
554
+ } else {
555
+ Ok ( ( ) )
549
556
}
550
557
}
551
558
}
552
-
553
- Ok ( ( ) )
554
559
}
555
560
556
561
/// Converts a path intended to use as a command to absolute if it is
@@ -1275,11 +1280,14 @@ impl DocTestKinds {
1275
1280
doctest : DocTest ,
1276
1281
opts : & GlobalTestOptions ,
1277
1282
edition : Edition ,
1283
+ rustdoc_options : & RustdocOptions ,
1278
1284
unused_externs : & Arc < Mutex < Vec < UnusedExterns > > > ,
1279
1285
) {
1280
1286
if doctest. failed_ast
1281
1287
|| doctest. lang_string . compile_fail
1282
1288
|| doctest. lang_string . test_harness
1289
+ || rustdoc_options. nocapture
1290
+ || rustdoc_options. test_args . iter ( ) . any ( |arg| arg == "--show-output" )
1283
1291
|| doctest. crate_attrs . contains ( "#![no_std]" )
1284
1292
{
1285
1293
self . standalone . push ( doctest. generate_test_desc_and_fn (
@@ -1305,6 +1313,7 @@ impl DocTestKinds {
1305
1313
}
1306
1314
let Self { mut standalone, others } = self ;
1307
1315
let mut ran_edition_tests = 0 ;
1316
+ let mut nb_errors = 0 ;
1308
1317
1309
1318
for ( edition, mut doctests) in others {
1310
1319
doctests. sort_by ( |a, b| a. name . cmp ( & b. name ) ) ;
@@ -1347,7 +1356,7 @@ fn main() {{
1347
1356
}}" ,
1348
1357
)
1349
1358
. unwrap ( ) ;
1350
- if let Err ( TestFailure :: CompileError ) = run_test (
1359
+ let ret = run_test (
1351
1360
output,
1352
1361
supports_color,
1353
1362
None ,
@@ -1358,7 +1367,8 @@ fn main() {{
1358
1367
edition,
1359
1368
|_: UnusedExterns | { } ,
1360
1369
false ,
1361
- ) {
1370
+ ) ;
1371
+ if let Err ( TestFailure :: CompileError ) = ret {
1362
1372
// We failed to compile all compatible tests as one so we push them into the
1363
1373
// "standalone" doctests.
1364
1374
debug ! ( "Failed to compile compatible doctests for edition {edition} all at once" ) ;
@@ -1371,13 +1381,20 @@ fn main() {{
1371
1381
}
1372
1382
} else {
1373
1383
ran_edition_tests += 1 ;
1384
+ if ret. is_err ( ) {
1385
+ nb_errors += 1 ;
1386
+ }
1374
1387
}
1375
1388
}
1376
1389
1377
1390
if ran_edition_tests == 0 || !standalone. is_empty ( ) {
1378
1391
standalone. sort_by ( |a, b| a. desc . name . as_slice ( ) . cmp ( & b. desc . name . as_slice ( ) ) ) ;
1379
1392
test:: test_main ( & test_args, standalone, None ) ;
1380
1393
}
1394
+ if nb_errors != 0 {
1395
+ // libtest::ERROR_EXIT_CODE is not public but it's the same value.
1396
+ std:: process:: exit ( 101 ) ;
1397
+ }
1381
1398
}
1382
1399
}
1383
1400
@@ -1538,7 +1555,13 @@ impl Tester for Collector {
1538
1555
path,
1539
1556
no_run,
1540
1557
) ;
1541
- self . tests . add_doctest ( doctest, & opts, edition, & self . unused_extern_reports ) ;
1558
+ self . tests . add_doctest (
1559
+ doctest,
1560
+ & opts,
1561
+ edition,
1562
+ & self . rustdoc_options ,
1563
+ & self . unused_extern_reports ,
1564
+ ) ;
1542
1565
}
1543
1566
1544
1567
fn get_line ( & self ) -> usize {
0 commit comments