Skip to content

Commit b60aeb0

Browse files
committed
Stop passing --lib to cargo test
This overrides the test=false flag in Cargo.toml and it shouldn't be necessary as --tests is already passed.
1 parent 2af87ea commit b60aeb0

File tree

3 files changed

+15
-59
lines changed

3 files changed

+15
-59
lines changed

src/bootstrap/src/core/build_steps/test.rs

+15-50
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl Step for CrateBootstrap {
9090
);
9191

9292
let crate_name = path.rsplit_once('/').unwrap().1;
93-
run_cargo_test(cargo, &[], &[], crate_name, crate_name, bootstrap_host, builder);
93+
run_cargo_test(cargo, &[], &[], crate_name, bootstrap_host, builder);
9494
}
9595
}
9696

@@ -140,15 +140,7 @@ You can skip linkcheck with --skip src/tools/linkchecker"
140140
SourceType::InTree,
141141
&[],
142142
);
143-
run_cargo_test(
144-
cargo,
145-
&[],
146-
&[],
147-
"linkchecker",
148-
"linkchecker self tests",
149-
bootstrap_host,
150-
builder,
151-
);
143+
run_cargo_test(cargo, &[], &[], "linkchecker self tests", bootstrap_host, builder);
152144

153145
if builder.doc_tests == DocTests::No {
154146
return;
@@ -331,7 +323,7 @@ impl Step for Cargo {
331323
);
332324

333325
// NOTE: can't use `run_cargo_test` because we need to overwrite `PATH`
334-
let mut cargo = prepare_cargo_test(cargo, &[], &[], "cargo", self.host, builder);
326+
let mut cargo = prepare_cargo_test(cargo, &[], &[], self.host, builder);
335327

336328
// Don't run cross-compile tests, we may not have cross-compiled libstd libs
337329
// available.
@@ -417,7 +409,7 @@ impl Step for RustAnalyzer {
417409
cargo.env("SKIP_SLOW_TESTS", "1");
418410

419411
cargo.add_rustc_lib_path(builder);
420-
run_cargo_test(cargo, &[], &[], "rust-analyzer", "rust-analyzer", host, builder);
412+
run_cargo_test(cargo, &[], &[], "rust-analyzer", host, builder);
421413
}
422414
}
423415

@@ -466,7 +458,7 @@ impl Step for Rustfmt {
466458

467459
cargo.add_rustc_lib_path(builder);
468460

469-
run_cargo_test(cargo, &[], &[], "rustfmt", "rustfmt", host, builder);
461+
run_cargo_test(cargo, &[], &[], "rustfmt", host, builder);
470462
}
471463
}
472464

@@ -582,7 +574,7 @@ impl Step for Miri {
582574

583575
// We can NOT use `run_cargo_test` since Miri's integration tests do not use the usual test
584576
// harness and therefore do not understand the flags added by `add_flags_and_try_run_test`.
585-
let mut cargo = prepare_cargo_test(cargo, &[], &[], "miri", host, builder);
577+
let mut cargo = prepare_cargo_test(cargo, &[], &[], host, builder);
586578

587579
// miri tests need to know about the stage sysroot
588580
cargo.env("MIRI_SYSROOT", &miri_sysroot);
@@ -730,7 +722,7 @@ impl Step for CompiletestTest {
730722
&[],
731723
);
732724
cargo.allow_features("test");
733-
run_cargo_test(cargo, &[], &[], "compiletest", "compiletest self test", host, builder);
725+
run_cargo_test(cargo, &[], &[], "compiletest self test", host, builder);
734726
}
735727
}
736728

@@ -791,7 +783,7 @@ impl Step for Clippy {
791783
cargo.env("HOST_LIBS", host_libs);
792784

793785
cargo.add_rustc_lib_path(builder);
794-
let cargo = prepare_cargo_test(cargo, &[], &[], "clippy", host, builder);
786+
let cargo = prepare_cargo_test(cargo, &[], &[], host, builder);
795787

796788
let _guard = builder.msg_sysroot_tool(Kind::Test, compiler.stage, "clippy", host, host);
797789

@@ -1318,15 +1310,7 @@ impl Step for CrateRunMakeSupport {
13181310
&[],
13191311
);
13201312
cargo.allow_features("test");
1321-
run_cargo_test(
1322-
cargo,
1323-
&[],
1324-
&[],
1325-
"run-make-support",
1326-
"run-make-support self test",
1327-
host,
1328-
builder,
1329-
);
1313+
run_cargo_test(cargo, &[], &[], "run-make-support self test", host, builder);
13301314
}
13311315
}
13321316

@@ -1363,7 +1347,7 @@ impl Step for CrateBuildHelper {
13631347
&[],
13641348
);
13651349
cargo.allow_features("test");
1366-
run_cargo_test(cargo, &[], &[], "build_helper", "build_helper self test", host, builder);
1350+
run_cargo_test(cargo, &[], &[], "build_helper self test", host, builder);
13671351
}
13681352
}
13691353

@@ -2569,13 +2553,12 @@ fn run_cargo_test<'a>(
25692553
cargo: builder::Cargo,
25702554
libtest_args: &[&str],
25712555
crates: &[String],
2572-
primary_crate: &str,
25732556
description: impl Into<Option<&'a str>>,
25742557
target: TargetSelection,
25752558
builder: &Builder<'_>,
25762559
) -> bool {
25772560
let compiler = cargo.compiler();
2578-
let mut cargo = prepare_cargo_test(cargo, libtest_args, crates, primary_crate, target, builder);
2561+
let mut cargo = prepare_cargo_test(cargo, libtest_args, crates, target, builder);
25792562
let _time = helpers::timeit(builder);
25802563
let _group = description.into().and_then(|what| {
25812564
builder.msg_sysroot_tool(Kind::Test, compiler.stage, what, compiler.host, target)
@@ -2599,7 +2582,6 @@ fn prepare_cargo_test(
25992582
cargo: builder::Cargo,
26002583
libtest_args: &[&str],
26012584
crates: &[String],
2602-
primary_crate: &str,
26032585
target: TargetSelection,
26042586
builder: &Builder<'_>,
26052587
) -> BootstrapCommand {
@@ -2629,13 +2611,6 @@ fn prepare_cargo_test(
26292611
cargo.arg("--doc");
26302612
}
26312613
DocTests::No => {
2632-
let krate = &builder
2633-
.crates
2634-
.get(primary_crate)
2635-
.unwrap_or_else(|| panic!("missing crate {primary_crate}"));
2636-
if krate.has_lib {
2637-
cargo.arg("--lib");
2638-
}
26392614
cargo.args(["--bins", "--examples", "--tests", "--benches"]);
26402615
}
26412616
DocTests::Yes => {}
@@ -2814,7 +2789,6 @@ impl Step for Crate {
28142789
cargo,
28152790
&[],
28162791
&self.crates,
2817-
&self.crates[0],
28182792
&*crate_description(&self.crates),
28192793
target,
28202794
builder,
@@ -2911,15 +2885,7 @@ impl Step for CrateRustdoc {
29112885
dylib_path.insert(0, PathBuf::from(&*libdir));
29122886
cargo.env(dylib_path_var(), env::join_paths(&dylib_path).unwrap());
29132887

2914-
run_cargo_test(
2915-
cargo,
2916-
&[],
2917-
&["rustdoc:0.0.0".to_string()],
2918-
"rustdoc",
2919-
"rustdoc",
2920-
target,
2921-
builder,
2922-
);
2888+
run_cargo_test(cargo, &[], &["rustdoc:0.0.0".to_string()], "rustdoc", target, builder);
29232889
}
29242890
}
29252891

@@ -2976,7 +2942,6 @@ impl Step for CrateRustdocJsonTypes {
29762942
libtest_args,
29772943
&["rustdoc-json-types".to_string()],
29782944
"rustdoc-json-types",
2979-
"rustdoc-json-types",
29802945
target,
29812946
builder,
29822947
);
@@ -3156,7 +3121,7 @@ impl Step for Bootstrap {
31563121

31573122
// bootstrap tests are racy on directory creation so just run them one at a time.
31583123
// Since there's not many this shouldn't be a problem.
3159-
run_cargo_test(cargo, &["--test-threads=1"], &[], "bootstrap", None, host, builder);
3124+
run_cargo_test(cargo, &["--test-threads=1"], &[], None, host, builder);
31603125
}
31613126

31623127
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
@@ -3281,7 +3246,7 @@ impl Step for RustInstaller {
32813246
bootstrap_host,
32823247
bootstrap_host,
32833248
);
3284-
run_cargo_test(cargo, &[], &[], "installer", None, bootstrap_host, builder);
3249+
run_cargo_test(cargo, &[], &[], None, bootstrap_host, builder);
32853250

32863251
// We currently don't support running the test.sh script outside linux(?) environments.
32873252
// Eventually this should likely migrate to #[test]s in rust-installer proper rather than a
@@ -3672,7 +3637,7 @@ impl Step for TestFloatParse {
36723637
&[],
36733638
);
36743639

3675-
run_cargo_test(cargo_test, &[], &[], crate_name, crate_name, bootstrap_host, builder);
3640+
run_cargo_test(cargo_test, &[], &[], crate_name, bootstrap_host, builder);
36763641

36773642
// Run the actual parse tests.
36783643
let mut cargo_run = tool::prepare_tool_cargo(

src/bootstrap/src/core/metadata.rs

-8
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ struct Package {
2828
source: Option<String>,
2929
manifest_path: String,
3030
dependencies: Vec<Dependency>,
31-
targets: Vec<Target>,
3231
features: BTreeMap<String, Vec<String>>,
3332
}
3433

@@ -40,11 +39,6 @@ struct Dependency {
4039
source: Option<String>,
4140
}
4241

43-
#[derive(Debug, Deserialize)]
44-
struct Target {
45-
kind: Vec<String>,
46-
}
47-
4842
/// Collects and stores package metadata of each workspace members into `build`,
4943
/// by executing `cargo metadata` commands.
5044
pub fn build(build: &mut Build) {
@@ -59,12 +53,10 @@ pub fn build(build: &mut Build) {
5953
.filter(|dep| dep.source.is_none())
6054
.map(|dep| dep.name)
6155
.collect();
62-
let has_lib = package.targets.iter().any(|t| t.kind.iter().any(|k| k == "lib"));
6356
let krate = Crate {
6457
name: name.clone(),
6558
deps,
6659
path,
67-
has_lib,
6860
features: package.features.keys().cloned().collect(),
6961
};
7062
let relative_path = krate.local_path(build);

src/bootstrap/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ struct Crate {
185185
name: String,
186186
deps: HashSet<String>,
187187
path: PathBuf,
188-
has_lib: bool,
189188
features: Vec<String>,
190189
}
191190

0 commit comments

Comments
 (0)