[Lldb-commits] [lldb] 7c6420e - [lldb/Test] Run dotest.py with the Python LLDB was built with.

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Wed May 6 14:57:51 PDT 2020


Author: Jonas Devlieghere
Date: 2020-05-06T14:57:44-07:00
New Revision: 7c6420e43178b0c03618f445fd008606a8b2c95e

URL: https://github.com/llvm/llvm-project/commit/7c6420e43178b0c03618f445fd008606a8b2c95e
DIFF: https://github.com/llvm/llvm-project/commit/7c6420e43178b0c03618f445fd008606a8b2c95e.diff

LOG: [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

Added: 
    

Modified: 
    lldb/test/API/lldbtest.py

Removed: 
    


################################################################################
diff  --git a/lldb/test/API/lldbtest.py b/lldb/test/API/lldbtest.py
index dc108462c8a8..77654e4082eb 100644
--- a/lldb/test/API/lldbtest.py
+++ b/lldb/test/API/lldbtest.py
@@ -62,10 +62,15 @@ def execute(self, test, litConfig):
             return (lit.Test.UNSUPPORTED, 'Test is unsupported')
 
         testPath, testFile = os.path.split(test.getSourcePath())
+
+        # The Python used to run lit can be 
diff erent from the Python LLDB was
+        # build with.
+        executable = test.config.python_executable
+
         # On Windows, the system does not always correctly interpret
         # shebang lines.  To make sure we can execute the tests, add
         # python exe as the first parameter of the command.
-        cmd = [sys.executable] + self.dotest_cmd + [testPath, '-p', testFile]
+        cmd = [executable] + self.dotest_cmd + [testPath, '-p', testFile]
 
         builddir = getBuildDir(cmd)
         mkdir_p(builddir)
@@ -74,13 +79,13 @@ def execute(self, test, litConfig):
         # libraries into system binaries, but this can be worked around by
         # copying the binary into a 
diff erent location.
         if 'DYLD_INSERT_LIBRARIES' in test.config.environment and \
-                (sys.executable.startswith('/System/') or \
-                sys.executable.startswith('/usr/bin/')):
+                (executable.startswith('/System/') or \
+                executable.startswith('/usr/bin/')):
             copied_python = os.path.join(builddir, 'copied-system-python')
             if not os.path.isfile(copied_python):
                 import shutil, subprocess
                 python = subprocess.check_output([
-                    sys.executable,
+                    executable,
                     '-c',
                     'import sys; print(sys.executable)'
                 ]).decode('utf-8').strip()


        


More information about the lldb-commits mailing list