Skip to content

Commit 01e743d

Browse files
authored
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.
1 parent 8d84adc commit 01e743d

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

Lib/test/bisect_cmd.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,16 @@ def format_shell_args(args):
4747
return ' '.join(args)
4848

4949

50+
def python_cmd():
51+
cmd = [sys.executable]
52+
cmd.extend(subprocess._args_from_interpreter_flags())
53+
cmd.extend(subprocess._optim_args_from_interpreter_flags())
54+
return cmd
55+
56+
5057
def list_cases(args):
51-
cmd = [sys.executable, '-m', 'test', '--list-cases']
58+
cmd = python_cmd()
59+
cmd.extend(['-m', 'test', '--list-cases'])
5260
cmd.extend(args.test_args)
5361
proc = subprocess.run(cmd,
5462
stdout=subprocess.PIPE,
@@ -68,7 +76,8 @@ def run_tests(args, tests, huntrleaks=None):
6876
try:
6977
write_tests(tmp, tests)
7078

71-
cmd = [sys.executable, '-m', 'test', '--matchfile', tmp]
79+
cmd = python_cmd()
80+
cmd.extend(['-m', 'test', '--matchfile', tmp])
7281
cmd.extend(args.test_args)
7382
print("+ %s" % format_shell_args(cmd))
7483
proc = subprocess.run(cmd)
@@ -100,6 +109,9 @@ def parse_args():
100109

101110
def main():
102111
args = parse_args()
112+
if '-w' in args.test_args or '--verbose2' in args.test_args:
113+
print("WARNING: -w/--verbose2 option should not be used to bisect!")
114+
print()
103115

104116
if args.input:
105117
with open(args.input) as fp:
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
``test.bisect_cmd`` now copies Python command line options like ``-O`` or
2+
``-W``. Moreover, emit a warning if ``test.bisect_cmd`` is used with
3+
``-w``/``--verbose2`` option.

0 commit comments

Comments
 (0)