[Lldb-commits] [PATCH] D14157: Make dosep correctly invoke the top level script when doing the multiprocessing fork

Zachary Turner via lldb-commits lldb-commits at lists.llvm.org
Wed Oct 28 13:49:27 PDT 2015


zturner created this revision.
zturner added a reviewer: tfiala.
zturner added a subscriber: lldb-commits.

This patch disables the ability to run `packages/Python/lldbsuite/test/dotest.py` as a standalone script by explicitly erroring out if it detects that to be the case.  Then, it fixes up the place where `dosep` exec's the script to actually exect the main script that we're running from, instead of hardcoding a path to `dotest.py`, which is now wrong in the presence of being imported as a package.

http://reviews.llvm.org/D14157

Files:
  packages/Python/lldbsuite/test/dosep.py
  packages/Python/lldbsuite/test/dotest.py

Index: packages/Python/lldbsuite/test/dotest.py
===================================================================
--- packages/Python/lldbsuite/test/dotest.py
+++ packages/Python/lldbsuite/test/dotest.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
 """
 A simple testing framework for lldb using python's unit testing framework.
 
@@ -2036,4 +2034,5 @@
     exitTestSuite(failed)
 
 if __name__ == "__main__":
-    run_suite()
\ No newline at end of file
+    print(__file__ + " is for use as a module only.  It should not be run as a standalone script.")
+    sys.exit(-1)
Index: packages/Python/lldbsuite/test/dosep.py
===================================================================
--- packages/Python/lldbsuite/test/dosep.py
+++ packages/Python/lldbsuite/test/dosep.py
@@ -279,11 +279,12 @@
     return process_driver.results
 
 
-def process_dir(root, files, test_root, dotest_argv, inferior_pid_events):
+def process_dir(root, files, dotest_argv, inferior_pid_events):
     """Examine a directory for tests, and invoke any found within it."""
     results = []
     for name in files:
-        script_file = os.path.join(test_root, "dotest.py")
+        import __main__ as main
+        script_file = main.__file__
         command = ([sys.executable, script_file] +
                    dotest_argv +
                    ["--inferior", "-p", name, root])
@@ -966,7 +967,7 @@
     test_work_items = []
     find_test_files_in_dir_tree(
         test_subdir, lambda testdir, test_files: test_work_items.append([
-            test_subdir, test_files, test_directory, dotest_argv, None]))
+            test_subdir, test_files, dotest_argv, None]))
 
     # Convert test work items into test results using whatever
     # was provided as the test run function.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14157.38684.patch
Type: text/x-patch
Size: 1765 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20151028/0c4ca6e8/attachment.bin>


More information about the lldb-commits mailing list