[Lldb-commits] [lldb] [lldb] Allow tests to share a single build (PR #181720)
via lldb-commits
lldb-commits at lists.llvm.org
Mon Feb 16 10:40:11 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: Dave Lee (kastiglione)
<details>
<summary>Changes</summary>
This allows a test to have a single shared build for the test case, instead of the
default behavior of a separate build for each test function.
Concretely, this results in a single build directory, named by the test. The default
behavior is to create many build directories, named `TestSomething.test_one`,
`TestSomething.test_two`, etc.
This is opt-in, tests get a single shared build by setting `SHARED_BUILD_TESTCASE` in
the test case class.
The goal here is to make the test suite eventually more efficient, by not repeatedly
building the same test source.
---
Full diff: https://github.com/llvm/llvm-project/pull/181720.diff
3 Files Affected:
- (modified) lldb/packages/Python/lldbsuite/test/lldbtest.py (+6-1)
- (modified) lldb/test/API/commands/dwim-print/TestDWIMPrint.py (+2)
- (modified) lldb/test/API/commands/dwim-print/objc/TestDWIMPrintObjC.py (+2)
``````````diff
diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 6034eca3b93f2..c8a69142394ee 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -569,6 +569,8 @@ class Base(unittest.TestCase):
# Can be overridden by the LLDB_TIME_WAIT_NEXT_LAUNCH environment variable.
timeWaitNextLaunch = 1.0
+ SHARED_BUILD_TESTCASE = False
+
@staticmethod
def compute_mydir(test_file):
"""Subclasses should call this function to correctly calculate the
@@ -754,7 +756,10 @@ def getSourceDir(self):
return os.path.join(configuration.test_src_root, self.mydir)
def getBuildDirBasename(self):
- return self.__class__.__module__ + "." + self.testMethodName
+ if self.__class__.SHARED_BUILD_TESTCASE:
+ return self.__class__.__module__
+ else:
+ return self.__class__.__module__ + "." + self.testMethodName
def getBuildDir(self):
"""Return the full path to the current test."""
diff --git a/lldb/test/API/commands/dwim-print/TestDWIMPrint.py b/lldb/test/API/commands/dwim-print/TestDWIMPrint.py
index 82ff59f74f41f..694671faedfc2 100644
--- a/lldb/test/API/commands/dwim-print/TestDWIMPrint.py
+++ b/lldb/test/API/commands/dwim-print/TestDWIMPrint.py
@@ -10,6 +10,8 @@
class TestCase(TestBase):
+ SHARED_BUILD_TESTCASE = True
+
def _run_cmd(self, cmd: str) -> str:
"""Run the given lldb command and return its output."""
result = lldb.SBCommandReturnObject()
diff --git a/lldb/test/API/commands/dwim-print/objc/TestDWIMPrintObjC.py b/lldb/test/API/commands/dwim-print/objc/TestDWIMPrintObjC.py
index 616d049459ab9..0a863c85bbc69 100644
--- a/lldb/test/API/commands/dwim-print/objc/TestDWIMPrintObjC.py
+++ b/lldb/test/API/commands/dwim-print/objc/TestDWIMPrintObjC.py
@@ -9,6 +9,8 @@
class TestCase(TestBase):
+ SHARED_BUILD_TESTCASE = True
+
@skipUnlessDarwin
def test(self):
self.build()
``````````
</details>
https://github.com/llvm/llvm-project/pull/181720
More information about the lldb-commits
mailing list