From 45302c9b9e9d645ad600fbeb3594bbbd3ea8e6bf Mon Sep 17 00:00:00 2001 From: Ben Finney Date: Wed, 28 Oct 2015 16:20:27 +1100 Subject: Split and re-assemble command line for special handling command name. --- tests/coveragetest.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/coveragetest.py b/tests/coveragetest.py index bf55395..86f3506 100644 --- a/tests/coveragetest.py +++ b/tests/coveragetest.py @@ -352,7 +352,11 @@ class CoverageTest( Python interpreter. """ - if cmd.startswith("python "): + split_commandline = cmd.split(" ", 1) + command_name = split_commandline[0] + command_args = split_commandline[1:] + + if command_name == "python": # Running a Python interpreter in a sub-processes can be # tricky. Use the real name of our own executable. So # "python foo.py" might get executed as "python3.3 @@ -360,9 +364,11 @@ class CoverageTest( # install as "python", so you might get a Python 2 # executable instead if you don't use the executable's # basename. - cmd = os.path.basename(sys.executable) + cmd[6:] + command_name = os.path.basename(sys.executable) + + full_commandline = " ".join([shlex.quote(command_name)] + command_args) - _, output = self.run_command_status(cmd) + _, output = self.run_command_status(full_commandline) return output def run_command_status(self, cmd): -- cgit v1.2.1