Skip to content

Commit a64dc6d

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 1f8899c commit a64dc6d

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

src/tools/compiletest/src/runtest.rs

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

0 commit comments

Comments
 (0)