Skip to content

Commit d4ee83e

Browse files
committed
bootstrap: add an initial stdarch test step
1 parent 5b61449 commit d4ee83e

4 files changed

Lines changed: 90 additions & 1 deletion

File tree

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

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3028,6 +3028,63 @@ fn prepare_cargo_test(
30283028
/// FIXME(Zalathar): Try to split this into two separate steps: a user-visible
30293029
/// step for testing standard library crates, and an internal step used for both
30303030
/// library crates and compiler crates.
3031+
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3032+
pub struct Stdarch {
3033+
build_compiler: Compiler,
3034+
target: TargetSelection,
3035+
}
3036+
3037+
impl Step for Stdarch {
3038+
type Output = ();
3039+
const IS_HOST: bool = true;
3040+
3041+
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
3042+
run.path("library/stdarch").path("library/stdarch/crates/core_arch")
3043+
}
3044+
3045+
fn is_default_step(_builder: &Builder<'_>) -> bool {
3046+
false
3047+
}
3048+
3049+
fn make_run(run: RunConfig<'_>) {
3050+
let builder = run.builder;
3051+
let host = run.build_triple();
3052+
let build_compiler = builder.compiler(builder.top_stage, host);
3053+
3054+
builder.ensure(Stdarch { build_compiler, target: run.target });
3055+
}
3056+
3057+
fn run(self, builder: &Builder<'_>) {
3058+
let build_compiler = self.build_compiler;
3059+
let target = self.target;
3060+
3061+
builder.ensure(Std::new(build_compiler, build_compiler.host).force_recompile(true));
3062+
3063+
if !builder.config.is_host_target(target) {
3064+
builder.ensure(compile::Std::new(build_compiler, target).force_recompile(true));
3065+
builder.ensure(RemoteCopyLibs { build_compiler, target });
3066+
}
3067+
3068+
let mut cargo = builder::Cargo::new(
3069+
builder,
3070+
build_compiler,
3071+
Mode::Std,
3072+
SourceType::InTree,
3073+
target,
3074+
builder.kind,
3075+
);
3076+
3077+
cargo.arg("--manifest-path").arg(builder.src.join("library/stdarch/Cargo.toml"));
3078+
3079+
let crates = vec!["core_arch".to_owned()];
3080+
run_cargo_test(cargo, &[], &crates, "stdarch", target, builder);
3081+
}
3082+
3083+
fn metadata(&self) -> Option<StepMetadata> {
3084+
Some(StepMetadata::test("stdarch", self.target).built_by(self.build_compiler))
3085+
}
3086+
}
3087+
30313088
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
30323089
pub struct Crate {
30333090
/// The compiler that will *build* libstd or rustc in test mode.

src/bootstrap/src/core/builder/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,7 @@ impl<'a> Builder<'a> {
871871
test::CrateRustdoc,
872872
test::CrateRustdocJsonTypes,
873873
test::CrateBootstrap,
874+
test::Stdarch,
874875
test::RemoteTestClientTests,
875876
test::Linkcheck,
876877
test::TierCheck,

src/bootstrap/src/core/builder/tests.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@ fn run_build(paths: &[PathBuf], config: Config) -> Cache {
3939
builder.cache
4040
}
4141

42+
fn configure_stdarch_test(paths: &[&str]) -> Config {
43+
let ctx = TestCtx::new();
44+
ctx.config("test")
45+
.args(paths)
46+
.args(&["--ci", "true"])
47+
.hosts(&[TEST_TRIPLE_1])
48+
.targets(&[TEST_TRIPLE_1])
49+
.no_override_download_ci_llvm()
50+
.create_config()
51+
}
52+
4253
fn check_cli<const N: usize>(paths: [&str; N]) {
4354
run_build(
4455
&paths.map(PathBuf::from),
@@ -140,6 +151,16 @@ fn validate_path_remap() {
140151
});
141152
}
142153

154+
#[test]
155+
fn test_stdarch_workspace_metadata_is_loaded() {
156+
let build = Build::new(configure_stdarch_test(&[]));
157+
158+
assert_eq!(
159+
build.crate_paths.get(&PathBuf::from("library/stdarch/crates/core_arch")),
160+
Some(&"core_arch".to_owned())
161+
);
162+
}
163+
143164
#[test]
144165
fn check_missing_paths_for_x_test_tests() {
145166
let build = Build::new(configure("test", &[TEST_TRIPLE_1], &[TEST_TRIPLE_1]));
@@ -320,6 +341,14 @@ fn test_test_compiler() {
320341
assert_eq!((compiler, cranelift, gcc), (true, false, false));
321342
}
322343

344+
#[test]
345+
fn test_test_stdarch() {
346+
let config = configure_stdarch_test(&["library/stdarch"]);
347+
let cache = run_build(&config.paths.clone(), config);
348+
349+
assert!(cache.contains::<test::Stdarch>());
350+
}
351+
323352
#[test]
324353
fn test_test_coverage() {
325354
struct Case {

src/bootstrap/src/core/metadata.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,11 @@ fn workspace_members(build: &Build) -> Vec<Package> {
9393
packages
9494
};
9595

96-
// Collects `metadata.packages` from the root and library workspaces.
96+
// Collect `metadata.packages` from the workspaces that bootstrap may need
97+
// to resolve from CLI paths.
9798
let mut packages = vec![];
9899
packages.extend(collect_metadata("Cargo.toml"));
99100
packages.extend(collect_metadata("library/Cargo.toml"));
101+
packages.extend(collect_metadata("library/stdarch/Cargo.toml"));
100102
packages
101103
}

0 commit comments

Comments
 (0)