[llvm] Fix lit testing to support standalone testing (PR #170365)
Mehdi Amini via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 2 13:06:48 PST 2025
https://github.com/joker-eph created https://github.com/llvm/llvm-project/pull/170365
To be able to test lit without having a configuration of LLVM, we need to support invocations that are not going through the lit.site.cfg and thus don't have a llvm_config set-up.
>From 6b3329c420bf32c9e2406bd8964a4d03316dce7b Mon Sep 17 00:00:00 2001
From: Mehdi Amini <joker.eph at gmail.com>
Date: Tue, 2 Dec 2025 13:04:57 -0800
Subject: [PATCH] Fix lit testing to support standalone testing
To be able to test lit without having a configuration of LLVM,
we need to support invocations that are not going through the
lit.site.cfg and thus don't have a llvm_config set-up.
---
llvm/utils/lit/tests/lit.cfg | 5 ++++-
llvm/utils/lit/tests/windows-pools.py | 2 +-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/llvm/utils/lit/tests/lit.cfg b/llvm/utils/lit/tests/lit.cfg
index 61ee0154071df..922fbd6c9c872 100644
--- a/llvm/utils/lit/tests/lit.cfg
+++ b/llvm/utils/lit/tests/lit.cfg
@@ -9,6 +9,10 @@ import lit.formats
from lit.llvm import llvm_config
# Configuration file for the 'lit' test runner.
+# Note that lit can be tested in a "standalone" mode, where it is run
+# without using the LLVM build directory.
+# In this case the llvm_config object is not available, and we expect
+# tools like FileCheck to be available in the PATH.
# name: The name of this test suite.
config.name = "lit"
@@ -39,7 +43,6 @@ lit_path = os.path.abspath(lit_path)
# Required because some tests import the lit module
if llvm_config:
- llvm_config.use_default_substitutions()
llvm_config.with_environment("PYTHONPATH", lit_path, append_path=True)
else:
config.environment["PYTHONPATH"] = lit_path
diff --git a/llvm/utils/lit/tests/windows-pools.py b/llvm/utils/lit/tests/windows-pools.py
index 1e3a012dc1706..6ba43ecca6284 100644
--- a/llvm/utils/lit/tests/windows-pools.py
+++ b/llvm/utils/lit/tests/windows-pools.py
@@ -1,7 +1,7 @@
# Create a directory with 20 files and check the number of pools and workers per pool that lit will use.
# RUN: rm -Rf %t.dir && mkdir -p %t.dir
-# RUN: %python -c "for i in range(20): open(rf'%t.dir/file{i}.txt', 'w').write('RUN:')"
+# RUN: %{python} -c "for i in range(20): open(rf'%t.dir/file{i}.txt', 'w').write('RUN:')"
# RUN: echo "import lit.formats" > %t.dir/lit.cfg
# RUN: echo "config.name = \"top-level-suite\"" >> %t.dir/lit.cfg
More information about the llvm-commits
mailing list