Skip to content

Commit a6c5a11

Browse files
committed
Simplify existing code for setting filecheck flags
This removes a version check for LLVM >=13, and specifies prefixes as a series of independent `--check-prefix` flags instead of a single `--check-prefixes`.
1 parent d976ed0 commit a6c5a11

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

src/tools/compiletest/src/runtest.rs

+17-11
Original file line numberDiff line numberDiff line change
@@ -2907,23 +2907,29 @@ impl<'test> TestCx<'test> {
29072907
fn verify_with_filecheck(&self, output: &Path) -> ProcRes {
29082908
let mut filecheck = Command::new(self.config.llvm_filecheck.as_ref().unwrap());
29092909
filecheck.arg("--input-file").arg(output).arg(&self.testpaths.file);
2910+
29102911
// It would be more appropriate to make most of the arguments configurable through
29112912
// a comment-attribute similar to `compile-flags`. For example, --check-prefixes is a very
29122913
// useful flag.
29132914
//
29142915
// For now, though…
2915-
let prefix_for_target =
2916-
if self.config.target.contains("msvc") { "MSVC" } else { "NONMSVC" };
2917-
let prefixes = if let Some(rev) = self.revision {
2918-
format!("CHECK,{},{}", prefix_for_target, rev)
2919-
} else {
2920-
format!("CHECK,{}", prefix_for_target)
2921-
};
2922-
if self.config.llvm_version.unwrap_or(0) >= 130000 {
2923-
filecheck.args(&["--allow-unused-prefixes", "--check-prefixes", &prefixes]);
2924-
} else {
2925-
filecheck.args(&["--check-prefixes", &prefixes]);
2916+
2917+
// Because we use custom prefixes, we also have to register the default prefix.
2918+
filecheck.arg("--check-prefix=CHECK");
2919+
2920+
// Some tests use the current revision name as a check prefix.
2921+
if let Some(rev) = self.revision {
2922+
filecheck.arg("--check-prefix").arg(rev);
29262923
}
2924+
2925+
// Some tests also expect either the MSVC or NONMSVC prefix to be defined.
2926+
let msvc_or_not = if self.config.target.contains("msvc") { "MSVC" } else { "NONMSVC" };
2927+
filecheck.arg("--check-prefix").arg(msvc_or_not);
2928+
2929+
// The filecheck tool normally fails if a prefix is defined but not used.
2930+
// However, we define several prefixes globally for all tests.
2931+
filecheck.arg("--allow-unused-prefixes");
2932+
29272933
// Provide more context on failures.
29282934
filecheck.args(&["--dump-input-context", "100"]);
29292935
self.compose_and_run(filecheck, "", None, None)

0 commit comments

Comments
 (0)