Error on trying to use revisions in run-make tests

Currently `run-make` tests do not support revisions.
This commit is contained in:
许杰友 Jieyou Xu (Joe) 2024-10-13 00:35:25 +08:00
parent 8f8bee4f60
commit 9f0f0352f7
2 changed files with 14 additions and 5 deletions

View File

@ -59,7 +59,7 @@ pub fn from_reader<R: Read>(config: &Config, testfile: &Path, rdr: R) -> Self {
rdr, rdr,
&mut |HeaderLine { directive: ln, .. }| { &mut |HeaderLine { directive: ln, .. }| {
parse_and_update_aux(config, ln, &mut props.aux); parse_and_update_aux(config, ln, &mut props.aux);
config.parse_and_update_revisions(ln, &mut props.revisions); config.parse_and_update_revisions(testfile, ln, &mut props.revisions);
}, },
); );
@ -391,7 +391,7 @@ fn split_flags(flags: &str) -> Vec<String> {
has_edition = true; has_edition = true;
} }
config.parse_and_update_revisions(ln, &mut self.revisions); config.parse_and_update_revisions(testfile, ln, &mut self.revisions);
if let Some(flags) = config.parse_name_value_directive(ln, RUN_FLAGS) { if let Some(flags) = config.parse_name_value_directive(ln, RUN_FLAGS) {
self.run_flags.extend(split_flags(&flags)); self.run_flags.extend(split_flags(&flags));
@ -907,12 +907,21 @@ fn iter_header(
} }
impl Config { impl Config {
fn parse_and_update_revisions(&self, line: &str, existing: &mut Vec<String>) { fn parse_and_update_revisions(&self, testfile: &Path, line: &str, existing: &mut Vec<String>) {
if let Some(raw) = self.parse_name_value_directive(line, "revisions") { 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());
}
let mut duplicates: HashSet<_> = existing.iter().cloned().collect(); let mut duplicates: HashSet<_> = existing.iter().cloned().collect();
for revision in raw.split_whitespace().map(|r| r.to_string()) { for revision in raw.split_whitespace().map(|r| r.to_string()) {
if !duplicates.insert(revision.clone()) { if !duplicates.insert(revision.clone()) {
panic!("Duplicate revision: `{}` in line `{}`", revision, raw); panic!(
"duplicate revision: `{}` in line `{}`: {}",
revision,
raw,
testfile.display()
);
} }
existing.push(revision); existing.push(revision);
} }

View File

@ -423,7 +423,7 @@ fn test_extract_version_range() {
} }
#[test] #[test]
#[should_panic(expected = "Duplicate revision: `rpass1` in line ` rpass1 rpass1`")] #[should_panic(expected = "duplicate revision: `rpass1` in line ` rpass1 rpass1`")]
fn test_duplicate_revisions() { fn test_duplicate_revisions() {
let config: Config = cfg().build(); let config: Config = cfg().build();
parse_rs(&config, "//@ revisions: rpass1 rpass1"); parse_rs(&config, "//@ revisions: rpass1 rpass1");