Skip to content

Commit 9a8dec8

Browse files
committed
[lldb/Test] Run dotest.py with the Python LLDB was built with.
The Python used to run lit can be different from the Python LLDB was build with. One scenario where this happens is when LLVM can find the Python 3 interpreter, but not the Python 3 libraries, in which case LLDB build and links against Python 3. Without this change, you end up with an ModuleNotFoundError because of the mismatch. Instead of looking at the Python interpreter that's used to run lit, lldbtest should use the interpreter that matches the Python version LLDB was build against. Differential revision: https://reviews.llvm.org/D79519 (cherry picked from commit 7c6420e)
1 parent bdbad8d commit 9a8dec8

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lldb/test/API/lldbtest.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,15 @@ def execute(self, test, litConfig):
6363
return (lit.Test.UNSUPPORTED, 'Test is unsupported')
6464

6565
testPath, testFile = os.path.split(test.getSourcePath())
66+
67+
# The Python used to run lit can be different from the Python LLDB was
68+
# build with.
69+
executable = test.config.python_executable
70+
6671
# On Windows, the system does not always correctly interpret
6772
# shebang lines. To make sure we can execute the tests, add
6873
# python exe as the first parameter of the command.
69-
cmd = [sys.executable] + self.dotest_cmd + [testPath, '-p', testFile]
74+
cmd = [executable] + self.dotest_cmd + [testPath, '-p', testFile]
7075

7176
# On macOS, we can't do the DYLD_INSERT_LIBRARIES trick with a shim
7277
# python binary as the ASan interceptors get loaded too late. Also,
@@ -82,7 +87,7 @@ def execute(self, test, litConfig):
8287
if not os.path.isfile(copied_python):
8388
import shutil, subprocess
8489
python = subprocess.check_output([
85-
sys.executable,
90+
executable,
8691
os.path.join(os.path.dirname(os.path.realpath(__file__)),
8792
'get_darwin_real_python.py')
8893
]).decode('utf-8').strip()

0 commit comments

Comments
 (0)