Skip to content

Commit aae8f1d

Browse files
committed
compiletest: add max-llvm-version directive
There's already `min-llvm-version`, and contributors were using `ignore-llvm-versions: 20 - 99` to emulate `max-llvm-version: 19`.
1 parent eb5d9bc commit aae8f1d

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

src/tools/compiletest/src/command-list.rs

+1
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
116116
"incremental",
117117
"known-bug",
118118
"llvm-cov-flags",
119+
"max-llvm-version",
119120
"min-cdb-version",
120121
"min-gdb-version",
121122
"min-lldb-version",

src/tools/compiletest/src/header.rs

+11
Original file line numberDiff line numberDiff line change
@@ -1501,6 +1501,17 @@ fn ignore_llvm(config: &Config, line: &str) -> IgnoreDecision {
15011501
),
15021502
};
15031503
}
1504+
} else if let Some(value) = config.parse_name_value_directive(line, "max-llvm-version") {
1505+
let value = value.trim();
1506+
let max_version = extract_llvm_version(value).unwrap();
1507+
// Ignore if actual version is larger than the maximum required version.
1508+
if actual_version > max_version {
1509+
return IgnoreDecision::Ignore {
1510+
reason: format!(
1511+
"ignored when the LLVM version ({actual_version}) is newer than {max_version}"
1512+
),
1513+
};
1514+
}
15041515
} else if let Some(value) =
15051516
config.parse_name_value_directive(line, "min-system-llvm-version")
15061517
{

src/tools/compiletest/src/header/tests.rs

+9
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,15 @@ fn llvm_version() {
261261

262262
let config: Config = cfg().llvm_version("10.0.0").build();
263263
assert!(!check_ignore(&config, "//@ min-llvm-version: 9.0"));
264+
265+
let config: Config = cfg().llvm_version("20.0.0").build();
266+
assert!(check_ignore(&config, "//@ max-llvm-version: 19.3.1"));
267+
268+
let config: Config = cfg().llvm_version("20.0.0").build();
269+
assert!(!check_ignore(&config, "//@ max-llvm-version: 20.0.0"));
270+
271+
let config: Config = cfg().llvm_version("20.0.0").build();
272+
assert!(!check_ignore(&config, "//@ max-llvm-version: 20.0.1"));
264273
}
265274

266275
#[test]

0 commit comments

Comments
 (0)