Skip to content

Conversation

cmtice
Copy link
Contributor

@cmtice cmtice commented Sep 8, 2025

This patch updates the clang-tools-extra lit test config to use the internal shell by default. This has some performance advantages (~10-15%) and also produces nicer failure output. It also updates one clang-tools-extra test, so that it passes using the internal shell. All the other tests appear to pass using the internal shell.

This patch updates the clang-tools-extra lit test config to use the
internal shell by default. This has some performance advantages
(~10-15%) and also produces nicer failure output. It also updates
one clang-tools-extra test, so that it passes using the internal shell.
All the other tests appear to pass using the internal shell.
@llvmbot
Copy link
Member

llvmbot commented Sep 8, 2025

@llvm/pr-subscribers-clang-tools-extra

Author: None (cmtice)

Changes

This patch updates the clang-tools-extra lit test config to use the internal shell by default. This has some performance advantages (~10-15%) and also produces nicer failure output. It also updates one clang-tools-extra test, so that it passes using the internal shell. All the other tests appear to pass using the internal shell.


Full diff: https://github.com/llvm/llvm-project/pull/157572.diff

2 Files Affected:

  • (modified) clang-tools-extra/test/clang-apply-replacements/crlf.cpp (+1-1)
  • (modified) clang-tools-extra/test/lit.cfg.py (+9-1)
diff --git a/clang-tools-extra/test/clang-apply-replacements/crlf.cpp b/clang-tools-extra/test/clang-apply-replacements/crlf.cpp
index f40429e354e02..266f806e70b95 100644
--- a/clang-tools-extra/test/clang-apply-replacements/crlf.cpp
+++ b/clang-tools-extra/test/clang-apply-replacements/crlf.cpp
@@ -1,5 +1,5 @@
 // RUN: mkdir -p %t.dir/Inputs/crlf
-// RUN: cat %S/Inputs/crlf/crlf.cpp > %t.dir/Inputs/crlf/crlf.cpp
+// RUN: cp %S/Inputs/crlf/crlf.cpp %t.dir/Inputs/crlf/crlf.cpp
 // RUN: sed "s#\$(path)#%/t.dir/Inputs/crlf#" %S/Inputs/crlf/file1.yaml > %t.dir/Inputs/crlf/file1.yaml
 // RUN: clang-apply-replacements %t.dir/Inputs/crlf
 // RUN: diff %t.dir/Inputs/crlf/crlf.cpp %S/Inputs/crlf/crlf.cpp.expected
diff --git a/clang-tools-extra/test/lit.cfg.py b/clang-tools-extra/test/lit.cfg.py
index bc82a14a0aed1..b503c659f6022 100644
--- a/clang-tools-extra/test/lit.cfg.py
+++ b/clang-tools-extra/test/lit.cfg.py
@@ -13,7 +13,15 @@
 config.name = "Clang Tools"
 
 # testFormat: The test format to use to interpret tests.
-config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
+# We prefer the lit internal shell which provides a better user experience on
+# failures and is faster unless the user explicitly disables it with
+# LIT_USE_INTERNAL_SHELL=0 env var.
+use_lit_shell = True
+lit_shell_env = os.environ.get("LIT_USE_INTERNAL_SHELL")
+if lit_shell_env:
+    use_lit_shell = lit.util.pythonize_bool(lit_shell_env)
+
+config.test_format = lit.formats.ShTest(not use_lit_shell)
 
 # suffixes: A list of file extensions to treat as test files.
 config.suffixes = [

@cmtice cmtice merged commit 1f783d7 into llvm:main Sep 9, 2025
11 checks passed
rupprecht added a commit that referenced this pull request Sep 9, 2025
…7728)

After #157572, the invocation to clang-tidy fails w/ `Could not open
<...>/crlf.cpp.tmp.dir/Inputs/crlf/crlf.cpp for writing` if run in an
environment where the source tree is mounted read-only. This is because
`cat` was creating a new file in a writeable dir, but running `cp`
preserves the readonly file permissions from the source tree.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants