add regression test for dist compilation

Signed-off-by: onur-ozkan <work@onurozkan.dev>
This commit is contained in:
onur-ozkan 2025-04-18 09:03:17 +00:00
parent edfef428f7
commit 4ba9fffba5

View file

@ -408,6 +408,7 @@ mod dist {
use pretty_assertions::assert_eq;
use super::{Config, TEST_TRIPLE_1, TEST_TRIPLE_2, TEST_TRIPLE_3, first, run_build};
use crate::Flags;
use crate::core::builder::*;
fn configure(host: &[&str], target: &[&str]) -> Config {
@ -646,6 +647,37 @@ mod dist {
);
}
/// This also serves as an important regression test for <https://github.com/rust-lang/rust/issues/138123>
/// and <https://github.com/rust-lang/rust/issues/138004>.
#[test]
fn dist_all_cross() {
let cmd_args =
&["dist", "--stage", "2", "--dry-run", "--config=/does/not/exist"].map(str::to_owned);
let config_str = r#"
[rust]
channel = "nightly"
[build]
extended = true
build = "i686-unknown-haiku"
host = ["i686-unknown-netbsd"]
target = ["i686-unknown-netbsd"]
"#;
let config = Config::parse_inner(Flags::parse(cmd_args), |&_| toml::from_str(config_str));
let mut cache = run_build(&[], config);
// Stage 2 `compile::Rustc` should **NEVER** be cached here.
assert_eq!(
first(cache.all::<compile::Rustc>()),
&[
rustc!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 0),
rustc!(TEST_TRIPLE_1 => TEST_TRIPLE_1, stage = 1),
rustc!(TEST_TRIPLE_1 => TEST_TRIPLE_3, stage = 1),
]
);
}
#[test]
fn build_all() {
let build = Build::new(configure(