[llvm] 18cec02 - [lit] Deprecate execute_external=True in ShTest (#201732)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 11 07:53:14 PDT 2026
Author: Aiden Grossman
Date: 2026-06-11T07:53:09-07:00
New Revision: 18cec023e10f4067b0e0bfa48c9a4209de6fd699
URL: https://github.com/llvm/llvm-project/commit/18cec023e10f4067b0e0bfa48c9a4209de6fd699
DIFF: https://github.com/llvm/llvm-project/commit/18cec023e10f4067b0e0bfa48c9a4209de6fd699.diff
LOG: [lit] Deprecate execute_external=True in ShTest (#201732)
Implementing the deprecation part of
https://discourse.llvm.org/t/rfc-removal-of-the-lit-external-shell/90951.
I made this a hard error with an additional keyword argument to opt out
of the warning behavior given we don't have the facilities to trivially
log within ShTest like we do in the rest of lit, and I think forcing
people to explicitly acknowledge that things are deprecated is not a bad
thing.
Added:
Modified:
llvm/utils/lit/lit/formats/shtest.py
llvm/utils/lit/tests/Inputs/per-test-coverage-by-lit-cfg/lit.cfg
llvm/utils/lit/tests/Inputs/per-test-coverage/lit.cfg
llvm/utils/lit/tests/Inputs/shtest-external-shell-kill/lit.cfg
llvm/utils/lit/tests/Inputs/shtest-format/external_shell/lit.local.cfg
llvm/utils/lit/tests/Inputs/shtest-readfile/lit.cfg
llvm/utils/lit/tests/Inputs/shtest-run-at-line/external-shell/lit.local.cfg
llvm/utils/lit/tests/Inputs/shtest-timeout/lit.cfg
Removed:
################################################################################
diff --git a/llvm/utils/lit/lit/formats/shtest.py b/llvm/utils/lit/lit/formats/shtest.py
index 5529b75f51d4f..80490c1f3227a 100644
--- a/llvm/utils/lit/lit/formats/shtest.py
+++ b/llvm/utils/lit/lit/formats/shtest.py
@@ -17,8 +17,19 @@ class ShTest(FileBasedTest):
"""
def __init__(
- self, execute_external=False, extra_substitutions=[], preamble_commands=[]
+ self,
+ execute_external=False,
+ extra_substitutions=[],
+ preamble_commands=[],
+ force_execute_external=False,
):
+ if execute_external and not force_execute_external:
+ raise ValueError(
+ "execute_external=True is deprected as of LLVM-23 and the option will "
+ "be removed in LLVM-24. Please move to using the internal shell "
+ "(execute_external=False). If you still need to force external "
+ "execution to allow time for migration, set force_execute_external=True"
+ )
self.execute_external = execute_external
self.extra_substitutions = extra_substitutions
self.preamble_commands = preamble_commands
diff --git a/llvm/utils/lit/tests/Inputs/per-test-coverage-by-lit-cfg/lit.cfg b/llvm/utils/lit/tests/Inputs/per-test-coverage-by-lit-cfg/lit.cfg
index b83d61eec595b..7487b09a228a2 100644
--- a/llvm/utils/lit/tests/Inputs/per-test-coverage-by-lit-cfg/lit.cfg
+++ b/llvm/utils/lit/tests/Inputs/per-test-coverage-by-lit-cfg/lit.cfg
@@ -3,9 +3,11 @@ import os
config.name = "per-test-coverage-by-lit-cfg"
config.suffixes = [".py"]
+use_external_shell = eval(lit_config.params.get("execute_external"))
config.test_format = lit.formats.ShTest(
- execute_external=eval(lit_config.params.get("execute_external")),
- preamble_commands=["%{python} %s | FileCheck -DINDEX=0 %s"]
+ execute_external=use_external_shell,
+ preamble_commands=["%{python} %s | FileCheck -DINDEX=0 %s"],
+ force_execute_external=use_external_shell
)
lit_config.per_test_coverage = True
config.substitutions.append(("%{python}", '"%s"' % (sys.executable)))
diff --git a/llvm/utils/lit/tests/Inputs/per-test-coverage/lit.cfg b/llvm/utils/lit/tests/Inputs/per-test-coverage/lit.cfg
index 9ffca93def73f..19d77b80e64f1 100644
--- a/llvm/utils/lit/tests/Inputs/per-test-coverage/lit.cfg
+++ b/llvm/utils/lit/tests/Inputs/per-test-coverage/lit.cfg
@@ -3,8 +3,10 @@ import os
config.name = "per-test-coverage"
config.suffixes = [".py"]
+use_external_shell = eval(lit_config.params.get("execute_external"))
config.test_format = lit.formats.ShTest(
- execute_external=eval(lit_config.params.get("execute_external")),
- preamble_commands=["%{python} %s | FileCheck -DINDEX=0 %s"]
+ execute_external=use_external_shell,
+ preamble_commands=["%{python} %s | FileCheck -DINDEX=0 %s"],
+ force_execute_external=use_external_shell
)
config.substitutions.append(("%{python}", '"%s"' % (sys.executable)))
diff --git a/llvm/utils/lit/tests/Inputs/shtest-external-shell-kill/lit.cfg b/llvm/utils/lit/tests/Inputs/shtest-external-shell-kill/lit.cfg
index d10594dc525f5..1f9ccb7d08091 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-external-shell-kill/lit.cfg
+++ b/llvm/utils/lit/tests/Inputs/shtest-external-shell-kill/lit.cfg
@@ -1,5 +1,6 @@
import lit.formats
-config.test_format = lit.formats.ShTest(execute_external=True)
+config.test_format = lit.formats.ShTest(execute_external=True,
+ force_execute_external=True)
config.name = "shtest-external-shell-kill"
config.suffixes = [".txt"]
diff --git a/llvm/utils/lit/tests/Inputs/shtest-format/external_shell/lit.local.cfg b/llvm/utils/lit/tests/Inputs/shtest-format/external_shell/lit.local.cfg
index 4cc234df4fcaa..20c399010ed7d 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-format/external_shell/lit.local.cfg
+++ b/llvm/utils/lit/tests/Inputs/shtest-format/external_shell/lit.local.cfg
@@ -1,3 +1,4 @@
import lit.formats
-config.test_format = lit.formats.ShTest(execute_external=True)
+config.test_format = lit.formats.ShTest(execute_external=True,
+ force_execute_external=True)
diff --git a/llvm/utils/lit/tests/Inputs/shtest-readfile/lit.cfg b/llvm/utils/lit/tests/Inputs/shtest-readfile/lit.cfg
index 80af27f57d35c..e044a1a15d212 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-readfile/lit.cfg
+++ b/llvm/utils/lit/tests/Inputs/shtest-readfile/lit.cfg
@@ -7,7 +7,8 @@ config.name = "shtest-readfile"
config.suffixes = [".txt"]
lit_shell_env = os.environ.get("LIT_USE_INTERNAL_SHELL")
use_lit_shell = lit.util.pythonize_bool(lit_shell_env)
-config.test_format = lit.formats.ShTest(execute_external=not use_lit_shell)
+config.test_format = lit.formats.ShTest(execute_external=not use_lit_shell,
+ force_execute_external=not use_lit_shell)
config.test_source_root = None
config.test_exec_root = None
config.substitutions.append(("%{python}", '"%s"' % (sys.executable)))
diff --git a/llvm/utils/lit/tests/Inputs/shtest-run-at-line/external-shell/lit.local.cfg b/llvm/utils/lit/tests/Inputs/shtest-run-at-line/external-shell/lit.local.cfg
index 913495fbb3fe3..81a13c69649d6 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-run-at-line/external-shell/lit.local.cfg
+++ b/llvm/utils/lit/tests/Inputs/shtest-run-at-line/external-shell/lit.local.cfg
@@ -1,6 +1,7 @@
import lit.formats
-config.test_format = lit.formats.ShTest(execute_external=True)
+config.test_format = lit.formats.ShTest(execute_external=True,
+ force_execute_external=True)
config.substitutions.append(("%{cmds-with-newlines}", """
echo abc |
FileCheck %s &&
diff --git a/llvm/utils/lit/tests/Inputs/shtest-timeout/lit.cfg b/llvm/utils/lit/tests/Inputs/shtest-timeout/lit.cfg
index 3a72f35024eb2..3e2dc3a130e72 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-timeout/lit.cfg
+++ b/llvm/utils/lit/tests/Inputs/shtest-timeout/lit.cfg
@@ -21,7 +21,8 @@ if configSetTimeout != "0":
# Try setting the max individual test time in the configuration
config.maxIndividualTestTime = int(configSetTimeout)
-config.test_format = lit.formats.ShTest(execute_external=externalShell)
+config.test_format = lit.formats.ShTest(execute_external=externalShell,
+ force_execute_external=externalShell)
config.suffixes = [".py"]
config.test_source_root = os.path.dirname(__file__)
More information about the llvm-commits
mailing list