Skip to content

Commit

Permalink
Add test for x.py build cross-compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Simulacrum committed Sep 17, 2020
1 parent bd4e0af commit 363aff0
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/bootstrap/builder/tests.rs
Expand Up @@ -90,6 +90,54 @@ mod defaults {
assert!(builder.cache.all::<compile::Rustc>().is_empty());
}

#[test]
fn build_cross_compile() {
let config = Config { stage: 1, ..configure("build", &["B"], &["B"]) };
let build = Build::new(config);
let mut builder = Builder::new(&build);
builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Build), &[]);

let a = TargetSelection::from_user("A");
let b = TargetSelection::from_user("B");

// Ideally, this build wouldn't actually have `target: a`
// rustdoc/rustcc/std here (the user only requested a host=B build, so
// there's not really a need for us to build for target A in this case
// (since we're producing stage 1 libraries/binaries). But currently
// rustbuild is just a bit buggy here; this should be fixed though.
assert_eq!(
first(builder.cache.all::<compile::Std>()),
&[
compile::Std { compiler: Compiler { host: a, stage: 0 }, target: a },
compile::Std { compiler: Compiler { host: a, stage: 1 }, target: a },
compile::Std { compiler: Compiler { host: a, stage: 0 }, target: b },
compile::Std { compiler: Compiler { host: a, stage: 1 }, target: b },
]
);
assert_eq!(
first(builder.cache.all::<compile::Assemble>()),
&[
compile::Assemble { target_compiler: Compiler { host: a, stage: 0 } },
compile::Assemble { target_compiler: Compiler { host: a, stage: 1 } },
compile::Assemble { target_compiler: Compiler { host: b, stage: 1 } },
]
);
assert_eq!(
first(builder.cache.all::<tool::Rustdoc>()),
&[
tool::Rustdoc { compiler: Compiler { host: a, stage: 1 } },
tool::Rustdoc { compiler: Compiler { host: b, stage: 1 } },
],
);
assert_eq!(
first(builder.cache.all::<compile::Rustc>()),
&[
compile::Rustc { compiler: Compiler { host: a, stage: 0 }, target: a },
compile::Rustc { compiler: Compiler { host: a, stage: 0 }, target: b },
]
);
}

#[test]
fn doc_default() {
let mut config = configure("doc", &[], &[]);
Expand Down

0 comments on commit 363aff0

Please sign in to comment.