Skip to content

Commit 34a1749

Browse files
committed
Break out compiletest self-test into its own compiletest_self_tests module
1 parent fbf743c commit 34a1749

File tree

2 files changed

+50
-41
lines changed

2 files changed

+50
-41
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
use super::test_helpers::run_cargo_test;
2+
use crate::core::build_steps::compile;
3+
use crate::core::build_steps::tool::{self, SourceType};
4+
use crate::core::builder::{Builder, RunConfig, ShouldRun, Step};
5+
use crate::core::config::TargetSelection;
6+
use crate::{Kind, Mode};
7+
8+
// FIXME(#137178): this step is named inconsistently versus other crate self-test steps.
9+
10+
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
11+
pub struct CompiletestTest {
12+
host: TargetSelection,
13+
}
14+
15+
impl Step for CompiletestTest {
16+
type Output = ();
17+
18+
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
19+
run.path("src/tools/compiletest")
20+
}
21+
22+
fn make_run(run: RunConfig<'_>) {
23+
run.builder.ensure(CompiletestTest { host: run.target });
24+
}
25+
26+
/// Runs `cargo test` for compiletest.
27+
fn run(self, builder: &Builder<'_>) {
28+
let host = self.host;
29+
let compiler = builder.compiler(builder.top_stage, host);
30+
31+
// We need `ToolStd` for the locally-built sysroot because
32+
// compiletest uses unstable features of the `test` crate.
33+
builder.ensure(compile::Std::new(compiler, host));
34+
let mut cargo = tool::prepare_tool_cargo(
35+
builder,
36+
compiler,
37+
// compiletest uses libtest internals; make it use the in-tree std to make sure it never breaks
38+
// when std sources change.
39+
Mode::ToolStd,
40+
host,
41+
Kind::Test,
42+
"src/tools/compiletest",
43+
SourceType::InTree,
44+
&[],
45+
);
46+
cargo.allow_features("test");
47+
run_cargo_test(cargo, &[], &[], "compiletest", "compiletest self test", host, builder);
48+
}
49+
}

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

Lines changed: 1 addition & 41 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 compiletest_self_tests;
4041
mod devtool_tests;
4142
mod miri_tests;
4243
mod rustdoc_tests;
@@ -246,47 +247,6 @@ impl Step for Cargotest {
246247
}
247248
}
248249

249-
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
250-
pub struct CompiletestTest {
251-
host: TargetSelection,
252-
}
253-
254-
impl Step for CompiletestTest {
255-
type Output = ();
256-
257-
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
258-
run.path("src/tools/compiletest")
259-
}
260-
261-
fn make_run(run: RunConfig<'_>) {
262-
run.builder.ensure(CompiletestTest { host: run.target });
263-
}
264-
265-
/// Runs `cargo test` for compiletest.
266-
fn run(self, builder: &Builder<'_>) {
267-
let host = self.host;
268-
let compiler = builder.compiler(builder.top_stage, host);
269-
270-
// We need `ToolStd` for the locally-built sysroot because
271-
// compiletest uses unstable features of the `test` crate.
272-
builder.ensure(compile::Std::new(compiler, host));
273-
let mut cargo = tool::prepare_tool_cargo(
274-
builder,
275-
compiler,
276-
// compiletest uses libtest internals; make it use the in-tree std to make sure it never breaks
277-
// when std sources change.
278-
Mode::ToolStd,
279-
host,
280-
Kind::Test,
281-
"src/tools/compiletest",
282-
SourceType::InTree,
283-
&[],
284-
);
285-
cargo.allow_features("test");
286-
run_cargo_test(cargo, &[], &[], "compiletest", "compiletest self test", host, builder);
287-
}
288-
}
289-
290250
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
291251
pub struct RustdocTheme {
292252
pub compiler: Compiler,

0 commit comments

Comments
 (0)