Skip to content

Commit

Permalink
Add support for run-make-support unit tests to be run with bootstrap …
Browse files Browse the repository at this point in the history
…command
  • Loading branch information
JoverZhang committed Apr 24, 2024
1 parent c1feb3e commit 9821098
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1371,6 +1371,7 @@ impl Step for RunMakeSupport {
run.builder.ensure(RunMakeSupport { compiler, target: run.build_triple() });
}

/// Builds run-make-support and returns the path to the resulting rlib.
fn run(self, builder: &Builder<'_>) -> PathBuf {
builder.ensure(compile::Std::new(self.compiler, self.target));

Expand All @@ -1397,6 +1398,52 @@ impl Step for RunMakeSupport {
}
}

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct RunMakeSupportTest {
host: TargetSelection,
}

impl Step for RunMakeSupportTest {
type Output = ();

fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
run.path("src/tools/run-make-support")
}

fn make_run(run: RunConfig<'_>) {
run.builder.ensure(RunMakeSupportTest { host: run.target });
}

/// Runs `cargo test` for run-make-support.
fn run(self, builder: &Builder<'_>) {
let host = self.host;
let compiler = builder.compiler(builder.top_stage, host);

builder.ensure(compile::Std::new(compiler, host));
let mut cargo = tool::prepare_tool_cargo(
builder,
compiler,
Mode::ToolStd,
host,
"test",
"src/tools/run-make-support",
SourceType::InTree,
&[],
);
cargo.allow_features("test");
run_cargo_test(
cargo,
&[],
&[],
"run-make-support",
"run-make-support self test",
compiler,
host,
builder,
);
}
}

default_test!(Ui { path: "tests/ui", mode: "ui", suite: "ui" });

default_test!(Crashes { path: "tests/crashes", mode: "crashes", suite: "crashes" });
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/src/core/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,7 @@ impl<'a> Builder<'a> {
test::Bootstrap,
// Run run-make last, since these won't pass without make on Windows
test::RunMake,
test::RunMakeSupportTest,
),
Kind::Miri => describe!(test::Crate),
Kind::Bench => describe!(test::Crate, test::CrateLibrustc),
Expand Down

0 comments on commit 9821098

Please sign in to comment.