Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/tools/compiletest/src/directives/line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ pub(crate) fn line_directive<'a>(

revision = Some(line_revision);
raw_directive = after_close_bracket.trim_start();

if line_revision.contains(",") {
let suggestion: Vec<_> = line_revision
.split(",")
.map(|revision| {
format!("{COMPILETEST_DIRECTIVE_PREFIX} [{revision}]: {raw_directive}")
})
.collect();
panic!(
"malformed condition directive: multiple revisions aren't supported yet in `{}`, split them like\n{}",
original_line,
suggestion.join("\n"),
);
}
} else {
revision = None;
raw_directive = after_comment;
Expand Down
15 changes: 15 additions & 0 deletions src/tools/compiletest/src/directives/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,21 @@ fn test_miropt_mode_forbidden_revisions() {
parse_early_props(&config, "//@ revisions: CHECK");
}

#[test]
#[should_panic(expected = "malformed condition directive: multiple revisions aren't supported yet")]
fn test_multiple_revisions_in_directive() {
let directive = "//@ [foo,bar] compile-flags: -Z hello";

// The problem: this is seen as a single revision.
let line_directive = line_directive(Utf8Path::new("foo.txt"), LineNumber::ZERO, directive);
assert!(line_directive.is_some());
assert_eq!(Some("foo,bar"), line_directive.unwrap().revision);

// The solution for now: forbid directives from having multiple revisions.
let config: Config = cfg().build();
parse_early_props(&config, directive);
}

#[test]
fn test_forbidden_revisions_allowed_in_non_filecheck_dir() {
let revisions = ["CHECK", "COM", "NEXT", "SAME", "EMPTY", "NOT", "COUNT", "DAG", "LABEL"];
Expand Down
Loading