[Python-checkins] r85469 - in python/branches/py3k/Lib/test: regrtest.py support.py

antoine.pitrou python-checkins at python.org
Thu Oct 14 13:12:00 CEST 2010


Author: antoine.pitrou
Date: Thu Oct 14 13:12:00 2010
New Revision: 85469

Log:
Inherit interpreter flags in parallel testing



Modified:
   python/branches/py3k/Lib/test/regrtest.py
   python/branches/py3k/Lib/test/support.py

Modified: python/branches/py3k/Lib/test/regrtest.py
==============================================================================
--- python/branches/py3k/Lib/test/regrtest.py	(original)
+++ python/branches/py3k/Lib/test/regrtest.py	Thu Oct 14 13:12:00 2010
@@ -391,9 +391,6 @@
         usage("-T and -j don't go together!")
     if use_mp and findleaks:
         usage("-l and -j don't go together!")
-    if use_mp and max(sys.flags):
-        # TODO: inherit the environment and the flags
-        print("Warning: flags and environment variables are ignored with -j option")
 
     good = []
     bad = []
@@ -534,6 +531,8 @@
                 )
                 yield (test, args_tuple)
         pending = tests_and_args()
+        opt_args = support.args_from_interpreter_flags()
+        base_cmd = [sys.executable] + opt_args + ['-m', 'test.regrtest']
         def work():
             # A worker thread.
             try:
@@ -544,8 +543,7 @@
                         output.put((None, None, None, None))
                         return
                     # -E is needed by some tests, e.g. test_import
-                    popen = Popen([sys.executable, '-E', '-m', 'test.regrtest',
-                                   '--slaveargs', json.dumps(args_tuple)],
+                    popen = Popen(base_cmd + ['--slaveargs', json.dumps(args_tuple)],
                                    stdout=PIPE, stderr=PIPE,
                                    universal_newlines=True,
                                    close_fds=(os.name != 'nt'))

Modified: python/branches/py3k/Lib/test/support.py
==============================================================================
--- python/branches/py3k/Lib/test/support.py	(original)
+++ python/branches/py3k/Lib/test/support.py	Thu Oct 14 13:12:00 2010
@@ -1327,3 +1327,22 @@
     """
     stderr = re.sub(br"\[\d+ refs\]\r?\n?$", b"", stderr).strip()
     return stderr
+
+def args_from_interpreter_flags():
+    """Return a list of command-line arguments reproducing the current
+    settings in sys.flags."""
+    flag_opt_map = {
+        'bytes_warning': 'b',
+        'dont_write_bytecode': 'B',
+        'ignore_environment': 'E',
+        'no_user_site': 's',
+        'no_site': 'S',
+        'optimize': 'O',
+        'verbose': 'v',
+    }
+    args = []
+    for flag, opt in flag_opt_map.items():
+        v = getattr(sys.flags, flag)
+        if v > 0:
+            args.append('-' + opt * v)
+    return args


More information about the Python-checkins mailing list