diff options
| author | Davis Muro <davis.ray.muro@gmail.com> | 2024-12-30 08:18:22 -0800 |
|---|---|---|
| committer | Davis Muro <davis.ray.muro@gmail.com> | 2024-12-30 08:48:59 -0800 |
| commit | 891041fbc994648f3ab771e9e9147a9fddc6006f (patch) | |
| tree | 284247913c7a6862989c26474b6ed50d0bca800b | |
| parent | c1566141b6ed24eaa11075aa7dfe6511fdf32231 (diff) | |
| download | rust-891041fbc994648f3ab771e9e9147a9fddc6006f.tar.gz rust-891041fbc994648f3ab771e9e9147a9fddc6006f.zip | |
deny usage of FileCheck prefixes as revision names
| -rw-r--r-- | src/tools/compiletest/src/header.rs | 10 | ||||
| -rw-r--r-- | src/tools/compiletest/src/header/tests.rs | 15 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 48149e3b897..3111793ab6a 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -934,6 +934,9 @@ fn iter_header( impl Config { fn parse_and_update_revisions(&self, testfile: &Path, line: &str, existing: &mut Vec<String>) { + const FORBIDDEN_REVISION_NAMES: [&str; 9] = + ["CHECK", "COM", "NEXT", "SAME", "EMPTY", "NOT", "COUNT", "DAG", "LABEL"]; + if let Some(raw) = self.parse_name_value_directive(line, "revisions") { if self.mode == Mode::RunMake { panic!("`run-make` tests do not support revisions: {}", testfile.display()); @@ -948,6 +951,13 @@ impl Config { raw, testfile.display() ); + } else if FORBIDDEN_REVISION_NAMES.contains(&revision.as_str()) { + panic!( + "invalid revision: `{}` in line `{}`: {}", + revision, + raw, + testfile.display() + ); } existing.push(revision); } diff --git a/src/tools/compiletest/src/header/tests.rs b/src/tools/compiletest/src/header/tests.rs index 618b66dfd4c..52bbd031498 100644 --- a/src/tools/compiletest/src/header/tests.rs +++ b/src/tools/compiletest/src/header/tests.rs @@ -554,6 +554,21 @@ fn test_duplicate_revisions() { } #[test] +fn test_forbidden_revisions() { + let config: Config = cfg().build(); + let revisions = ["CHECK", "COM", "NEXT", "SAME", "EMPTY", "NOT", "COUNT", "DAG", "LABEL"]; + for rev in revisions { + let res = std::panic::catch_unwind(|| { + parse_rs(&config, format!("//@ revisions: {rev}").as_str()); + }); + assert!(res.is_err()); + if let Some(msg) = res.unwrap_err().downcast_ref::<String>() { + assert!(msg.contains(format!("invalid revision: `{rev}` in line ` {rev}`").as_str())) + } + } +} + +#[test] fn ignore_arch() { let archs = [ ("x86_64-unknown-linux-gnu", "x86_64"), |
