Skip to content

Commit e3e91c1

Browse files
authored
Merge pull request #4218 from jediry/fix_runtest_py
Fix excessive path escaping in runtest py
2 parents 4ec9a65 + 3c2458a commit e3e91c1

4 files changed

Lines changed: 8 additions & 29 deletions

File tree

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
2020
From Flaviu Tamas
2121
- Added -fsanitize support to ParseFlags(). This will propagate to CCFLAGS and LINKFLAGS.
2222

23+
From Ryan Saunders
24+
- Fixed runtest.py failure on Windows caused by excessive escaping of the path to python.exe.
2325

2426
RELEASE 4.4.0 - Sat, 30 Jul 2022 14:08:29 -0700
2527

runtest.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import argparse
2323
import glob
2424
import os
25-
import re
2625
import stat
2726
import subprocess
2827
import sys
@@ -311,15 +310,6 @@ def get_template_command(filetype, verb=None):
311310
return buf.value
312311

313312

314-
_ws = re.compile(r'\s')
315-
316-
def escape(s):
317-
if _ws.search(s):
318-
s = '"' + s + '"'
319-
s = s.replace('\\', '\\\\')
320-
return s
321-
322-
323313
if not catch_output:
324314
# Without any output suppressed, we let the subprocess
325315
# write its stuff freely to stdout/stderr.
@@ -432,8 +422,7 @@ class PopenExecutor(RuntestBase):
432422
433423
A bit of a misnomer as the Popen call is now wrapped
434424
by calling subprocess.run (behind the covers uses Popen.
435-
Very similar to SystemExecutor, but uses command_str
436-
instead of command_args, and doesn't allow for not catching
425+
Very similar to SystemExecutor, but doesn't allow for not catching
437426
the output).
438427
"""
439428
# For an explanation of the following 'if ... else'
@@ -447,7 +436,7 @@ def execute(self, env):
447436
tmp_stderr = tempfile.TemporaryFile(mode='w+t')
448437
# Start subprocess...
449438
cp = subprocess.run(
450-
self.command_str.split(),
439+
self.command_args,
451440
stdout=tmp_stdout,
452441
stderr=tmp_stderr,
453442
shell=False,
@@ -470,7 +459,7 @@ def execute(self, env):
470459

471460
def execute(self, env):
472461
cp = subprocess.run(
473-
self.command_str.split(),
462+
self.command_args,
474463
stdout=subprocess.PIPE,
475464
stderr=subprocess.PIPE,
476465
shell=False,
@@ -784,7 +773,7 @@ def run_test(t, io_lock=None, run_async=True):
784773
if args.runner and t.path in unittests:
785774
# For example --runner TestUnit.TAPTestRunner
786775
command_args.append('--runner ' + args.runner)
787-
t.command_args = [escape(args.python)] + command_args
776+
t.command_args = [args.python] + command_args
788777
t.command_str = " ".join(t.command_args)
789778
if args.printcommand:
790779
if args.print_progress:

test/runtest/python.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,12 @@
5050
# getting called with "/bin/../bin/python" as first argument, e.g. Fedora 17 Desktop.
5151
mypython = os.path.normpath(os.path.join(head, dir, os.path.pardir, dir, python))
5252

53-
def escape(s):
54-
return s.replace('\\', '\\\\')
55-
56-
if re.search(r'\s', mypython):
57-
mypythonstring = '"%s"' % escape(mypython)
58-
else:
59-
mypythonstring = escape(mypython)
60-
6153
test.subdir('test')
6254

6355
test.write_passing_test(['test', 'pass.py'])
6456

6557
expect_stdout = """\
66-
%(mypythonstring)s%(pythonflags)s %(test_pass_py)s
58+
%(mypython)s%(pythonflags)s %(test_pass_py)s
6759
PASSING TEST STDOUT
6860
""" % locals()
6961

testing/framework/TestRuntest.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,7 @@
5151
]
5252
)
5353

54-
if re.search(r'\s', python):
55-
pythonstring = _python_
56-
else:
57-
pythonstring = python
58-
pythonstring = pythonstring.replace('\\', '\\\\')
54+
pythonstring = python
5955
pythonflags = ''
6056

6157
failing_test_template = """\

0 commit comments

Comments
 (0)