Skip to content

Commit a4107b0

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

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

src/tools/compiletest/src/directive-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-major-version",
119120
"min-cdb-version",
120121
"min-gdb-version",
121122
"min-lldb-version",

src/tools/compiletest/src/header.rs

+14
Original file line numberDiff line numberDiff line change
@@ -1518,6 +1518,20 @@ fn ignore_llvm(config: &Config, line: &str) -> IgnoreDecision {
15181518
),
15191519
};
15201520
}
1521+
} else if let Some(version_string) =
1522+
config.parse_name_value_directive(line, "max-llvm-major-version")
1523+
{
1524+
let max_version = extract_llvm_version(&version_string);
1525+
// Ignore if actual major version is larger than the maximum required major version.
1526+
if actual_version.major > max_version.major {
1527+
return IgnoreDecision::Ignore {
1528+
reason: format!(
1529+
"ignored when the LLVM version ({actual_version}) is newer than major\
1530+
version {}",
1531+
max_version.major
1532+
),
1533+
};
1534+
}
15211535
} else if let Some(version_string) =
15221536
config.parse_name_value_directive(line, "min-system-llvm-version")
15231537
{

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

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

266266
let config: Config = cfg().llvm_version("10.0.0").build();
267267
assert!(!check_ignore(&config, "//@ min-llvm-version: 9.0"));
268+
269+
let config: Config = cfg().llvm_version("19.0.0").build();
270+
assert!(!check_ignore(&config, "//@ max-llvm-major-version: 19"));
271+
272+
let config: Config = cfg().llvm_version("19.1.2").build();
273+
assert!(!check_ignore(&config, "//@ max-llvm-major-version: 19"));
274+
275+
let config: Config = cfg().llvm_version("20.0.0").build();
276+
assert!(check_ignore(&config, "//@ max-llvm-major-version: 19"));
268277
}
269278

270279
#[test]

0 commit comments

Comments
 (0)