[Python-checkins] bpo-40003: test.bisect_cmd copies Python options (GH-19246)

Victor Stinner webhook-mailer at python.org
Tue Mar 31 11:26:01 EDT 2020


https://github.com/python/cpython/commit/01e743d704aeefd1c1825a6a96d0c766c5516fb1
commit: 01e743d704aeefd1c1825a6a96d0c766c5516fb1
branch: master
author: Victor Stinner <vstinner at python.org>
committer: GitHub <noreply at github.com>
date: 2020年03月31日T17:25:56+02:00
summary:
bpo-40003: test.bisect_cmd copies Python options (GH-19246)
test.bisect_cmd now copies Python command line options like -O or -W.
Moreover, emit a warning if test.bisect_cmd is used with
-w/--verbose2 option.
files:
A Misc/NEWS.d/next/Tests/2020-03-31-16-07-15.bpo-40003.SOruLY.rst
M Lib/test/bisect_cmd.py
diff --git a/Lib/test/bisect_cmd.py b/Lib/test/bisect_cmd.py
index cb06480e7c91f..0bdd7a43c03f7 100755
--- a/Lib/test/bisect_cmd.py
+++ b/Lib/test/bisect_cmd.py
@@ -47,8 +47,16 @@ def format_shell_args(args):
 return ' '.join(args)
 
 
+def python_cmd():
+ cmd = [sys.executable]
+ cmd.extend(subprocess._args_from_interpreter_flags())
+ cmd.extend(subprocess._optim_args_from_interpreter_flags())
+ return cmd
+
+
 def list_cases(args):
- cmd = [sys.executable, '-m', 'test', '--list-cases']
+ cmd = python_cmd()
+ cmd.extend(['-m', 'test', '--list-cases'])
 cmd.extend(args.test_args)
 proc = subprocess.run(cmd,
 stdout=subprocess.PIPE,
@@ -68,7 +76,8 @@ def run_tests(args, tests, huntrleaks=None):
 try:
 write_tests(tmp, tests)
 
- cmd = [sys.executable, '-m', 'test', '--matchfile', tmp]
+ cmd = python_cmd()
+ cmd.extend(['-m', 'test', '--matchfile', tmp])
 cmd.extend(args.test_args)
 print("+ %s" % format_shell_args(cmd))
 proc = subprocess.run(cmd)
@@ -100,6 +109,9 @@ def parse_args():
 
 def main():
 args = parse_args()
+ if '-w' in args.test_args or '--verbose2' in args.test_args:
+ print("WARNING: -w/--verbose2 option should not be used to bisect!")
+ print()
 
 if args.input:
 with open(args.input) as fp:
diff --git a/Misc/NEWS.d/next/Tests/2020-03-31-16-07-15.bpo-40003.SOruLY.rst b/Misc/NEWS.d/next/Tests/2020-03-31-16-07-15.bpo-40003.SOruLY.rst
new file mode 100644
index 0000000000000..7ddb90121d894
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2020-03-31-16-07-15.bpo-40003.SOruLY.rst
@@ -0,0 +1,3 @@
+``test.bisect_cmd`` now copies Python command line options like ``-O`` or
+``-W``. Moreover, emit a warning if ``test.bisect_cmd`` is used with
+``-w``/``--verbose2`` option.


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /