mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Rollup merge of #137679 - bjorn3:coretests_improvements, r=jieyouxu,onur-ozkan
Various coretests improvements The first commit is not yet strictly necessary as directly testing libcore works though useless work, but will be necessary once https://github.com/rust-lang/rust/pull/136642 migrates the liballoc tests into a separate package. The second commit fixes https://github.com/rust-lang/rust/issues/137478 and ensures that coretests actually gets tested on all CI job. The third commit fixes an error that didn't get caught because coretests doesn't run on the wasm32 CI job.
This commit is contained in:
@@ -5,8 +5,6 @@
|
||||
use core::ops::{Range, RangeInclusive};
|
||||
use core::slice;
|
||||
|
||||
use rand::seq::IndexedRandom;
|
||||
|
||||
#[test]
|
||||
fn test_position() {
|
||||
let b = [1, 2, 3, 5, 5];
|
||||
@@ -1810,6 +1808,7 @@ fn select_nth_unstable() {
|
||||
use core::cmp::Ordering::{Equal, Greater, Less};
|
||||
|
||||
use rand::Rng;
|
||||
use rand::seq::IndexedRandom;
|
||||
|
||||
let mut rng = crate::test_rng();
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ fn run(self, builder: &Builder<'_>) {
|
||||
);
|
||||
|
||||
let crate_name = path.rsplit_once('/').unwrap().1;
|
||||
run_cargo_test(cargo, &[], &[], crate_name, crate_name, bootstrap_host, builder);
|
||||
run_cargo_test(cargo, &[], &[], crate_name, bootstrap_host, builder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,15 +140,7 @@ fn run(self, builder: &Builder<'_>) {
|
||||
SourceType::InTree,
|
||||
&[],
|
||||
);
|
||||
run_cargo_test(
|
||||
cargo,
|
||||
&[],
|
||||
&[],
|
||||
"linkchecker",
|
||||
"linkchecker self tests",
|
||||
bootstrap_host,
|
||||
builder,
|
||||
);
|
||||
run_cargo_test(cargo, &[], &[], "linkchecker self tests", bootstrap_host, builder);
|
||||
|
||||
if builder.doc_tests == DocTests::No {
|
||||
return;
|
||||
@@ -337,7 +329,7 @@ fn run(self, builder: &Builder<'_>) {
|
||||
);
|
||||
|
||||
// NOTE: can't use `run_cargo_test` because we need to overwrite `PATH`
|
||||
let mut cargo = prepare_cargo_test(cargo, &[], &[], "cargo", self.host, builder);
|
||||
let mut cargo = prepare_cargo_test(cargo, &[], &[], self.host, builder);
|
||||
|
||||
// Don't run cross-compile tests, we may not have cross-compiled libstd libs
|
||||
// available.
|
||||
@@ -423,7 +415,7 @@ fn run(self, builder: &Builder<'_>) {
|
||||
cargo.env("SKIP_SLOW_TESTS", "1");
|
||||
|
||||
cargo.add_rustc_lib_path(builder);
|
||||
run_cargo_test(cargo, &[], &[], "rust-analyzer", "rust-analyzer", host, builder);
|
||||
run_cargo_test(cargo, &[], &[], "rust-analyzer", host, builder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -472,7 +464,7 @@ fn run(self, builder: &Builder<'_>) {
|
||||
|
||||
cargo.add_rustc_lib_path(builder);
|
||||
|
||||
run_cargo_test(cargo, &[], &[], "rustfmt", "rustfmt", host, builder);
|
||||
run_cargo_test(cargo, &[], &[], "rustfmt", host, builder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -588,7 +580,7 @@ fn run(self, builder: &Builder<'_>) {
|
||||
|
||||
// We can NOT use `run_cargo_test` since Miri's integration tests do not use the usual test
|
||||
// harness and therefore do not understand the flags added by `add_flags_and_try_run_test`.
|
||||
let mut cargo = prepare_cargo_test(cargo, &[], &[], "miri", host, builder);
|
||||
let mut cargo = prepare_cargo_test(cargo, &[], &[], host, builder);
|
||||
|
||||
// miri tests need to know about the stage sysroot
|
||||
cargo.env("MIRI_SYSROOT", &miri_sysroot);
|
||||
@@ -736,7 +728,7 @@ fn run(self, builder: &Builder<'_>) {
|
||||
&[],
|
||||
);
|
||||
cargo.allow_features("test");
|
||||
run_cargo_test(cargo, &[], &[], "compiletest", "compiletest self test", host, builder);
|
||||
run_cargo_test(cargo, &[], &[], "compiletest self test", host, builder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -797,7 +789,7 @@ fn run(self, builder: &Builder<'_>) {
|
||||
cargo.env("HOST_LIBS", host_libs);
|
||||
|
||||
cargo.add_rustc_lib_path(builder);
|
||||
let cargo = prepare_cargo_test(cargo, &[], &[], "clippy", host, builder);
|
||||
let cargo = prepare_cargo_test(cargo, &[], &[], host, builder);
|
||||
|
||||
let _guard = builder.msg_sysroot_tool(Kind::Test, compiler.stage, "clippy", host, host);
|
||||
|
||||
@@ -1277,15 +1269,7 @@ fn run(self, builder: &Builder<'_>) {
|
||||
&[],
|
||||
);
|
||||
cargo.allow_features("test");
|
||||
run_cargo_test(
|
||||
cargo,
|
||||
&[],
|
||||
&[],
|
||||
"run-make-support",
|
||||
"run-make-support self test",
|
||||
host,
|
||||
builder,
|
||||
);
|
||||
run_cargo_test(cargo, &[], &[], "run-make-support self test", host, builder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1322,7 +1306,7 @@ fn run(self, builder: &Builder<'_>) {
|
||||
&[],
|
||||
);
|
||||
cargo.allow_features("test");
|
||||
run_cargo_test(cargo, &[], &[], "build_helper", "build_helper self test", host, builder);
|
||||
run_cargo_test(cargo, &[], &[], "build_helper self test", host, builder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2507,13 +2491,12 @@ fn run_cargo_test<'a>(
|
||||
cargo: builder::Cargo,
|
||||
libtest_args: &[&str],
|
||||
crates: &[String],
|
||||
primary_crate: &str,
|
||||
description: impl Into<Option<&'a str>>,
|
||||
target: TargetSelection,
|
||||
builder: &Builder<'_>,
|
||||
) -> bool {
|
||||
let compiler = cargo.compiler();
|
||||
let mut cargo = prepare_cargo_test(cargo, libtest_args, crates, primary_crate, target, builder);
|
||||
let mut cargo = prepare_cargo_test(cargo, libtest_args, crates, target, builder);
|
||||
let _time = helpers::timeit(builder);
|
||||
let _group = description.into().and_then(|what| {
|
||||
builder.msg_sysroot_tool(Kind::Test, compiler.stage, what, compiler.host, target)
|
||||
@@ -2537,7 +2520,6 @@ fn prepare_cargo_test(
|
||||
cargo: builder::Cargo,
|
||||
libtest_args: &[&str],
|
||||
crates: &[String],
|
||||
primary_crate: &str,
|
||||
target: TargetSelection,
|
||||
builder: &Builder<'_>,
|
||||
) -> BootstrapCommand {
|
||||
@@ -2567,13 +2549,6 @@ fn prepare_cargo_test(
|
||||
cargo.arg("--doc");
|
||||
}
|
||||
DocTests::No => {
|
||||
let krate = &builder
|
||||
.crates
|
||||
.get(primary_crate)
|
||||
.unwrap_or_else(|| panic!("missing crate {primary_crate}"));
|
||||
if krate.has_lib {
|
||||
cargo.arg("--lib");
|
||||
}
|
||||
cargo.args(["--bins", "--examples", "--tests", "--benches"]);
|
||||
}
|
||||
DocTests::Yes => {}
|
||||
@@ -2748,15 +2723,15 @@ fn run(self, builder: &Builder<'_>) {
|
||||
_ => panic!("can only test libraries"),
|
||||
};
|
||||
|
||||
run_cargo_test(
|
||||
cargo,
|
||||
&[],
|
||||
&self.crates,
|
||||
&self.crates[0],
|
||||
&*crate_description(&self.crates),
|
||||
target,
|
||||
builder,
|
||||
);
|
||||
let mut crates = self.crates.clone();
|
||||
// The core crate can't directly be tested. We could silently
|
||||
// ignore it, but adding it's own test crate is less confusing
|
||||
// for users. We still keep core itself for doctests.
|
||||
if crates.iter().any(|crate_| crate_ == "core") {
|
||||
crates.push("coretests".to_owned());
|
||||
}
|
||||
|
||||
run_cargo_test(cargo, &[], &crates, &*crate_description(&self.crates), target, builder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2849,15 +2824,7 @@ fn run(self, builder: &Builder<'_>) {
|
||||
dylib_path.insert(0, PathBuf::from(&*libdir));
|
||||
cargo.env(dylib_path_var(), env::join_paths(&dylib_path).unwrap());
|
||||
|
||||
run_cargo_test(
|
||||
cargo,
|
||||
&[],
|
||||
&["rustdoc:0.0.0".to_string()],
|
||||
"rustdoc",
|
||||
"rustdoc",
|
||||
target,
|
||||
builder,
|
||||
);
|
||||
run_cargo_test(cargo, &[], &["rustdoc:0.0.0".to_string()], "rustdoc", target, builder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2914,7 +2881,6 @@ fn run(self, builder: &Builder<'_>) {
|
||||
libtest_args,
|
||||
&["rustdoc-json-types".to_string()],
|
||||
"rustdoc-json-types",
|
||||
"rustdoc-json-types",
|
||||
target,
|
||||
builder,
|
||||
);
|
||||
@@ -3094,7 +3060,7 @@ fn run(self, builder: &Builder<'_>) {
|
||||
|
||||
// bootstrap tests are racy on directory creation so just run them one at a time.
|
||||
// Since there's not many this shouldn't be a problem.
|
||||
run_cargo_test(cargo, &["--test-threads=1"], &[], "bootstrap", None, host, builder);
|
||||
run_cargo_test(cargo, &["--test-threads=1"], &[], None, host, builder);
|
||||
}
|
||||
|
||||
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
||||
@@ -3219,7 +3185,7 @@ fn run(self, builder: &Builder<'_>) {
|
||||
bootstrap_host,
|
||||
bootstrap_host,
|
||||
);
|
||||
run_cargo_test(cargo, &[], &[], "installer", None, bootstrap_host, builder);
|
||||
run_cargo_test(cargo, &[], &[], None, bootstrap_host, builder);
|
||||
|
||||
// We currently don't support running the test.sh script outside linux(?) environments.
|
||||
// Eventually this should likely migrate to #[test]s in rust-installer proper rather than a
|
||||
@@ -3610,7 +3576,7 @@ fn run(self, builder: &Builder<'_>) {
|
||||
&[],
|
||||
);
|
||||
|
||||
run_cargo_test(cargo_test, &[], &[], crate_name, crate_name, bootstrap_host, builder);
|
||||
run_cargo_test(cargo_test, &[], &[], crate_name, bootstrap_host, builder);
|
||||
|
||||
// Run the actual parse tests.
|
||||
let mut cargo_run = tool::prepare_tool_cargo(
|
||||
|
||||
@@ -28,7 +28,6 @@ struct Package {
|
||||
source: Option<String>,
|
||||
manifest_path: String,
|
||||
dependencies: Vec<Dependency>,
|
||||
targets: Vec<Target>,
|
||||
features: BTreeMap<String, Vec<String>>,
|
||||
}
|
||||
|
||||
@@ -40,11 +39,6 @@ struct Dependency {
|
||||
source: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct Target {
|
||||
kind: Vec<String>,
|
||||
}
|
||||
|
||||
/// Collects and stores package metadata of each workspace members into `build`,
|
||||
/// by executing `cargo metadata` commands.
|
||||
pub fn build(build: &mut Build) {
|
||||
@@ -59,12 +53,10 @@ pub fn build(build: &mut Build) {
|
||||
.filter(|dep| dep.source.is_none())
|
||||
.map(|dep| dep.name)
|
||||
.collect();
|
||||
let has_lib = package.targets.iter().any(|t| t.kind.iter().any(|k| k == "lib"));
|
||||
let krate = Crate {
|
||||
name: name.clone(),
|
||||
deps,
|
||||
path,
|
||||
has_lib,
|
||||
features: package.features.keys().cloned().collect(),
|
||||
};
|
||||
let relative_path = krate.local_path(build);
|
||||
|
||||
@@ -185,7 +185,6 @@ struct Crate {
|
||||
name: String,
|
||||
deps: HashSet<String>,
|
||||
path: PathBuf,
|
||||
has_lib: bool,
|
||||
features: Vec<String>,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user