From d95a6cf91189421cc3174d10aaa910c7376529b8 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Sat, 1 May 2021 01:11:44 -0400 Subject: [PATCH 1/2] Add support for --test-args to cargotest This allows running a single test without having to wait for all tests to complete. --- src/bootstrap/test.rs | 1 + src/tools/cargotest/main.rs | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 965d11621450b..814a591b13738 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -183,6 +183,7 @@ impl Step for Cargotest { builder, cmd.arg(&cargo) .arg(&out_dir) + .args(builder.config.cmd.test_args()) .env("RUSTC", builder.rustc(compiler)) .env("RUSTDOC", builder.rustdoc(compiler)), ); diff --git a/src/tools/cargotest/main.rs b/src/tools/cargotest/main.rs index fc608eaabccf7..54ff38e39dbe4 100644 --- a/src/tools/cargotest/main.rs +++ b/src/tools/cargotest/main.rs @@ -85,7 +85,9 @@ fn main() { let cargo = &Path::new(cargo); for test in TEST_REPOS.iter().rev() { - test_repo(cargo, out_dir, test); + if args[3..].is_empty() || args[3..].iter().any(|s| s.contains(test.name)) { + test_repo(cargo, out_dir, test); + } } } From 22667464cd2ba3b8e7ae9a37da1be122ca28139b Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Sat, 1 May 2021 01:22:51 -0400 Subject: [PATCH 2/2] [WIP] Don't require building a stage1 compiler before running cargotest - Always use a bootstrap compiler for cargo and cargo-credential helpers This seems wrong; I think cargo is intentionally built with stage 2 because it's distributed with other parts of the release. However, I don't know how to avoid it - just changing CargoTest to build it with stage 0 unconditionally still builds rustc because it uses a `ToolRustc` mode. - Don't call `builder.ensure(Rustc)`. It's unnecessary. - Don't use the same compiler for building cargo as for testing. --- src/bootstrap/test.rs | 11 ++++++----- src/bootstrap/tool.rs | 6 +++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 814a591b13738..94295ece62568 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -167,9 +167,9 @@ impl Step for Cargotest { /// This tool in `src/tools` will check out a few Rust projects and run `cargo /// test` to ensure that we don't regress the test suites there. fn run(self, builder: &Builder<'_>) { - let compiler = builder.compiler(self.stage, self.host); - builder.ensure(compile::Rustc { compiler, target: compiler.host }); - let cargo = builder.ensure(tool::Cargo { compiler, target: compiler.host }); + let bootstrap_compiler = builder.compiler(0, self.host); + let cargo = builder + .ensure(tool::Cargo { compiler: bootstrap_compiler, target: bootstrap_compiler.host }); // Note that this is a short, cryptic, and not scoped directory name. This // is currently to minimize the length of path on Windows where we otherwise @@ -179,13 +179,14 @@ impl Step for Cargotest { let _time = util::timeit(&builder); let mut cmd = builder.tool_cmd(Tool::CargoTest); + let test_compiler = builder.compiler(self.stage, self.host); try_run( builder, cmd.arg(&cargo) .arg(&out_dir) .args(builder.config.cmd.test_args()) - .env("RUSTC", builder.rustc(compiler)) - .env("RUSTDOC", builder.rustdoc(compiler)), + .env("RUSTC", builder.rustc(test_compiler)) + .env("RUSTDOC", builder.rustdoc(test_compiler)), ); } } diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index e85f4628fb03a..c90022b3e2514 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -595,7 +595,7 @@ impl Step for Cargo { fn make_run(run: RunConfig<'_>) { run.builder.ensure(Cargo { - compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build), + compiler: run.builder.compiler(0, run.builder.config.build), target: run.target, }); } @@ -606,7 +606,7 @@ impl Step for Cargo { compiler: self.compiler, target: self.target, tool: "cargo", - mode: Mode::ToolRustc, + mode: Mode::ToolBootstrap, path: "src/tools/cargo", is_optional_tool: false, source_type: SourceType::Submodule, @@ -621,7 +621,7 @@ impl Step for Cargo { compiler: self.compiler, target: self.target, tool: name, - mode: Mode::ToolRustc, + mode: Mode::ToolBootstrap, path, is_optional_tool: true, source_type: SourceType::Submodule,