From 1e432dd9f4b165ac36db19082176ddf6a828d0ca Mon Sep 17 00:00:00 2001 From: Zalathar Date: Sat, 3 Feb 2024 11:06:59 +1100 Subject: [PATCH] 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`. --- src/tools/compiletest/src/runtest.rs | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 27a8079d893..3c417f3161b 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -2906,23 +2906,29 @@ fn compile_test_and_save_assembly(&self) -> (ProcRes, PathBuf) { fn verify_with_filecheck(&self, output: &Path) -> ProcRes { let mut filecheck = Command::new(self.config.llvm_filecheck.as_ref().unwrap()); filecheck.arg("--input-file").arg(output).arg(&self.testpaths.file); + // It would be more appropriate to make most of the arguments configurable through // a comment-attribute similar to `compile-flags`. For example, --check-prefixes is a very // useful flag. // // For now, though… - let prefix_for_target = - if self.config.target.contains("msvc") { "MSVC" } else { "NONMSVC" }; - let prefixes = if let Some(rev) = self.revision { - format!("CHECK,{},{}", prefix_for_target, rev) - } else { - format!("CHECK,{}", prefix_for_target) - }; - if self.config.llvm_version.unwrap_or(0) >= 130000 { - filecheck.args(&["--allow-unused-prefixes", "--check-prefixes", &prefixes]); - } else { - filecheck.args(&["--check-prefixes", &prefixes]); + + // Because we use custom prefixes, we also have to register the default prefix. + filecheck.arg("--check-prefix=CHECK"); + + // Some tests use the current revision name as a check prefix. + if let Some(rev) = self.revision { + filecheck.arg("--check-prefix").arg(rev); } + + // Some tests also expect either the MSVC or NONMSVC prefix to be defined. + let msvc_or_not = if self.config.target.contains("msvc") { "MSVC" } else { "NONMSVC" }; + filecheck.arg("--check-prefix").arg(msvc_or_not); + + // The filecheck tool normally fails if a prefix is defined but not used. + // However, we define several prefixes globally for all tests. + filecheck.arg("--allow-unused-prefixes"); + // Provide more context on failures. filecheck.args(&["--dump-input-context", "100"]); self.compose_and_run(filecheck, "", None, None)