Skip to content

Commit f8c59dc

Browse files
committed
Extract TestParseFloat into std_tests module
1 parent a55e8d2 commit f8c59dc

File tree

2 files changed

+83
-68
lines changed

2 files changed

+83
-68
lines changed

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

Lines changed: 1 addition & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ mod compiletest_suites;
4343
mod devtool_tests;
4444
mod miri_tests;
4545
mod rustdoc_tests;
46+
mod std_tests;
4647
mod test_helpers;
4748
mod tidy;
4849

@@ -531,74 +532,6 @@ impl Step for RustInstaller {
531532
}
532533
}
533534

534-
/// Test step that does two things:
535-
/// - Runs `cargo test` for the `src/etc/test-float-parse` tool.
536-
/// - Invokes the `test-float-parse` tool to test the standard library's
537-
/// float parsing routines.
538-
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
539-
pub struct TestFloatParse {
540-
path: PathBuf,
541-
host: TargetSelection,
542-
}
543-
544-
impl Step for TestFloatParse {
545-
type Output = ();
546-
const ONLY_HOSTS: bool = true;
547-
const DEFAULT: bool = true;
548-
549-
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
550-
run.path("src/etc/test-float-parse")
551-
}
552-
553-
fn make_run(run: RunConfig<'_>) {
554-
for path in run.paths {
555-
let path = path.assert_single_path().path.clone();
556-
run.builder.ensure(Self { path, host: run.target });
557-
}
558-
}
559-
560-
fn run(self, builder: &Builder<'_>) {
561-
let bootstrap_host = builder.config.build;
562-
let compiler = builder.compiler(builder.top_stage, bootstrap_host);
563-
let path = self.path.to_str().unwrap();
564-
let crate_name = self.path.components().last().unwrap().as_os_str().to_str().unwrap();
565-
566-
builder.ensure(tool::TestFloatParse { host: self.host });
567-
568-
// Run any unit tests in the crate
569-
let cargo_test = tool::prepare_tool_cargo(
570-
builder,
571-
compiler,
572-
Mode::ToolStd,
573-
bootstrap_host,
574-
Kind::Test,
575-
path,
576-
SourceType::InTree,
577-
&[],
578-
);
579-
580-
run_cargo_test(cargo_test, &[], &[], crate_name, crate_name, bootstrap_host, builder);
581-
582-
// Run the actual parse tests.
583-
let mut cargo_run = tool::prepare_tool_cargo(
584-
builder,
585-
compiler,
586-
Mode::ToolStd,
587-
bootstrap_host,
588-
Kind::Run,
589-
path,
590-
SourceType::InTree,
591-
&[],
592-
);
593-
594-
if !matches!(env::var("FLOAT_PARSE_TESTS_NO_SKIP_HUGE").as_deref(), Ok("1") | Ok("true")) {
595-
cargo_run.args(["--", "--skip-huge"]);
596-
}
597-
598-
cargo_run.into_cmd().run(builder);
599-
}
600-
}
601-
602535
/// Runs the tool `src/tools/collect-license-metadata` in `ONLY_CHECK=1` mode,
603536
/// which verifies that `license-metadata.json` is up-to-date and therefore
604537
/// running the tool normally would not update anything.
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
//! Standard library tests.
2+
3+
use std::env;
4+
use std::path::PathBuf;
5+
6+
use super::test_helpers::run_cargo_test;
7+
use crate::Mode;
8+
use crate::core::build_steps::tool::{self, SourceType};
9+
use crate::core::builder::{Builder, Kind, RunConfig, ShouldRun, Step};
10+
use crate::core::config::TargetSelection;
11+
12+
// FIXME(#137178): `Crate` is also used for standard library crate tests?
13+
14+
// FIXME(#137178): break up `TestFloatParse` into two steps: one for testing the tool itself, and
15+
// one for testing std float parsing.
16+
17+
/// Test step that does two things:
18+
/// - Runs `cargo test` for the `src/etc/test-float-parse` tool.
19+
/// - Invokes the `test-float-parse` tool to test the standard library's float parsing routines.
20+
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
21+
pub struct TestFloatParse {
22+
path: PathBuf,
23+
host: TargetSelection,
24+
}
25+
26+
impl Step for TestFloatParse {
27+
type Output = ();
28+
const ONLY_HOSTS: bool = true;
29+
const DEFAULT: bool = true;
30+
31+
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
32+
run.path("src/etc/test-float-parse")
33+
}
34+
35+
fn make_run(run: RunConfig<'_>) {
36+
for path in run.paths {
37+
let path = path.assert_single_path().path.clone();
38+
run.builder.ensure(Self { path, host: run.target });
39+
}
40+
}
41+
42+
fn run(self, builder: &Builder<'_>) {
43+
let bootstrap_host = builder.config.build;
44+
let compiler = builder.compiler(builder.top_stage, bootstrap_host);
45+
let path = self.path.to_str().unwrap();
46+
let crate_name = self.path.components().last().unwrap().as_os_str().to_str().unwrap();
47+
48+
builder.ensure(tool::TestFloatParse { host: self.host });
49+
50+
// Run any unit tests in the crate
51+
let cargo_test = tool::prepare_tool_cargo(
52+
builder,
53+
compiler,
54+
Mode::ToolStd,
55+
bootstrap_host,
56+
Kind::Test,
57+
path,
58+
SourceType::InTree,
59+
&[],
60+
);
61+
62+
run_cargo_test(cargo_test, &[], &[], crate_name, crate_name, bootstrap_host, builder);
63+
64+
// Run the actual parse tests.
65+
let mut cargo_run = tool::prepare_tool_cargo(
66+
builder,
67+
compiler,
68+
Mode::ToolStd,
69+
bootstrap_host,
70+
Kind::Run,
71+
path,
72+
SourceType::InTree,
73+
&[],
74+
);
75+
76+
if !matches!(env::var("FLOAT_PARSE_TESTS_NO_SKIP_HUGE").as_deref(), Ok("1") | Ok("true")) {
77+
cargo_run.args(["--", "--skip-huge"]);
78+
}
79+
80+
cargo_run.into_cmd().run(builder);
81+
}
82+
}

0 commit comments

Comments
 (0)