Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 657ba34

Browse files
committedJul 20, 2024
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 81d960f commit 657ba34

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
@@ -3466,3 +3466,80 @@ impl Step for CodegenGCC {
34663466
cargo.into_cmd().run(builder);
34673467
}
34683468
}
3469+
3470+
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3471+
pub struct TestFloatParse {
3472+
path: PathBuf,
3473+
host: TargetSelection,
3474+
}
3475+
3476+
impl Step for TestFloatParse {
3477+
type Output = ();
3478+
const ONLY_HOSTS: bool = true;
3479+
const DEFAULT: bool = true;
3480+
3481+
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
3482+
run.path("src/etc/test-float-parse")
3483+
}
3484+
3485+
fn make_run(run: RunConfig<'_>) {
3486+
for path in run.paths {
3487+
let path = path.assert_single_path().path.clone();
3488+
run.builder.ensure(Self { path, host: run.target });
3489+
}
3490+
}
3491+
3492+
fn run(self, builder: &Builder<'_>) {
3493+
let bootstrap_host = builder.config.build;
3494+
let compiler = builder.compiler(0, bootstrap_host);
3495+
let path = self.path.to_str().unwrap();
3496+
let crate_name = self.path.components().last().unwrap().as_os_str().to_str().unwrap();
3497+
3498+
builder.ensure(compile::Std::new(compiler, self.host));
3499+
3500+
// Run any unit tests in the crate
3501+
let cargo_test = tool::prepare_tool_cargo(
3502+
builder,
3503+
compiler,
3504+
Mode::ToolStd,
3505+
bootstrap_host,
3506+
"test",
3507+
path,
3508+
SourceType::InTree,
3509+
&[],
3510+
);
3511+
3512+
run_cargo_test(
3513+
cargo_test,
3514+
&[],
3515+
&[],
3516+
crate_name,
3517+
crate_name,
3518+
compiler,
3519+
bootstrap_host,
3520+
builder,
3521+
);
3522+
3523+
// Run the actual parse tests.
3524+
let mut cargo_run = tool::prepare_tool_cargo(
3525+
builder,
3526+
compiler,
3527+
Mode::ToolStd,
3528+
bootstrap_host,
3529+
"run",
3530+
path,
3531+
SourceType::InTree,
3532+
&[],
3533+
);
3534+
3535+
cargo_run.arg("--");
3536+
if builder.config.args().is_empty() {
3537+
// By default, exclude tests that take longer than ~1m.
3538+
cargo_run.arg("--skip-huge");
3539+
} else {
3540+
cargo_run.args(builder.config.args());
3541+
}
3542+
3543+
cargo_run.into_cmd().run(builder);
3544+
}
3545+
}

‎src/bootstrap/src/core/builder.rs

+3
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,7 @@ impl<'a> Builder<'a> {
794794
clippy::Rustdoc,
795795
clippy::Rustfmt,
796796
clippy::RustInstaller,
797+
clippy::TestFloatParse,
797798
clippy::Tidy,
798799
),
799800
Kind::Check | Kind::Fix => describe!(
@@ -808,6 +809,7 @@ impl<'a> Builder<'a> {
808809
check::Rls,
809810
check::Rustfmt,
810811
check::RustAnalyzer,
812+
check::TestFloatParse,
811813
check::Bootstrap,
812814
),
813815
Kind::Test => describe!(
@@ -868,6 +870,7 @@ impl<'a> Builder<'a> {
868870
test::RustdocJson,
869871
test::HtmlCheck,
870872
test::RustInstaller,
873+
test::TestFloatParse,
871874
// Run bootstrap close to the end as it's unlikely to fail
872875
test::Bootstrap,
873876
// Run run-make last, since these won't pass without make on Windows

0 commit comments

Comments
 (0)
Please sign in to comment.