@@ -87,7 +87,7 @@ impl Step for CrateBootstrap {
87
87
&[],
88
88
);
89
89
let crate_name = path.rsplit_once('/').unwrap().1;
90
- run_cargo_test(cargo, &[], &[], crate_name, crate_name, compiler, bootstrap_host, builder);
90
+ run_cargo_test(cargo, &[], &[], crate_name, crate_name, bootstrap_host, builder);
91
91
}
92
92
}
93
93
@@ -143,7 +143,6 @@ You can skip linkcheck with --skip src/tools/linkchecker"
143
143
&[],
144
144
"linkchecker",
145
145
"linkchecker self tests",
146
- compiler,
147
146
bootstrap_host,
148
147
builder,
149
148
);
@@ -312,7 +311,7 @@ impl Step for Cargo {
312
311
);
313
312
314
313
// NOTE: can't use `run_cargo_test` because we need to overwrite `PATH`
315
- let mut cargo = prepare_cargo_test(cargo, &[], &[], "cargo", compiler, self.host, builder);
314
+ let mut cargo = prepare_cargo_test(cargo, &[], &[], "cargo", self.host, builder);
316
315
317
316
// Don't run cross-compile tests, we may not have cross-compiled libstd libs
318
317
// available.
@@ -397,7 +396,7 @@ impl Step for RustAnalyzer {
397
396
cargo.env("SKIP_SLOW_TESTS", "1");
398
397
399
398
cargo.add_rustc_lib_path(builder);
400
- run_cargo_test(cargo, &[], &[], "rust-analyzer", "rust-analyzer", compiler, host, builder);
399
+ run_cargo_test(cargo, &[], &[], "rust-analyzer", "rust-analyzer", host, builder);
401
400
}
402
401
}
403
402
@@ -445,7 +444,7 @@ impl Step for Rustfmt {
445
444
446
445
cargo.add_rustc_lib_path(builder);
447
446
448
- run_cargo_test(cargo, &[], &[], "rustfmt", "rustfmt", compiler, host, builder);
447
+ run_cargo_test(cargo, &[], &[], "rustfmt", "rustfmt", host, builder);
449
448
}
450
449
}
451
450
@@ -565,7 +564,7 @@ impl Step for Miri {
565
564
566
565
// We can NOT use `run_cargo_test` since Miri's integration tests do not use the usual test
567
566
// harness and therefore do not understand the flags added by `add_flags_and_try_run_test`.
568
- let mut cargo = prepare_cargo_test(cargo, &[], &[], "miri", host_compiler, host, builder);
567
+ let mut cargo = prepare_cargo_test(cargo, &[], &[], "miri", host, builder);
569
568
570
569
// miri tests need to know about the stage sysroot
571
570
cargo.env("MIRI_SYSROOT", &miri_sysroot);
@@ -713,16 +712,7 @@ impl Step for CompiletestTest {
713
712
&[],
714
713
);
715
714
cargo.allow_features("test");
716
- run_cargo_test(
717
- cargo,
718
- &[],
719
- &[],
720
- "compiletest",
721
- "compiletest self test",
722
- compiler,
723
- host,
724
- builder,
725
- );
715
+ run_cargo_test(cargo, &[], &[], "compiletest", "compiletest self test", host, builder);
726
716
}
727
717
}
728
718
@@ -769,7 +759,7 @@ impl Step for Clippy {
769
759
cargo.env("HOST_LIBS", host_libs);
770
760
771
761
cargo.add_rustc_lib_path(builder);
772
- let cargo = prepare_cargo_test(cargo, &[], &[], "clippy", compiler, host, builder);
762
+ let cargo = prepare_cargo_test(cargo, &[], &[], "clippy", host, builder);
773
763
774
764
let _guard = builder.msg_sysroot_tool(Kind::Test, compiler.stage, "clippy", host, host);
775
765
@@ -1294,7 +1284,6 @@ impl Step for CrateRunMakeSupport {
1294
1284
&[],
1295
1285
"run-make-support",
1296
1286
"run-make-support self test",
1297
- compiler,
1298
1287
host,
1299
1288
builder,
1300
1289
);
@@ -1334,16 +1323,7 @@ impl Step for CrateBuildHelper {
1334
1323
&[],
1335
1324
);
1336
1325
cargo.allow_features("test");
1337
- run_cargo_test(
1338
- cargo,
1339
- &[],
1340
- &[],
1341
- "build_helper",
1342
- "build_helper self test",
1343
- compiler,
1344
- host,
1345
- builder,
1346
- );
1326
+ run_cargo_test(cargo, &[], &[], "build_helper", "build_helper self test", host, builder);
1347
1327
}
1348
1328
}
1349
1329
@@ -2540,19 +2520,17 @@ impl Step for CrateLibrustc {
2540
2520
/// Given a `cargo test` subcommand, add the appropriate flags and run it.
2541
2521
///
2542
2522
/// Returns whether the test succeeded.
2543
- #[allow(clippy::too_many_arguments)] // FIXME: reduce the number of args and remove this.
2544
2523
fn run_cargo_test<'a>(
2545
- cargo: impl Into<BootstrapCommand> ,
2524
+ cargo: builder::Cargo ,
2546
2525
libtest_args: &[&str],
2547
2526
crates: &[String],
2548
2527
primary_crate: &str,
2549
2528
description: impl Into<Option<&'a str>>,
2550
- compiler: Compiler,
2551
2529
target: TargetSelection,
2552
2530
builder: &Builder<'_>,
2553
2531
) -> bool {
2554
- let mut cargo =
2555
- prepare_cargo_test(cargo, libtest_args, crates, primary_crate, compiler , target, builder);
2532
+ let compiler = cargo.compiler();
2533
+ let mut cargo = prepare_cargo_test(cargo, libtest_args, crates, primary_crate, target, builder);
2556
2534
let _time = helpers::timeit(builder);
2557
2535
let _group = description.into().and_then(|what| {
2558
2536
builder.msg_sysroot_tool(Kind::Test, compiler.stage, what, compiler.host, target)
@@ -2573,15 +2551,15 @@ fn run_cargo_test<'a>(
2573
2551
2574
2552
/// Given a `cargo test` subcommand, pass it the appropriate test flags given a `builder`.
2575
2553
fn prepare_cargo_test(
2576
- cargo: impl Into<BootstrapCommand> ,
2554
+ cargo: builder::Cargo ,
2577
2555
libtest_args: &[&str],
2578
2556
crates: &[String],
2579
2557
primary_crate: &str,
2580
- compiler: Compiler,
2581
2558
target: TargetSelection,
2582
2559
builder: &Builder<'_>,
2583
2560
) -> BootstrapCommand {
2584
- let mut cargo = cargo.into();
2561
+ let compiler = cargo.compiler();
2562
+ let mut cargo: BootstrapCommand = cargo.into();
2585
2563
2586
2564
// Propagate `--bless` if it has not already been set/unset
2587
2565
// Any tools that want to use this should bless if `RUSTC_BLESS` is set to
@@ -2793,7 +2771,6 @@ impl Step for Crate {
2793
2771
&self.crates,
2794
2772
&self.crates[0],
2795
2773
&*crate_description(&self.crates),
2796
- compiler,
2797
2774
target,
2798
2775
builder,
2799
2776
);
@@ -2895,7 +2872,6 @@ impl Step for CrateRustdoc {
2895
2872
&["rustdoc:0.0.0".to_string()],
2896
2873
"rustdoc",
2897
2874
"rustdoc",
2898
- compiler,
2899
2875
target,
2900
2876
builder,
2901
2877
);
@@ -2956,7 +2932,6 @@ impl Step for CrateRustdocJsonTypes {
2956
2932
&["rustdoc-json-types".to_string()],
2957
2933
"rustdoc-json-types",
2958
2934
"rustdoc-json-types",
2959
- compiler,
2960
2935
target,
2961
2936
builder,
2962
2937
);
@@ -3113,23 +3088,25 @@ impl Step for Bootstrap {
3113
3088
// Use `python -m unittest` manually if you want to pass arguments.
3114
3089
check_bootstrap.delay_failure().run(builder);
3115
3090
3116
- let mut cmd = command(&builder.initial_cargo);
3117
- cmd.arg("test")
3118
- .current_dir(builder.src.join("src/bootstrap"))
3119
- .env("RUSTFLAGS", "--cfg test -Cdebuginfo=2")
3091
+ let mut cargo = tool::prepare_tool_cargo(
3092
+ builder,
3093
+ compiler,
3094
+ Mode::ToolBootstrap,
3095
+ host,
3096
+ Kind::Test,
3097
+ "src/bootstrap",
3098
+ SourceType::InTree,
3099
+ &[],
3100
+ );
3101
+
3102
+ cargo
3103
+ .rustflag("-Cdebuginfo=2")
3120
3104
.env("CARGO_TARGET_DIR", builder.out.join("bootstrap"))
3121
- .env("RUSTC_BOOTSTRAP", "1")
3122
- .env("RUSTDOC", builder.rustdoc(compiler))
3123
- .env("RUSTC", &builder.initial_rustc);
3124
- if let Some(flags) = option_env!("RUSTFLAGS") {
3125
- // Use the same rustc flags for testing as for "normal" compilation,
3126
- // so that Cargo doesn’t recompile the entire dependency graph every time:
3127
- // https://github.com/rust-lang/rust/issues/49215
3128
- cmd.env("RUSTFLAGS", flags);
3129
- }
3105
+ .env("RUSTC_BOOTSTRAP", "1");
3106
+
3130
3107
// bootstrap tests are racy on directory creation so just run them one at a time.
3131
3108
// Since there's not many this shouldn't be a problem.
3132
- run_cargo_test(cmd , &["--test-threads=1"], &[], "bootstrap", None, compiler , host, builder);
3109
+ run_cargo_test(cargo , &["--test-threads=1"], &[], "bootstrap", None, host, builder);
3133
3110
}
3134
3111
3135
3112
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
@@ -3254,7 +3231,7 @@ impl Step for RustInstaller {
3254
3231
bootstrap_host,
3255
3232
bootstrap_host,
3256
3233
);
3257
- run_cargo_test(cargo, &[], &[], "installer", None, compiler, bootstrap_host, builder);
3234
+ run_cargo_test(cargo, &[], &[], "installer", None, bootstrap_host, builder);
3258
3235
3259
3236
// We currently don't support running the test.sh script outside linux(?) environments.
3260
3237
// Eventually this should likely migrate to #[test]s in rust-installer proper rather than a
@@ -3639,16 +3616,7 @@ impl Step for TestFloatParse {
3639
3616
&[],
3640
3617
);
3641
3618
3642
- run_cargo_test(
3643
- cargo_test,
3644
- &[],
3645
- &[],
3646
- crate_name,
3647
- crate_name,
3648
- compiler,
3649
- bootstrap_host,
3650
- builder,
3651
- );
3619
+ run_cargo_test(cargo_test, &[], &[], crate_name, crate_name, bootstrap_host, builder);
3652
3620
3653
3621
// Run the actual parse tests.
3654
3622
let mut cargo_run = tool::prepare_tool_cargo(
0 commit comments