@@ -103,7 +103,8 @@ impl Step for CrateBootstrap {
103
103
path,
104
104
bootstrap_host,
105
105
) ) ;
106
- run_cargo_test ( cargo, & [ ] , & [ ] , compiler, bootstrap_host, builder) ;
106
+ let crate_name = path. rsplit_once ( '/' ) . unwrap ( ) . 1 ;
107
+ run_cargo_test ( cargo, & [ ] , & [ ] , crate_name, compiler, bootstrap_host, builder) ;
107
108
}
108
109
}
109
110
@@ -152,7 +153,11 @@ You can skip linkcheck with --exclude src/tools/linkchecker"
152
153
SourceType :: InTree ,
153
154
& [ ] ,
154
155
) ;
155
- run_cargo_test ( cargo, & [ ] , & [ ] , compiler, bootstrap_host, builder) ;
156
+ run_cargo_test ( cargo, & [ ] , & [ ] , "linkchecker" , compiler, bootstrap_host, builder) ;
157
+
158
+ if builder. doc_tests == DocTests :: No {
159
+ return ;
160
+ }
156
161
157
162
// Build all the default documentation.
158
163
builder. default_doc ( & [ ] ) ;
@@ -307,7 +312,7 @@ impl Step for Cargo {
307
312
cargo. env ( "CARGO_TEST_DISABLE_NIGHTLY" , "1" ) ;
308
313
cargo. env ( "PATH" , & path_for_cargo ( builder, compiler) ) ;
309
314
310
- run_cargo_test ( cargo, & [ ] , & [ ] , compiler, self . host , builder) ;
315
+ run_cargo_test ( cargo, & [ ] , & [ ] , "cargo" , compiler, self . host , builder) ;
311
316
}
312
317
}
313
318
@@ -364,7 +369,7 @@ impl Step for RustAnalyzer {
364
369
cargo. env ( "SKIP_SLOW_TESTS" , "1" ) ;
365
370
366
371
cargo. add_rustc_lib_path ( builder, compiler) ;
367
- run_cargo_test ( cargo, & [ ] , & [ ] , compiler, host, builder) ;
372
+ run_cargo_test ( cargo, & [ ] , & [ ] , "rust-analyzer" , compiler, host, builder) ;
368
373
}
369
374
}
370
375
@@ -413,7 +418,7 @@ impl Step for Rustfmt {
413
418
414
419
cargo. add_rustc_lib_path ( builder, compiler) ;
415
420
416
- run_cargo_test ( cargo, & [ ] , & [ ] , compiler, host, builder) ;
421
+ run_cargo_test ( cargo, & [ ] , & [ ] , "rustfmt" , compiler, host, builder) ;
417
422
}
418
423
}
419
424
@@ -461,7 +466,7 @@ impl Step for RustDemangler {
461
466
cargo. env ( "RUST_DEMANGLER_DRIVER_PATH" , rust_demangler) ;
462
467
cargo. add_rustc_lib_path ( builder, compiler) ;
463
468
464
- run_cargo_test ( cargo, & [ ] , & [ ] , compiler, host, builder) ;
469
+ run_cargo_test ( cargo, & [ ] , & [ ] , "rust-demangler" , compiler, host, builder) ;
465
470
}
466
471
}
467
472
@@ -598,7 +603,7 @@ impl Step for Miri {
598
603
599
604
// This can NOT be `run_cargo_test` since the Miri test runner
600
605
// does not understand the flags added by `add_flags_and_try_run_test`.
601
- let mut cargo = prepare_cargo_test ( cargo, & [ ] , & [ ] , compiler, target, builder) ;
606
+ let mut cargo = prepare_cargo_test ( cargo, & [ ] , & [ ] , "miri" , compiler, target, builder) ;
602
607
{
603
608
let _time = util:: timeit ( & builder) ;
604
609
builder. run ( & mut cargo) ;
@@ -675,7 +680,7 @@ impl Step for CompiletestTest {
675
680
& [ ] ,
676
681
) ;
677
682
cargo. allow_features ( "test" ) ;
678
- run_cargo_test ( cargo, & [ ] , & [ ] , compiler, host, builder) ;
683
+ run_cargo_test ( cargo, & [ ] , & [ ] , "compiletest" , compiler, host, builder) ;
679
684
}
680
685
}
681
686
@@ -718,17 +723,13 @@ impl Step for Clippy {
718
723
& [ ] ,
719
724
) ;
720
725
721
- if !builder. fail_fast {
722
- cargo. arg ( "--no-fail-fast" ) ;
723
- }
724
-
725
726
cargo. env ( "RUSTC_TEST_SUITE" , builder. rustc ( compiler) ) ;
726
727
cargo. env ( "RUSTC_LIB_PATH" , builder. rustc_libdir ( compiler) ) ;
727
728
let host_libs = builder. stage_out ( compiler, Mode :: ToolRustc ) . join ( builder. cargo_dir ( ) ) ;
728
729
cargo. env ( "HOST_LIBS" , host_libs) ;
729
730
730
731
cargo. add_rustc_lib_path ( builder, compiler) ;
731
- let mut cargo = prepare_cargo_test ( cargo, & [ ] , & [ ] , compiler, host, builder) ;
732
+ let mut cargo = prepare_cargo_test ( cargo, & [ ] , & [ ] , "clippy" , compiler, host, builder) ;
732
733
733
734
if builder. try_run ( & mut cargo) {
734
735
// The tests succeeded; nothing to do.
@@ -2037,11 +2038,13 @@ fn run_cargo_test(
2037
2038
cargo : impl Into < Command > ,
2038
2039
libtest_args : & [ & str ] ,
2039
2040
crates : & [ Interned < String > ] ,
2041
+ primary_crate : & str ,
2040
2042
compiler : Compiler ,
2041
2043
target : TargetSelection ,
2042
2044
builder : & Builder < ' _ > ,
2043
2045
) -> bool {
2044
- let mut cargo = prepare_cargo_test ( cargo, libtest_args, crates, compiler, target, builder) ;
2046
+ let mut cargo =
2047
+ prepare_cargo_test ( cargo, libtest_args, crates, primary_crate, compiler, target, builder) ;
2045
2048
let _time = util:: timeit ( & builder) ;
2046
2049
add_flags_and_try_run_tests ( builder, & mut cargo)
2047
2050
}
@@ -2051,6 +2054,7 @@ fn prepare_cargo_test(
2051
2054
cargo : impl Into < Command > ,
2052
2055
libtest_args : & [ & str ] ,
2053
2056
crates : & [ Interned < String > ] ,
2057
+ primary_crate : & str ,
2054
2058
compiler : Compiler ,
2055
2059
target : TargetSelection ,
2056
2060
builder : & Builder < ' _ > ,
@@ -2068,7 +2072,14 @@ fn prepare_cargo_test(
2068
2072
cargo. arg ( "--doc" ) ;
2069
2073
}
2070
2074
DocTests :: No => {
2071
- cargo. args ( & [ "--lib" , "--bins" , "--examples" , "--tests" , "--benches" ] ) ;
2075
+ let krate = & builder
2076
+ . crates
2077
+ . get ( & INTERNER . intern_str ( primary_crate) )
2078
+ . unwrap_or_else ( || panic ! ( "missing crate {primary_crate}" ) ) ;
2079
+ if krate. has_lib {
2080
+ cargo. arg ( "--lib" ) ;
2081
+ }
2082
+ cargo. args ( & [ "--bins" , "--examples" , "--tests" , "--benches" ] ) ;
2072
2083
}
2073
2084
DocTests :: Yes => { }
2074
2085
}
@@ -2181,7 +2192,7 @@ impl Step for Crate {
2181
2192
& compiler. host,
2182
2193
target
2183
2194
) ) ;
2184
- run_cargo_test ( cargo, & [ ] , & self . crates , compiler, target, builder) ;
2195
+ run_cargo_test ( cargo, & [ ] , & self . crates , & self . crates [ 0 ] , compiler, target, builder) ;
2185
2196
}
2186
2197
}
2187
2198
@@ -2280,6 +2291,7 @@ impl Step for CrateRustdoc {
2280
2291
cargo,
2281
2292
& [ ] ,
2282
2293
& [ INTERNER . intern_str ( "rustdoc:0.0.0" ) ] ,
2294
+ "rustdoc" ,
2283
2295
compiler,
2284
2296
target,
2285
2297
builder,
@@ -2346,6 +2358,7 @@ impl Step for CrateRustdocJsonTypes {
2346
2358
cargo,
2347
2359
libtest_args,
2348
2360
& [ INTERNER . intern_str ( "rustdoc-json-types" ) ] ,
2361
+ "rustdoc-json-types" ,
2349
2362
compiler,
2350
2363
target,
2351
2364
builder,
@@ -2505,7 +2518,7 @@ impl Step for Bootstrap {
2505
2518
}
2506
2519
// rustbuild tests are racy on directory creation so just run them one at a time.
2507
2520
// Since there's not many this shouldn't be a problem.
2508
- run_cargo_test ( cmd, & [ "--test-threads=1" ] , & [ ] , compiler, host, builder) ;
2521
+ run_cargo_test ( cmd, & [ "--test-threads=1" ] , & [ ] , "bootstrap" , compiler, host, builder) ;
2509
2522
}
2510
2523
2511
2524
fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
@@ -2618,7 +2631,7 @@ impl Step for RustInstaller {
2618
2631
SourceType :: InTree ,
2619
2632
& [ ] ,
2620
2633
) ;
2621
- try_run ( builder , & mut cargo . into ( ) ) ;
2634
+ run_cargo_test ( cargo , & [ ] , & [ ] , "installer" , compiler , bootstrap_host , builder ) ;
2622
2635
2623
2636
// We currently don't support running the test.sh script outside linux(?) environments.
2624
2637
// Eventually this should likely migrate to #[test]s in rust-installer proper rather than a
0 commit comments