Skip to content

Commit eb5d9bc

Browse files
committed
compiletest: use parse_name_value_directive and improve ignore messages
Instead of using `strip_prefix`.
1 parent a9d1762 commit eb5d9bc

File tree

1 file changed

+27
-16
lines changed

1 file changed

+27
-16
lines changed

src/tools/compiletest/src/header.rs

+27-16
Original file line numberDiff line numberDiff line change
@@ -1490,29 +1490,38 @@ fn ignore_llvm(config: &Config, line: &str) -> IgnoreDecision {
14901490
}
14911491
}
14921492
if let Some(actual_version) = config.llvm_version {
1493-
if let Some(rest) = line.strip_prefix("min-llvm-version:").map(str::trim) {
1494-
let min_version = extract_llvm_version(rest).unwrap();
1495-
// Ignore if actual version is smaller the minimum required
1496-
// version
1493+
if let Some(value) = config.parse_name_value_directive(line, "min-llvm-version") {
1494+
let value = value.trim();
1495+
let min_version = extract_llvm_version(value).unwrap();
1496+
// Ignore if actual version is smaller than the minimum required version.
14971497
if actual_version < min_version {
14981498
return IgnoreDecision::Ignore {
1499-
reason: format!("ignored when the LLVM version is older than {rest}"),
1499+
reason: format!(
1500+
"ignored when the LLVM version ({actual_version}) is older than {min_version}"
1501+
),
15001502
};
15011503
}
1502-
} else if let Some(rest) = line.strip_prefix("min-system-llvm-version:").map(str::trim) {
1503-
let min_version = extract_llvm_version(rest).unwrap();
1504-
// Ignore if using system LLVM and actual version
1505-
// is smaller the minimum required version
1504+
} else if let Some(value) =
1505+
config.parse_name_value_directive(line, "min-system-llvm-version")
1506+
{
1507+
let value = value.trim();
1508+
let min_version = extract_llvm_version(value).unwrap();
1509+
// Ignore if using system LLVM and actual version is smaller the minimum required
1510+
// version.
15061511
if config.system_llvm && actual_version < min_version {
15071512
return IgnoreDecision::Ignore {
1508-
reason: format!("ignored when the system LLVM version is older than {rest}"),
1513+
reason: format!(
1514+
"ignored when the system LLVM version ({actual_version})\
1515+
is older than {min_version}"
1516+
),
15091517
};
15101518
}
1511-
} else if let Some(rest) = line.strip_prefix("ignore-llvm-version:").map(str::trim) {
1512-
// Syntax is: "ignore-llvm-version: <version1> [- <version2>]"
1519+
} else if let Some(value) = config.parse_name_value_directive(line, "ignore-llvm-version") {
1520+
let value = value.trim();
1521+
// Syntax is: "ignore-llvm-version: <version1> [- <version2>]".
15131522
let (v_min, v_max) =
1514-
extract_version_range(rest, extract_llvm_version).unwrap_or_else(|| {
1515-
panic!("couldn't parse version range: {:?}", rest);
1523+
extract_version_range(value, extract_llvm_version).unwrap_or_else(|| {
1524+
panic!("couldn't parse version range: {:?}", value);
15161525
});
15171526
if v_max < v_min {
15181527
panic!("Malformed LLVM version range: max < min")
@@ -1521,11 +1530,13 @@ fn ignore_llvm(config: &Config, line: &str) -> IgnoreDecision {
15211530
if actual_version >= v_min && actual_version <= v_max {
15221531
if v_min == v_max {
15231532
return IgnoreDecision::Ignore {
1524-
reason: format!("ignored when the LLVM version is {rest}"),
1533+
reason: format!("ignored when the LLVM version is {actual_version}"),
15251534
};
15261535
} else {
15271536
return IgnoreDecision::Ignore {
1528-
reason: format!("ignored when the LLVM version is between {rest}"),
1537+
reason: format!(
1538+
"ignored when the LLVM version ({actual_version}) is between {v_min}-{v_max}"
1539+
),
15291540
};
15301541
}
15311542
}

0 commit comments

Comments
 (0)