From 1e8cd1f7a68bf17b0b8cda356562968e4145a215 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Tue, 21 Apr 2026 22:40:00 +1000 Subject: [PATCH] Support `//@ skip-filecheck` in codegen and assembly tests Skipping FileCheck in codegen/assembly tests is normally not very useful, but a small number of existing tests were using `//@ build-pass` to do so anyway, so it's clearer for them to explicitly use `//@ skip-filecheck` instead. --- src/doc/rustc-dev-guide/src/tests/directives.md | 2 +- src/tools/compiletest/src/directives.rs | 1 - src/tools/compiletest/src/directives/handlers.rs | 2 +- src/tools/compiletest/src/runtest/assembly.rs | 8 +++++--- src/tools/compiletest/src/runtest/codegen.rs | 13 ++++++------- .../scalable-vectors/tuple-intrinsics.rs | 3 ++- tests/codegen-llvm/simd/simd-wide-sum.rs | 2 +- 7 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/tests/directives.md b/src/doc/rustc-dev-guide/src/tests/directives.md index 506deb1942db..d536d324cb2b 100644 --- a/src/doc/rustc-dev-guide/src/tests/directives.md +++ b/src/doc/rustc-dev-guide/src/tests/directives.md @@ -327,7 +327,7 @@ The following directives affect how certain command-line tools are invoked, in test suites that use those tools: - `skip-filecheck` avoids running LLVM's `FileCheck` tool in tests that would normally run it to check output. - - Used by mir-opt tests. + - Used by codegen tests, assembly tests, and mir-opt tests. - `filecheck-flags` adds extra flags when running LLVM's `FileCheck` tool. - Used by [codegen tests](compiletest.md#codegen-tests), [assembly tests](compiletest.md#assembly-tests), and diff --git a/src/tools/compiletest/src/directives.rs b/src/tools/compiletest/src/directives.rs index fd5c9d02b6d7..d87cb915b07b 100644 --- a/src/tools/compiletest/src/directives.rs +++ b/src/tools/compiletest/src/directives.rs @@ -442,7 +442,6 @@ fn update_pass_mode(&mut self, ln: &DirectiveLine<'_>, config: &Config) { let check_no_run = |s| match (config.mode, s) { (TestMode::Ui, _) => (), (TestMode::Crashes, _) => (), - (TestMode::Codegen, "build-pass") => (), (mode, _) => panic!("`{s}` directive is not supported in `{mode}` tests"), }; let pass_mode = if config.parse_name_directive(ln, "check-pass") { diff --git a/src/tools/compiletest/src/directives/handlers.rs b/src/tools/compiletest/src/directives/handlers.rs index 1f2d9709ee9d..a1d6bd308823 100644 --- a/src/tools/compiletest/src/directives/handlers.rs +++ b/src/tools/compiletest/src/directives/handlers.rs @@ -316,7 +316,7 @@ fn make_directive_handlers_map() -> HashMap<&'static str, Handler> { let directive_name = ln.name; // FIXME(Zalathar): Someday we should add unified support for declaring // and checking which modes are supported by each directive. - if !matches!(config.mode, TestMode::MirOpt) { + if !matches!(config.mode, TestMode::Assembly | TestMode::Codegen | TestMode::MirOpt) { panic!( "directive `//@ {directive_name}` is not supported by this test suite (mode: {mode:?})", mode = config.mode diff --git a/src/tools/compiletest/src/runtest/assembly.rs b/src/tools/compiletest/src/runtest/assembly.rs index 18027328abfe..0d41c29075c4 100644 --- a/src/tools/compiletest/src/runtest/assembly.rs +++ b/src/tools/compiletest/src/runtest/assembly.rs @@ -13,9 +13,11 @@ pub(super) fn run_assembly_test(&self) { self.fatal_proc_rec("compilation failed!", &proc_res); } - let proc_res = self.verify_with_filecheck(&output_path); - if !proc_res.status.success() { - self.fatal_proc_rec("verification with 'FileCheck' failed", &proc_res); + if !self.props.skip_filecheck { + let proc_res = self.verify_with_filecheck(&output_path); + if !proc_res.status.success() { + self.fatal_proc_rec("verification with 'FileCheck' failed", &proc_res); + } } } diff --git a/src/tools/compiletest/src/runtest/codegen.rs b/src/tools/compiletest/src/runtest/codegen.rs index 6e61ab5e46d6..60da1ff40f17 100644 --- a/src/tools/compiletest/src/runtest/codegen.rs +++ b/src/tools/compiletest/src/runtest/codegen.rs @@ -1,4 +1,4 @@ -use super::{PassMode, TestCx}; +use super::TestCx; impl TestCx<'_> { pub(super) fn run_codegen_test(&self) { @@ -11,12 +11,11 @@ pub(super) fn run_codegen_test(&self) { self.fatal_proc_rec("compilation failed!", &proc_res); } - if let Some(PassMode::Build) = self.pass_mode() { - return; - } - let proc_res = self.verify_with_filecheck(&output_path); - if !proc_res.status.success() { - self.fatal_proc_rec("verification with 'FileCheck' failed", &proc_res); + if !self.props.skip_filecheck { + let proc_res = self.verify_with_filecheck(&output_path); + if !proc_res.status.success() { + self.fatal_proc_rec("verification with 'FileCheck' failed", &proc_res); + } } } } diff --git a/tests/codegen-llvm/scalable-vectors/tuple-intrinsics.rs b/tests/codegen-llvm/scalable-vectors/tuple-intrinsics.rs index e19fc40cb9d6..7a990b29e6ca 100644 --- a/tests/codegen-llvm/scalable-vectors/tuple-intrinsics.rs +++ b/tests/codegen-llvm/scalable-vectors/tuple-intrinsics.rs @@ -1,4 +1,5 @@ -//@ build-pass +// FIXME: The FileCheck directives in this test are unchecked and probably broken. +//@ skip-filecheck //@ only-aarch64 #![crate_type = "lib"] #![allow(incomplete_features, internal_features)] diff --git a/tests/codegen-llvm/simd/simd-wide-sum.rs b/tests/codegen-llvm/simd/simd-wide-sum.rs index 95117b2c7488..68febe00d1b9 100644 --- a/tests/codegen-llvm/simd/simd-wide-sum.rs +++ b/tests/codegen-llvm/simd/simd-wide-sum.rs @@ -3,7 +3,7 @@ //@ edition: 2021 //@ only-x86_64 //@ [mir-opt3]compile-flags: -Zmir-opt-level=3 -//@ [mir-opt3]build-pass +//@ [mir-opt3] skip-filecheck // mir-opt3 is a regression test for https://github.com/rust-lang/rust/issues/98016