Convert the rest of the test
Steps to run_cargo_test
This commit is contained in:
parent
107257eedc
commit
ff674c1664
@ -13,6 +13,7 @@ use std::process::{Command, Stdio};
|
|||||||
use crate::builder::crate_description;
|
use crate::builder::crate_description;
|
||||||
use crate::builder::{Builder, Compiler, Kind, RunConfig, ShouldRun, Step};
|
use crate::builder::{Builder, Compiler, Kind, RunConfig, ShouldRun, Step};
|
||||||
use crate::cache::Interned;
|
use crate::cache::Interned;
|
||||||
|
use crate::cache::INTERNER;
|
||||||
use crate::compile;
|
use crate::compile;
|
||||||
use crate::config::TargetSelection;
|
use crate::config::TargetSelection;
|
||||||
use crate::dist;
|
use crate::dist;
|
||||||
@ -85,7 +86,7 @@ impl Step for CrateJsonDocLint {
|
|||||||
SourceType::InTree,
|
SourceType::InTree,
|
||||||
&[],
|
&[],
|
||||||
);
|
);
|
||||||
add_flags_and_try_run_tests(builder, &mut cargo.into());
|
run_cargo_test(cargo, &[], &[], compiler, bootstrap_host, builder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,7 +112,7 @@ impl Step for SuggestTestsCrate {
|
|||||||
let bootstrap_host = builder.config.build;
|
let bootstrap_host = builder.config.build;
|
||||||
let compiler = builder.compiler(0, bootstrap_host);
|
let compiler = builder.compiler(0, bootstrap_host);
|
||||||
|
|
||||||
let suggest_tests = tool::prepare_tool_cargo(
|
let cargo = tool::prepare_tool_cargo(
|
||||||
builder,
|
builder,
|
||||||
compiler,
|
compiler,
|
||||||
Mode::ToolBootstrap,
|
Mode::ToolBootstrap,
|
||||||
@ -121,7 +122,7 @@ impl Step for SuggestTestsCrate {
|
|||||||
SourceType::InTree,
|
SourceType::InTree,
|
||||||
&[],
|
&[],
|
||||||
);
|
);
|
||||||
add_flags_and_try_run_tests(builder, &mut suggest_tests.into());
|
run_cargo_test(cargo, &[], &[], compiler, bootstrap_host, builder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,7 +171,7 @@ You can skip linkcheck with --exclude src/tools/linkchecker"
|
|||||||
SourceType::InTree,
|
SourceType::InTree,
|
||||||
&[],
|
&[],
|
||||||
);
|
);
|
||||||
add_flags_and_try_run_tests(builder, &mut cargo.into());
|
run_cargo_test(cargo, &[], &[], compiler, bootstrap_host, builder);
|
||||||
|
|
||||||
// Build all the default documentation.
|
// Build all the default documentation.
|
||||||
builder.default_doc(&[]);
|
builder.default_doc(&[]);
|
||||||
@ -306,7 +307,7 @@ impl Step for Cargo {
|
|||||||
let compiler = builder.compiler(self.stage, self.host);
|
let compiler = builder.compiler(self.stage, self.host);
|
||||||
|
|
||||||
builder.ensure(tool::Cargo { compiler, target: self.host });
|
builder.ensure(tool::Cargo { compiler, target: self.host });
|
||||||
let mut cargo = tool::prepare_tool_cargo(
|
let cargo = tool::prepare_tool_cargo(
|
||||||
builder,
|
builder,
|
||||||
compiler,
|
compiler,
|
||||||
Mode::ToolRustc,
|
Mode::ToolRustc,
|
||||||
@ -317,10 +318,8 @@ impl Step for Cargo {
|
|||||||
&[],
|
&[],
|
||||||
);
|
);
|
||||||
|
|
||||||
if !builder.fail_fast {
|
// NOTE: can't use `run_cargo_test` because we need to overwrite `PATH`
|
||||||
cargo.arg("--no-fail-fast");
|
let mut cargo = prepare_cargo_test(cargo, &[], &[], compiler, self.host, builder);
|
||||||
}
|
|
||||||
cargo.arg("--").args(builder.config.cmd.test_args());
|
|
||||||
|
|
||||||
// Don't run cross-compile tests, we may not have cross-compiled libstd libs
|
// Don't run cross-compile tests, we may not have cross-compiled libstd libs
|
||||||
// available.
|
// available.
|
||||||
@ -328,10 +327,10 @@ impl Step for Cargo {
|
|||||||
// Forcibly disable tests using nightly features since any changes to
|
// Forcibly disable tests using nightly features since any changes to
|
||||||
// those features won't be able to land.
|
// those features won't be able to land.
|
||||||
cargo.env("CARGO_TEST_DISABLE_NIGHTLY", "1");
|
cargo.env("CARGO_TEST_DISABLE_NIGHTLY", "1");
|
||||||
|
|
||||||
cargo.env("PATH", &path_for_cargo(builder, compiler));
|
cargo.env("PATH", &path_for_cargo(builder, compiler));
|
||||||
|
|
||||||
add_flags_and_try_run_tests(builder, &mut cargo.into());
|
let _time = util::timeit(&builder);
|
||||||
|
add_flags_and_try_run_tests(builder, &mut cargo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -388,9 +387,7 @@ impl Step for RustAnalyzer {
|
|||||||
cargo.env("SKIP_SLOW_TESTS", "1");
|
cargo.env("SKIP_SLOW_TESTS", "1");
|
||||||
|
|
||||||
cargo.add_rustc_lib_path(builder, compiler);
|
cargo.add_rustc_lib_path(builder, compiler);
|
||||||
cargo.arg("--").args(builder.config.cmd.test_args());
|
run_cargo_test(cargo, &[], &[], compiler, host, builder);
|
||||||
|
|
||||||
add_flags_and_try_run_tests(builder, &mut cargo.into());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -433,17 +430,13 @@ impl Step for Rustfmt {
|
|||||||
&[],
|
&[],
|
||||||
);
|
);
|
||||||
|
|
||||||
if !builder.fail_fast {
|
|
||||||
cargo.arg("--no-fail-fast");
|
|
||||||
}
|
|
||||||
|
|
||||||
let dir = testdir(builder, compiler.host);
|
let dir = testdir(builder, compiler.host);
|
||||||
t!(fs::create_dir_all(&dir));
|
t!(fs::create_dir_all(&dir));
|
||||||
cargo.env("RUSTFMT_TEST_DIR", dir);
|
cargo.env("RUSTFMT_TEST_DIR", dir);
|
||||||
|
|
||||||
cargo.add_rustc_lib_path(builder, compiler);
|
cargo.add_rustc_lib_path(builder, compiler);
|
||||||
|
|
||||||
add_flags_and_try_run_tests(builder, &mut cargo.into());
|
run_cargo_test(cargo, &[], &[], compiler, host, builder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -489,12 +482,9 @@ impl Step for RustDemangler {
|
|||||||
t!(fs::create_dir_all(&dir));
|
t!(fs::create_dir_all(&dir));
|
||||||
|
|
||||||
cargo.env("RUST_DEMANGLER_DRIVER_PATH", rust_demangler);
|
cargo.env("RUST_DEMANGLER_DRIVER_PATH", rust_demangler);
|
||||||
|
|
||||||
cargo.arg("--").args(builder.config.cmd.test_args());
|
|
||||||
|
|
||||||
cargo.add_rustc_lib_path(builder, compiler);
|
cargo.add_rustc_lib_path(builder, compiler);
|
||||||
|
|
||||||
add_flags_and_try_run_tests(builder, &mut cargo.into());
|
run_cargo_test(cargo, &[], &[], compiler, host, builder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -617,10 +607,6 @@ impl Step for Miri {
|
|||||||
);
|
);
|
||||||
cargo.add_rustc_lib_path(builder, compiler);
|
cargo.add_rustc_lib_path(builder, compiler);
|
||||||
|
|
||||||
if !builder.fail_fast {
|
|
||||||
cargo.arg("--no-fail-fast");
|
|
||||||
}
|
|
||||||
|
|
||||||
// miri tests need to know about the stage sysroot
|
// miri tests need to know about the stage sysroot
|
||||||
cargo.env("MIRI_SYSROOT", &miri_sysroot);
|
cargo.env("MIRI_SYSROOT", &miri_sysroot);
|
||||||
cargo.env("MIRI_HOST_SYSROOT", sysroot);
|
cargo.env("MIRI_HOST_SYSROOT", sysroot);
|
||||||
@ -632,13 +618,14 @@ impl Step for Miri {
|
|||||||
|
|
||||||
// Set the target.
|
// Set the target.
|
||||||
cargo.env("MIRI_TEST_TARGET", target.rustc_target_arg());
|
cargo.env("MIRI_TEST_TARGET", target.rustc_target_arg());
|
||||||
// Forward test filters.
|
|
||||||
cargo.arg("--").args(builder.config.cmd.test_args());
|
|
||||||
|
|
||||||
// This can NOT be `add_flags_and_try_run_tests` since the Miri test runner
|
// This can NOT be `run_cargo_test` since the Miri test runner
|
||||||
// does not understand those flags!
|
// does not understand the flags added by `add_flags_and_try_run_test`.
|
||||||
let mut cargo = Command::from(cargo);
|
let mut cargo = prepare_cargo_test(cargo, &[], &[], compiler, target, builder);
|
||||||
|
{
|
||||||
|
let _time = util::timeit(&builder);
|
||||||
builder.run(&mut cargo);
|
builder.run(&mut cargo);
|
||||||
|
}
|
||||||
|
|
||||||
// # Run `cargo miri test`.
|
// # Run `cargo miri test`.
|
||||||
// This is just a smoke test (Miri's own CI invokes this in a bunch of different ways and ensures
|
// This is just a smoke test (Miri's own CI invokes this in a bunch of different ways and ensures
|
||||||
@ -671,6 +658,7 @@ impl Step for Miri {
|
|||||||
cargo.env("RUST_BACKTRACE", "1");
|
cargo.env("RUST_BACKTRACE", "1");
|
||||||
|
|
||||||
let mut cargo = Command::from(cargo);
|
let mut cargo = Command::from(cargo);
|
||||||
|
let _time = util::timeit(&builder);
|
||||||
builder.run(&mut cargo);
|
builder.run(&mut cargo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -710,8 +698,7 @@ impl Step for CompiletestTest {
|
|||||||
&[],
|
&[],
|
||||||
);
|
);
|
||||||
cargo.allow_features("test");
|
cargo.allow_features("test");
|
||||||
|
run_cargo_test(cargo, &[], &[], compiler, host, builder);
|
||||||
add_flags_and_try_run_tests(builder, &mut cargo.into());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -763,11 +750,10 @@ impl Step for Clippy {
|
|||||||
let host_libs = builder.stage_out(compiler, Mode::ToolRustc).join(builder.cargo_dir());
|
let host_libs = builder.stage_out(compiler, Mode::ToolRustc).join(builder.cargo_dir());
|
||||||
cargo.env("HOST_LIBS", host_libs);
|
cargo.env("HOST_LIBS", host_libs);
|
||||||
|
|
||||||
cargo.arg("--").args(builder.config.cmd.test_args());
|
|
||||||
|
|
||||||
cargo.add_rustc_lib_path(builder, compiler);
|
cargo.add_rustc_lib_path(builder, compiler);
|
||||||
|
let mut cargo = prepare_cargo_test(cargo, &[], &[], compiler, host, builder);
|
||||||
|
|
||||||
if builder.try_run(&mut cargo.into()) {
|
if builder.try_run(&mut cargo) {
|
||||||
// The tests succeeded; nothing to do.
|
// The tests succeeded; nothing to do.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1195,7 +1181,7 @@ impl Step for TidySelfTest {
|
|||||||
SourceType::InTree,
|
SourceType::InTree,
|
||||||
&[],
|
&[],
|
||||||
);
|
);
|
||||||
add_flags_and_try_run_tests(builder, &mut cargo.into());
|
run_cargo_test(cargo, &[], &[], compiler, bootstrap_host, builder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2108,8 +2094,31 @@ impl Step for CrateLibrustc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Given a `cargo test` subcommand, pass it the appropriate test flags given a `builder`.
|
/// Given a `cargo test` subcommand, add the appropriate flags and run it.
|
||||||
fn run_cargo_test(cargo: impl Into<Command>, libtest_args: &[&str], crates: &[Interned<String>], compiler: Compiler, target: TargetSelection, builder: &Builder<'_>) {
|
///
|
||||||
|
/// Returns whether the test succeeded.
|
||||||
|
fn run_cargo_test(
|
||||||
|
cargo: impl Into<Command>,
|
||||||
|
libtest_args: &[&str],
|
||||||
|
crates: &[Interned<String>],
|
||||||
|
compiler: Compiler,
|
||||||
|
target: TargetSelection,
|
||||||
|
builder: &Builder<'_>,
|
||||||
|
) -> bool {
|
||||||
|
let mut cargo = prepare_cargo_test(cargo, libtest_args, crates, compiler, target, builder);
|
||||||
|
let _time = util::timeit(&builder);
|
||||||
|
add_flags_and_try_run_tests(builder, &mut cargo)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Given a `cargo test` subcommand, pass it the appropriate test flags given a `builder`.
|
||||||
|
fn prepare_cargo_test(
|
||||||
|
cargo: impl Into<Command>,
|
||||||
|
libtest_args: &[&str],
|
||||||
|
crates: &[Interned<String>],
|
||||||
|
compiler: Compiler,
|
||||||
|
target: TargetSelection,
|
||||||
|
builder: &Builder<'_>,
|
||||||
|
) -> Command {
|
||||||
let mut cargo = cargo.into();
|
let mut cargo = cargo.into();
|
||||||
|
|
||||||
// Pass in some standard flags then iterate over the graph we've discovered
|
// Pass in some standard flags then iterate over the graph we've discovered
|
||||||
@ -2132,6 +2141,11 @@ fn run_cargo_test(cargo: impl Into<Command>, libtest_args: &[&str], crates: &[In
|
|||||||
cargo.arg("-p").arg(krate);
|
cargo.arg("-p").arg(krate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cargo.arg("--").args(&builder.config.cmd.test_args()).args(libtest_args);
|
||||||
|
if !builder.config.verbose_tests {
|
||||||
|
cargo.arg("--quiet");
|
||||||
|
}
|
||||||
|
|
||||||
// The tests are going to run with the *target* libraries, so we need to
|
// The tests are going to run with the *target* libraries, so we need to
|
||||||
// ensure that those libraries show up in the LD_LIBRARY_PATH equivalent.
|
// ensure that those libraries show up in the LD_LIBRARY_PATH equivalent.
|
||||||
//
|
//
|
||||||
@ -2157,9 +2171,7 @@ fn run_cargo_test(cargo: impl Into<Command>, libtest_args: &[&str], crates: &[In
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
cargo.arg("--").args(&builder.config.cmd.test_args()).args(libtest_args);
|
cargo
|
||||||
let _time = util::timeit(&builder);
|
|
||||||
add_flags_and_try_run_tests(builder, &mut cargo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
@ -2281,24 +2293,6 @@ impl Step for CrateRustdoc {
|
|||||||
SourceType::InTree,
|
SourceType::InTree,
|
||||||
&[],
|
&[],
|
||||||
);
|
);
|
||||||
if builder.kind == Kind::Test && !builder.fail_fast {
|
|
||||||
cargo.arg("--no-fail-fast");
|
|
||||||
}
|
|
||||||
match builder.doc_tests {
|
|
||||||
DocTests::Only => {
|
|
||||||
cargo.arg("--doc");
|
|
||||||
}
|
|
||||||
DocTests::No => {
|
|
||||||
cargo.args(&["--lib", "--bins", "--examples", "--tests", "--benches"]);
|
|
||||||
}
|
|
||||||
DocTests::Yes => {}
|
|
||||||
}
|
|
||||||
|
|
||||||
cargo.arg("-p").arg("rustdoc:0.0.0");
|
|
||||||
|
|
||||||
cargo.arg("--");
|
|
||||||
cargo.args(&builder.config.cmd.test_args());
|
|
||||||
|
|
||||||
if self.host.contains("musl") {
|
if self.host.contains("musl") {
|
||||||
cargo.arg("'-Ctarget-feature=-crt-static'");
|
cargo.arg("'-Ctarget-feature=-crt-static'");
|
||||||
}
|
}
|
||||||
@ -2338,15 +2332,15 @@ impl Step for CrateRustdoc {
|
|||||||
dylib_path.insert(0, PathBuf::from(&*libdir));
|
dylib_path.insert(0, PathBuf::from(&*libdir));
|
||||||
cargo.env(dylib_path_var(), env::join_paths(&dylib_path).unwrap());
|
cargo.env(dylib_path_var(), env::join_paths(&dylib_path).unwrap());
|
||||||
|
|
||||||
if !builder.config.verbose_tests {
|
|
||||||
cargo.arg("--quiet");
|
|
||||||
}
|
|
||||||
|
|
||||||
let _guard = builder.msg(builder.kind, compiler.stage, "rustdoc", compiler.host, target);
|
let _guard = builder.msg(builder.kind, compiler.stage, "rustdoc", compiler.host, target);
|
||||||
|
run_cargo_test(
|
||||||
let _time = util::timeit(&builder);
|
cargo,
|
||||||
|
&[],
|
||||||
add_flags_and_try_run_tests(builder, &mut cargo.into());
|
&[INTERNER.intern_str("rustdoc:0.0.0")],
|
||||||
|
compiler,
|
||||||
|
target,
|
||||||
|
builder,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2380,7 +2374,7 @@ impl Step for CrateRustdocJsonTypes {
|
|||||||
let compiler = builder.compiler_for(builder.top_stage, target, target);
|
let compiler = builder.compiler_for(builder.top_stage, target, target);
|
||||||
builder.ensure(compile::Rustc::new(compiler, target));
|
builder.ensure(compile::Rustc::new(compiler, target));
|
||||||
|
|
||||||
let mut cargo = tool::prepare_tool_cargo(
|
let cargo = tool::prepare_tool_cargo(
|
||||||
builder,
|
builder,
|
||||||
compiler,
|
compiler,
|
||||||
Mode::ToolRustc,
|
Mode::ToolRustc,
|
||||||
@ -2390,24 +2384,24 @@ impl Step for CrateRustdocJsonTypes {
|
|||||||
SourceType::InTree,
|
SourceType::InTree,
|
||||||
&[],
|
&[],
|
||||||
);
|
);
|
||||||
if builder.kind == Kind::Test && !builder.fail_fast {
|
|
||||||
cargo.arg("--no-fail-fast");
|
|
||||||
}
|
|
||||||
|
|
||||||
cargo.arg("-p").arg("rustdoc-json-types");
|
// FIXME: this looks very wrong, libtest doesn't accept `-C` arguments and the quotes are fishy.
|
||||||
|
let libtest_args = if self.host.contains("musl") {
|
||||||
cargo.arg("--");
|
["'-Ctarget-feature=-crt-static'"].as_slice()
|
||||||
cargo.args(&builder.config.cmd.test_args());
|
} else {
|
||||||
|
&[]
|
||||||
if self.host.contains("musl") {
|
};
|
||||||
cargo.arg("'-Ctarget-feature=-crt-static'");
|
|
||||||
}
|
|
||||||
|
|
||||||
let _guard =
|
let _guard =
|
||||||
builder.msg(builder.kind, compiler.stage, "rustdoc-json-types", compiler.host, target);
|
builder.msg(builder.kind, compiler.stage, "rustdoc-json-types", compiler.host, target);
|
||||||
let _time = util::timeit(&builder);
|
run_cargo_test(
|
||||||
|
cargo,
|
||||||
add_flags_and_try_run_tests(builder, &mut cargo.into());
|
libtest_args,
|
||||||
|
&[INTERNER.intern_str("rustdoc-json-types")],
|
||||||
|
compiler,
|
||||||
|
target,
|
||||||
|
builder,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user