Skip to content

Commit 6062059

Browse files
committed
Expose test-float-parse via bootstrap
With updates to `test-float-parse`, it is now possible to run as another Rust tool. Enable check, clippy, and test. Test runs the unit tests, as well as shorter parsing tests (takes approximately 1 minute).
1 parent 51827ce commit 6062059

File tree

4 files changed

+82
-0
lines changed

4 files changed

+82
-0
lines changed

src/bootstrap/src/core/build_steps/check.rs

+1
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@ tool_check_step!(CargoMiri, "src/tools/miri/cargo-miri", SourceType::InTree);
466466
tool_check_step!(Rls, "src/tools/rls", SourceType::InTree);
467467
tool_check_step!(Rustfmt, "src/tools/rustfmt", SourceType::InTree);
468468
tool_check_step!(MiroptTestTools, "src/tools/miropt-test-tools", SourceType::InTree);
469+
tool_check_step!(TestFloatParse, "src/etc/test-float-parse", SourceType::InTree);
469470

470471
tool_check_step!(Bootstrap, "src/bootstrap", SourceType::InTree, false);
471472

src/bootstrap/src/core/build_steps/clippy.rs

+1
Original file line numberDiff line numberDiff line change
@@ -326,4 +326,5 @@ lint_any!(
326326
Rustfmt, "src/tools/rustfmt", "rustfmt";
327327
RustInstaller, "src/tools/rust-installer", "rust-installer";
328328
Tidy, "src/tools/tidy", "tidy";
329+
TestFloatParse, "src/etc/test-float-parse", "test-float-parse";
329330
);

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

+77
Original file line numberDiff line numberDiff line change
@@ -3505,3 +3505,80 @@ impl Step for CodegenGCC {
35053505
cargo.into_cmd().run(builder);
35063506
}
35073507
}
3508+
3509+
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3510+
pub struct TestFloatParse {
3511+
path: PathBuf,
3512+
host: TargetSelection,
3513+
}
3514+
3515+
impl Step for TestFloatParse {
3516+
type Output = ();
3517+
const ONLY_HOSTS: bool = true;
3518+
const DEFAULT: bool = true;
3519+
3520+
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
3521+
run.path("src/etc/test-float-parse")
3522+
}
3523+
3524+
fn make_run(run: RunConfig<'_>) {
3525+
for path in run.paths {
3526+
let path = path.assert_single_path().path.clone();
3527+
run.builder.ensure(Self { path, host: run.target });
3528+
}
3529+
}
3530+
3531+
fn run(self, builder: &Builder<'_>) {
3532+
let bootstrap_host = builder.config.build;
3533+
let compiler = builder.compiler(0, bootstrap_host);
3534+
let path = self.path.to_str().unwrap();
3535+
let crate_name = self.path.components().last().unwrap().as_os_str().to_str().unwrap();
3536+
3537+
builder.ensure(compile::Std::new(compiler, self.host));
3538+
3539+
// Run any unit tests in the crate
3540+
let cargo_test = tool::prepare_tool_cargo(
3541+
builder,
3542+
compiler,
3543+
Mode::ToolStd,
3544+
bootstrap_host,
3545+
"test",
3546+
path,
3547+
SourceType::InTree,
3548+
&[],
3549+
);
3550+
3551+
run_cargo_test(
3552+
cargo_test,
3553+
&[],
3554+
&[],
3555+
crate_name,
3556+
crate_name,
3557+
compiler,
3558+
bootstrap_host,
3559+
builder,
3560+
);
3561+
3562+
// Run the actual parse tests.
3563+
let mut cargo_run = tool::prepare_tool_cargo(
3564+
builder,
3565+
compiler,
3566+
Mode::ToolStd,
3567+
bootstrap_host,
3568+
"run",
3569+
path,
3570+
SourceType::InTree,
3571+
&[],
3572+
);
3573+
3574+
cargo_run.arg("--");
3575+
if builder.config.args().is_empty() {
3576+
// By default, exclude tests that take longer than ~1m.
3577+
cargo_run.arg("--skip-huge");
3578+
} else {
3579+
cargo_run.args(builder.config.args());
3580+
}
3581+
3582+
cargo_run.into_cmd().run(builder);
3583+
}
3584+
}

src/bootstrap/src/core/builder.rs

+3
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,7 @@ impl<'a> Builder<'a> {
826826
clippy::Rustdoc,
827827
clippy::Rustfmt,
828828
clippy::RustInstaller,
829+
clippy::TestFloatParse,
829830
clippy::Tidy,
830831
),
831832
Kind::Check | Kind::Fix => describe!(
@@ -840,6 +841,7 @@ impl<'a> Builder<'a> {
840841
check::Rls,
841842
check::Rustfmt,
842843
check::RustAnalyzer,
844+
check::TestFloatParse,
843845
check::Bootstrap,
844846
),
845847
Kind::Test => describe!(
@@ -901,6 +903,7 @@ impl<'a> Builder<'a> {
901903
test::RustdocJson,
902904
test::HtmlCheck,
903905
test::RustInstaller,
906+
test::TestFloatParse,
904907
// Run bootstrap close to the end as it's unlikely to fail
905908
test::Bootstrap,
906909
// Run run-make last, since these won't pass without make on Windows

0 commit comments

Comments
 (0)