Skip to content

Commit 70b63a6

Browse files
committed
Break out Cargotest into its own cargotest module
1 parent f8c59dc commit 70b63a6

File tree

2 files changed

+55
-48
lines changed

2 files changed

+55
-48
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
use std::fs;
2+
3+
use crate::core::build_steps::compile;
4+
use crate::core::build_steps::tool::{self, Tool};
5+
use crate::core::builder::{Builder, RunConfig, ShouldRun, Step};
6+
use crate::core::config::TargetSelection;
7+
use crate::utils::helpers::{self, LldThreads, add_rustdoc_cargo_linker_args, t};
8+
9+
/// Builds cargo and then runs the `src/tools/cargotest` tool, which checks out some representative
10+
/// crate repositories and runs `cargo test` on them, in order to test cargo.
11+
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
12+
pub struct Cargotest {
13+
stage: u32,
14+
host: TargetSelection,
15+
}
16+
17+
impl Step for Cargotest {
18+
type Output = ();
19+
const ONLY_HOSTS: bool = true;
20+
21+
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
22+
run.path("src/tools/cargotest")
23+
}
24+
25+
fn make_run(run: RunConfig<'_>) {
26+
run.builder.ensure(Cargotest { stage: run.builder.top_stage, host: run.target });
27+
}
28+
29+
/// Runs the `cargotest` tool as compiled in `stage` by the `host` compiler.
30+
///
31+
/// This tool in `src/tools` will check out a few Rust projects and run `cargo
32+
/// test` to ensure that we don't regress the test suites there.
33+
fn run(self, builder: &Builder<'_>) {
34+
let compiler = builder.compiler(self.stage, self.host);
35+
builder.ensure(compile::Rustc::new(compiler, compiler.host));
36+
let cargo = builder.ensure(tool::Cargo { compiler, target: compiler.host });
37+
38+
// Note that this is a short, cryptic, and not scoped directory name. This
39+
// is currently to minimize the length of path on Windows where we otherwise
40+
// quickly run into path name limit constraints.
41+
let out_dir = builder.out.join("ct");
42+
t!(fs::create_dir_all(&out_dir));
43+
44+
let _time = helpers::timeit(builder);
45+
let mut cmd = builder.tool_cmd(Tool::CargoTest);
46+
cmd.arg(&cargo)
47+
.arg(&out_dir)
48+
.args(builder.config.test_args())
49+
.env("RUSTC", builder.rustc(compiler))
50+
.env("RUSTDOC", builder.rustdoc(compiler));
51+
add_rustdoc_cargo_linker_args(&mut cmd, builder, compiler.host, LldThreads::No);
52+
cmd.delay_failure().run(builder);
53+
}
54+
}

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

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ use crate::{CLang, DocTests, GitRepo, Mode, PathSet, envify};
3737

3838
mod book_tests;
3939
mod bootstrap_self_tests;
40+
mod cargotest;
4041
mod compiler_crate_tests;
4142
mod compiletest_self_tests;
4243
mod compiletest_suites;
@@ -200,54 +201,6 @@ impl Step for HtmlCheck {
200201
}
201202
}
202203

203-
/// Builds cargo and then runs the `src/tools/cargotest` tool, which checks out
204-
/// some representative crate repositories and runs `cargo test` on them, in
205-
/// order to test cargo.
206-
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
207-
pub struct Cargotest {
208-
stage: u32,
209-
host: TargetSelection,
210-
}
211-
212-
impl Step for Cargotest {
213-
type Output = ();
214-
const ONLY_HOSTS: bool = true;
215-
216-
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
217-
run.path("src/tools/cargotest")
218-
}
219-
220-
fn make_run(run: RunConfig<'_>) {
221-
run.builder.ensure(Cargotest { stage: run.builder.top_stage, host: run.target });
222-
}
223-
224-
/// Runs the `cargotest` tool as compiled in `stage` by the `host` compiler.
225-
///
226-
/// This tool in `src/tools` will check out a few Rust projects and run `cargo
227-
/// test` to ensure that we don't regress the test suites there.
228-
fn run(self, builder: &Builder<'_>) {
229-
let compiler = builder.compiler(self.stage, self.host);
230-
builder.ensure(compile::Rustc::new(compiler, compiler.host));
231-
let cargo = builder.ensure(tool::Cargo { compiler, target: compiler.host });
232-
233-
// Note that this is a short, cryptic, and not scoped directory name. This
234-
// is currently to minimize the length of path on Windows where we otherwise
235-
// quickly run into path name limit constraints.
236-
let out_dir = builder.out.join("ct");
237-
t!(fs::create_dir_all(&out_dir));
238-
239-
let _time = helpers::timeit(builder);
240-
let mut cmd = builder.tool_cmd(Tool::CargoTest);
241-
cmd.arg(&cargo)
242-
.arg(&out_dir)
243-
.args(builder.config.test_args())
244-
.env("RUSTC", builder.rustc(compiler))
245-
.env("RUSTDOC", builder.rustdoc(compiler));
246-
add_rustdoc_cargo_linker_args(&mut cmd, builder, compiler.host, LldThreads::No);
247-
cmd.delay_failure().run(builder);
248-
}
249-
}
250-
251204
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
252205
pub struct RustdocTheme {
253206
pub compiler: Compiler,

0 commit comments

Comments
 (0)