stabilize download_ci_llvm test

Signed-off-by: onur-ozkan <work@onurozkan.dev>
This commit is contained in:
onur-ozkan 2024-10-10 10:24:41 +03:00
parent ef51577656
commit f6b75575e1

View File

@ -20,29 +20,21 @@ fn parse(config: &str) -> Config {
#[test]
fn download_ci_llvm() {
if crate::core::build_steps::llvm::is_ci_llvm_modified(&parse("")) {
eprintln!("Detected LLVM as non-available: running in CI and modified LLVM in this change");
return;
assert!(parse("").llvm_from_ci);
assert!(parse("llvm.download-ci-llvm = true").llvm_from_ci);
assert!(!parse("llvm.download-ci-llvm = false").llvm_from_ci);
let if_unchanged_config = parse("llvm.download-ci-llvm = \"if-unchanged\"");
if if_unchanged_config.llvm_from_ci {
let has_changes = if_unchanged_config
.last_modified_commit(&["src/llvm-project"], "download-ci-llvm", true)
.is_none();
assert!(
!has_changes,
"CI LLVM can't be enabled with 'if-unchanged' while there are changes in LLVM submodule."
);
}
let parse_llvm = |s| parse(s).llvm_from_ci;
let if_unchanged = parse_llvm("llvm.download-ci-llvm = \"if-unchanged\"");
assert!(parse_llvm("llvm.download-ci-llvm = true"));
assert!(!parse_llvm("llvm.download-ci-llvm = false"));
assert_eq!(parse_llvm(""), if_unchanged);
assert_eq!(parse_llvm("rust.channel = \"dev\""), if_unchanged);
assert!(parse_llvm("rust.channel = \"stable\""));
assert_eq!(parse_llvm("build.build = \"x86_64-unknown-linux-gnu\""), if_unchanged);
assert_eq!(
parse_llvm(
"llvm.assertions = true \r\n build.build = \"x86_64-unknown-linux-gnu\" \r\n llvm.download-ci-llvm = \"if-unchanged\""
),
if_unchanged
);
assert!(!parse_llvm(
"llvm.assertions = true \r\n build.build = \"aarch64-apple-darwin\" \r\n llvm.download-ci-llvm = \"if-unchanged\""
));
}
// FIXME(onur-ozkan): extend scope of the test