Skip to content

Commit 2a75607

Browse files
committed
Combine several Steps into a single step with multiple paths
1 parent ff674c1 commit 2a75607

File tree

3 files changed

+22
-115
lines changed

3 files changed

+22
-115
lines changed

src/bootstrap/builder.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,6 @@ impl<'a> Builder<'a> {
703703
crate::toolstate::ToolStateCheck,
704704
test::ExpandYamlAnchors,
705705
test::Tidy,
706-
test::TidySelfTest,
707706
test::Ui,
708707
test::RunPassValgrind,
709708
test::MirOpt,
@@ -719,11 +718,9 @@ impl<'a> Builder<'a> {
719718
test::CrateLibrustc,
720719
test::CrateRustdoc,
721720
test::CrateRustdocJsonTypes,
722-
test::CrateJsonDocLint,
723-
test::SuggestTestsCrate,
721+
test::CrateBootstrap,
724722
test::Linkcheck,
725723
test::TierCheck,
726-
test::ReplacePlaceholderTest,
727724
test::Cargotest,
728725
test::Cargo,
729726
test::RustAnalyzer,

src/bootstrap/test.rs

+20-110
Original file line numberDiff line numberDiff line change
@@ -55,73 +55,54 @@ fn try_run_quiet(builder: &Builder<'_>, cmd: &mut Command) -> bool {
5555
}
5656

5757
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
58-
pub struct CrateJsonDocLint {
58+
pub struct CrateBootstrap {
59+
path: Interned<PathBuf>,
5960
host: TargetSelection,
6061
}
6162

62-
impl Step for CrateJsonDocLint {
63+
impl Step for CrateBootstrap {
6364
type Output = ();
6465
const ONLY_HOSTS: bool = true;
6566
const DEFAULT: bool = true;
6667

6768
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
6869
run.path("src/tools/jsondoclint")
70+
.path("src/tools/suggest-tests")
71+
.path("src/tools/replace-version-placeholder")
72+
.alias("tidyselftest")
6973
}
7074

7175
fn make_run(run: RunConfig<'_>) {
72-
run.builder.ensure(CrateJsonDocLint { host: run.target });
76+
for path in run.paths {
77+
let path = INTERNER.intern_path(path.assert_single_path().path.clone());
78+
run.builder.ensure(CrateBootstrap { host: run.target, path });
79+
}
7380
}
7481

7582
fn run(self, builder: &Builder<'_>) {
7683
let bootstrap_host = builder.config.build;
7784
let compiler = builder.compiler(0, bootstrap_host);
85+
let mut path = self.path.to_str().unwrap();
86+
if path == "tidyselftest" {
87+
path = "src/tools/tidy";
88+
}
7889

7990
let cargo = tool::prepare_tool_cargo(
8091
builder,
8192
compiler,
8293
Mode::ToolBootstrap,
8394
bootstrap_host,
8495
"test",
85-
"src/tools/jsondoclint",
96+
path,
8697
SourceType::InTree,
8798
&[],
8899
);
89-
run_cargo_test(cargo, &[], &[], compiler, bootstrap_host, builder);
90-
}
91-
}
92-
93-
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
94-
pub struct SuggestTestsCrate {
95-
host: TargetSelection,
96-
}
97-
98-
impl Step for SuggestTestsCrate {
99-
type Output = ();
100-
const ONLY_HOSTS: bool = true;
101-
const DEFAULT: bool = true;
102-
103-
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
104-
run.path("src/tools/suggest-tests")
105-
}
106-
107-
fn make_run(run: RunConfig<'_>) {
108-
run.builder.ensure(SuggestTestsCrate { host: run.target });
109-
}
110-
111-
fn run(self, builder: &Builder<'_>) {
112-
let bootstrap_host = builder.config.build;
113-
let compiler = builder.compiler(0, bootstrap_host);
114-
115-
let cargo = tool::prepare_tool_cargo(
116-
builder,
117-
compiler,
118-
Mode::ToolBootstrap,
100+
builder.info(&format!(
101+
"{} {} stage0 ({})",
102+
builder.kind.test_description(),
103+
path,
119104
bootstrap_host,
120-
"test",
121-
"src/tools/suggest-tests",
122-
SourceType::InTree,
123-
&[],
124-
);
105+
));
125106
run_cargo_test(cargo, &[], &[], compiler, bootstrap_host, builder);
126107
}
127108
}
@@ -1151,40 +1132,6 @@ help: to skip test's attempt to check tidiness, pass `--exclude src/tools/tidy`
11511132
}
11521133
}
11531134

1154-
/// Runs tidy's own tests.
1155-
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
1156-
pub struct TidySelfTest;
1157-
1158-
impl Step for TidySelfTest {
1159-
type Output = ();
1160-
const DEFAULT: bool = true;
1161-
const ONLY_HOSTS: bool = true;
1162-
1163-
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1164-
run.alias("tidyselftest")
1165-
}
1166-
1167-
fn make_run(run: RunConfig<'_>) {
1168-
run.builder.ensure(TidySelfTest);
1169-
}
1170-
1171-
fn run(self, builder: &Builder<'_>) {
1172-
let bootstrap_host = builder.config.build;
1173-
let compiler = builder.compiler(0, bootstrap_host);
1174-
let cargo = tool::prepare_tool_cargo(
1175-
builder,
1176-
compiler,
1177-
Mode::ToolBootstrap,
1178-
bootstrap_host,
1179-
"test",
1180-
"src/tools/tidy",
1181-
SourceType::InTree,
1182-
&[],
1183-
);
1184-
run_cargo_test(cargo, &[], &[], compiler, bootstrap_host, builder);
1185-
}
1186-
}
1187-
11881135
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
11891136
pub struct ExpandYamlAnchors;
11901137

@@ -2613,43 +2560,6 @@ impl Step for TierCheck {
26132560
}
26142561
}
26152562

2616-
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
2617-
pub struct ReplacePlaceholderTest;
2618-
2619-
impl Step for ReplacePlaceholderTest {
2620-
type Output = ();
2621-
const ONLY_HOSTS: bool = true;
2622-
const DEFAULT: bool = true;
2623-
2624-
/// Ensure the version placeholder replacement tool builds
2625-
fn run(self, builder: &Builder<'_>) {
2626-
builder.info("build check for version replacement placeholder");
2627-
2628-
// Test the version placeholder replacement tool itself.
2629-
let bootstrap_host = builder.config.build;
2630-
let compiler = builder.compiler(0, bootstrap_host);
2631-
let cargo = tool::prepare_tool_cargo(
2632-
builder,
2633-
compiler,
2634-
Mode::ToolBootstrap,
2635-
bootstrap_host,
2636-
"test",
2637-
"src/tools/replace-version-placeholder",
2638-
SourceType::InTree,
2639-
&[],
2640-
);
2641-
add_flags_and_try_run_tests(builder, &mut cargo.into());
2642-
}
2643-
2644-
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
2645-
run.path("src/tools/replace-version-placeholder")
2646-
}
2647-
2648-
fn make_run(run: RunConfig<'_>) {
2649-
run.builder.ensure(Self);
2650-
}
2651-
}
2652-
26532563
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
26542564
pub struct LintDocs {
26552565
pub compiler: Compiler,

src/bootstrap/tool.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ pub fn prepare_tool_cargo(
141141
mode: Mode,
142142
target: TargetSelection,
143143
command: &'static str,
144-
path: &'static str,
144+
path: &str,
145145
source_type: SourceType,
146146
extra_features: &[String],
147147
) -> CargoCommand {

0 commit comments

Comments
 (0)