@@ -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 ( & [ ] ) ;
@@ -300,7 +305,7 @@ impl Step for Cargo {
300
305
) ;
301
306
302
307
// NOTE: can't use `run_cargo_test` because we need to overwrite `PATH`
303
- let mut cargo = prepare_cargo_test ( cargo, & [ ] , & [ ] , compiler, self . host , builder) ;
308
+ let mut cargo = prepare_cargo_test ( cargo, & [ ] , & [ ] , "cargo" , compiler, self . host , builder) ;
304
309
305
310
// Don't run cross-compile tests, we may not have cross-compiled libstd libs
306
311
// available.
@@ -368,7 +373,7 @@ impl Step for RustAnalyzer {
368
373
cargo. env ( "SKIP_SLOW_TESTS" , "1" ) ;
369
374
370
375
cargo. add_rustc_lib_path ( builder, compiler) ;
371
- run_cargo_test ( cargo, & [ ] , & [ ] , compiler, host, builder) ;
376
+ run_cargo_test ( cargo, & [ ] , & [ ] , "rust-analyzer" , compiler, host, builder) ;
372
377
}
373
378
}
374
379
@@ -417,7 +422,7 @@ impl Step for Rustfmt {
417
422
418
423
cargo. add_rustc_lib_path ( builder, compiler) ;
419
424
420
- run_cargo_test ( cargo, & [ ] , & [ ] , compiler, host, builder) ;
425
+ run_cargo_test ( cargo, & [ ] , & [ ] , "rustfmt" , compiler, host, builder) ;
421
426
}
422
427
}
423
428
@@ -465,7 +470,7 @@ impl Step for RustDemangler {
465
470
cargo. env ( "RUST_DEMANGLER_DRIVER_PATH" , rust_demangler) ;
466
471
cargo. add_rustc_lib_path ( builder, compiler) ;
467
472
468
- run_cargo_test ( cargo, & [ ] , & [ ] , compiler, host, builder) ;
473
+ run_cargo_test ( cargo, & [ ] , & [ ] , "rust-demangler" , compiler, host, builder) ;
469
474
}
470
475
}
471
476
@@ -602,7 +607,7 @@ impl Step for Miri {
602
607
603
608
// This can NOT be `run_cargo_test` since the Miri test runner
604
609
// does not understand the flags added by `add_flags_and_try_run_test`.
605
- let mut cargo = prepare_cargo_test ( cargo, & [ ] , & [ ] , compiler, target, builder) ;
610
+ let mut cargo = prepare_cargo_test ( cargo, & [ ] , & [ ] , "miri" , compiler, target, builder) ;
606
611
{
607
612
let _time = util:: timeit ( & builder) ;
608
613
builder. run ( & mut cargo) ;
@@ -679,7 +684,7 @@ impl Step for CompiletestTest {
679
684
& [ ] ,
680
685
) ;
681
686
cargo. allow_features ( "test" ) ;
682
- run_cargo_test ( cargo, & [ ] , & [ ] , compiler, host, builder) ;
687
+ run_cargo_test ( cargo, & [ ] , & [ ] , "compiletest" , compiler, host, builder) ;
683
688
}
684
689
}
685
690
@@ -722,17 +727,13 @@ impl Step for Clippy {
722
727
& [ ] ,
723
728
) ;
724
729
725
- if !builder. fail_fast {
726
- cargo. arg ( "--no-fail-fast" ) ;
727
- }
728
-
729
730
cargo. env ( "RUSTC_TEST_SUITE" , builder. rustc ( compiler) ) ;
730
731
cargo. env ( "RUSTC_LIB_PATH" , builder. rustc_libdir ( compiler) ) ;
731
732
let host_libs = builder. stage_out ( compiler, Mode :: ToolRustc ) . join ( builder. cargo_dir ( ) ) ;
732
733
cargo. env ( "HOST_LIBS" , host_libs) ;
733
734
734
735
cargo. add_rustc_lib_path ( builder, compiler) ;
735
- let mut cargo = prepare_cargo_test ( cargo, & [ ] , & [ ] , compiler, host, builder) ;
736
+ let mut cargo = prepare_cargo_test ( cargo, & [ ] , & [ ] , "clippy" , compiler, host, builder) ;
736
737
737
738
if builder. try_run ( & mut cargo) {
738
739
// The tests succeeded; nothing to do.
@@ -2048,11 +2049,13 @@ fn run_cargo_test(
2048
2049
cargo : impl Into < Command > ,
2049
2050
libtest_args : & [ & str ] ,
2050
2051
crates : & [ Interned < String > ] ,
2052
+ primary_crate : & str ,
2051
2053
compiler : Compiler ,
2052
2054
target : TargetSelection ,
2053
2055
builder : & Builder < ' _ > ,
2054
2056
) -> bool {
2055
- let mut cargo = prepare_cargo_test ( cargo, libtest_args, crates, compiler, target, builder) ;
2057
+ let mut cargo =
2058
+ prepare_cargo_test ( cargo, libtest_args, crates, primary_crate, compiler, target, builder) ;
2056
2059
let _time = util:: timeit ( & builder) ;
2057
2060
add_flags_and_try_run_tests ( builder, & mut cargo)
2058
2061
}
@@ -2062,6 +2065,7 @@ fn prepare_cargo_test(
2062
2065
cargo : impl Into < Command > ,
2063
2066
libtest_args : & [ & str ] ,
2064
2067
crates : & [ Interned < String > ] ,
2068
+ primary_crate : & str ,
2065
2069
compiler : Compiler ,
2066
2070
target : TargetSelection ,
2067
2071
builder : & Builder < ' _ > ,
@@ -2079,7 +2083,14 @@ fn prepare_cargo_test(
2079
2083
cargo. arg ( "--doc" ) ;
2080
2084
}
2081
2085
DocTests :: No => {
2082
- cargo. args ( & [ "--lib" , "--bins" , "--examples" , "--tests" , "--benches" ] ) ;
2086
+ let krate = & builder
2087
+ . crates
2088
+ . get ( & INTERNER . intern_str ( primary_crate) )
2089
+ . unwrap_or_else ( || panic ! ( "missing crate {primary_crate}" ) ) ;
2090
+ if krate. has_lib {
2091
+ cargo. arg ( "--lib" ) ;
2092
+ }
2093
+ cargo. args ( & [ "--bins" , "--examples" , "--tests" , "--benches" ] ) ;
2083
2094
}
2084
2095
DocTests :: Yes => { }
2085
2096
}
@@ -2191,7 +2202,7 @@ impl Step for Crate {
2191
2202
compiler. host ,
2192
2203
target,
2193
2204
) ;
2194
- run_cargo_test ( cargo, & [ ] , & self . crates , compiler, target, builder) ;
2205
+ run_cargo_test ( cargo, & [ ] , & self . crates , & self . crates [ 0 ] , compiler, target, builder) ;
2195
2206
}
2196
2207
}
2197
2208
@@ -2284,6 +2295,7 @@ impl Step for CrateRustdoc {
2284
2295
cargo,
2285
2296
& [ ] ,
2286
2297
& [ INTERNER . intern_str ( "rustdoc:0.0.0" ) ] ,
2298
+ "rustdoc" ,
2287
2299
compiler,
2288
2300
target,
2289
2301
builder,
@@ -2345,6 +2357,7 @@ impl Step for CrateRustdocJsonTypes {
2345
2357
cargo,
2346
2358
libtest_args,
2347
2359
& [ INTERNER . intern_str ( "rustdoc-json-types" ) ] ,
2360
+ "rustdoc-json-types" ,
2348
2361
compiler,
2349
2362
target,
2350
2363
builder,
@@ -2504,7 +2517,7 @@ impl Step for Bootstrap {
2504
2517
}
2505
2518
// rustbuild tests are racy on directory creation so just run them one at a time.
2506
2519
// Since there's not many this shouldn't be a problem.
2507
- run_cargo_test ( cmd, & [ "--test-threads=1" ] , & [ ] , compiler, host, builder) ;
2520
+ run_cargo_test ( cmd, & [ "--test-threads=1" ] , & [ ] , "bootstrap" , compiler, host, builder) ;
2508
2521
}
2509
2522
2510
2523
fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
@@ -2617,7 +2630,7 @@ impl Step for RustInstaller {
2617
2630
SourceType :: InTree ,
2618
2631
& [ ] ,
2619
2632
) ;
2620
- try_run ( builder , & mut cargo . into ( ) ) ;
2633
+ run_cargo_test ( cargo , & [ ] , & [ ] , "installer" , compiler , bootstrap_host , builder ) ;
2621
2634
2622
2635
// We currently don't support running the test.sh script outside linux(?) environments.
2623
2636
// Eventually this should likely migrate to #[test]s in rust-installer proper rather than a
0 commit comments