Skip to content

Commit 45542b6

Browse files
committed
deny usage of FileCheck prefixes as revision names
1 parent c156614 commit 45542b6

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/tools/compiletest/src/header.rs

+10
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,9 @@ fn iter_header(
934934

935935
impl Config {
936936
fn parse_and_update_revisions(&self, testfile: &Path, line: &str, existing: &mut Vec<String>) {
937+
const FORBIDDEN_REVISION_NAMES: [&str; 9] =
938+
["CHECK", "COM", "NEXT", "SAME", "EMPTY", "NOT", "COUNT", "DAG", "LABEL"];
939+
937940
if let Some(raw) = self.parse_name_value_directive(line, "revisions") {
938941
if self.mode == Mode::RunMake {
939942
panic!("`run-make` tests do not support revisions: {}", testfile.display());
@@ -948,6 +951,13 @@ impl Config {
948951
raw,
949952
testfile.display()
950953
);
954+
} else if FORBIDDEN_REVISION_NAMES.contains(&revision) {
955+
panic!(
956+
"invalid revision: `{}` in line `{}`: {}",
957+
revision,
958+
raw,
959+
testfile.display()
960+
);
951961
}
952962
existing.push(revision);
953963
}

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

+12
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,18 @@ fn test_duplicate_revisions() {
553553
parse_rs(&config, "//@ revisions: rpass1 rpass1");
554554
}
555555

556+
#[test]
557+
fn test_forbidden_revisions() {
558+
let config: Config = cfg().build();
559+
let revisions = ["CHECK", "COM", "NEXT", "SAME", "EMPTY", "NOT", "COUNT", "DAG", "LABEL"];
560+
for rev in revisions {
561+
let res = std::panic::catch_unwind(|| {
562+
parse_rs(&config, format!("//@ revisions: {rev}").as_str());
563+
});
564+
assert!(res.is_err());
565+
}
566+
}
567+
556568
#[test]
557569
fn ignore_arch() {
558570
let archs = [

0 commit comments

Comments
 (0)