[clang] clang-format/test: Anchor the empty .clang-format-ignore to test_exec_root (PR #203444)
Nicolai Hähnle via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 11 20:01:47 PDT 2026
https://github.com/nhaehnle created https://github.com/llvm/llvm-project/pull/203444
The test suite's lit.local.cfg creates an empty .clang-format-ignore at
config discovery time to protect the multiple-inputs[-inplace].cpp tests
that work on files in temporary locations.
This file should be written to where the tests execute instead of the
CWD during config discovery. The CWD might not even be an ancestor of
where the tests execute, and it might be the repository root which does
have a .clang-format-ignore that is incorrectly clobbered without this
change.
An alternative would be to just fix the tests that need to be protected,
but having a blanket guard like this does seem like a reasonable thing
to do.
Fixes: 915de1a5889c ("Generate empty .clang-format-ignore before running tests (#136154)")
>From bb87842a8612044cc6cf3d1ef70e7a3e5d955c8d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nicolai=20H=C3=A4hnle?= <nicolai.haehnle at amd.com>
Date: Thu, 11 Jun 2026 17:05:46 -0700
Subject: [PATCH] clang-format/test: Anchor the empty .clang-format-ignore to
test_exec_root
The test suite's lit.local.cfg creates an empty .clang-format-ignore at
config discovery time to protect the multiple-inputs[-inplace].cpp tests
that work on files in temporary locations.
This file should be written to where the tests execute instead of the
CWD during config discovery. The CWD might not even be an ancestor of
where the tests execute, and it might be the repository root which does
have a .clang-format-ignore that is incorrectly clobbered without this
change.
An alternative would be to just fix the tests that need to be protected,
but having a blanket guard like this does seem like a reasonable thing
to do.
Fixes: 915de1a5889c ("Generate empty .clang-format-ignore before running tests (#136154)")
commit-id:fe858dac
---
clang/test/Format/lit.local.cfg | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/clang/test/Format/lit.local.cfg b/clang/test/Format/lit.local.cfg
index faa4b7f20fbcc..13e244ffd5d15 100644
--- a/clang/test/Format/lit.local.cfg
+++ b/clang/test/Format/lit.local.cfg
@@ -29,7 +29,7 @@ config.suffixes = [
if platform.system() == "AIX":
config.test_format = lit.formats.ShTest()
-# Create an empty .clang-format-ignore file so that tests don't get messed
-# up if one exists higher in the tree
-with open(".clang-format-ignore", "w"):
+# Create an empty .clang-format-ignore file in the test execution root so that
+# tests don't get messed up if one exists higher in the tree.
+with open(os.path.join(config.test_exec_root, ".clang-format-ignore"), "w"):
pass
More information about the cfe-commits
mailing list