mirror of
https://gitlab.com/ita1024/waf.git
synced 2024-11-22 01:46:15 +01:00
waf_unit_test: Fix command handling under windows
The unit test tool moved from a simple split to using shlex.split for handling the unit test command. This results in the path separators on windows being treated as escapes. To handle this the unit test exec command is properly escaped before joining so that the subsequent split restores the original arguments. The quote function is also exposed in the Utilities module so that wscripts making use of the unit test tool can properly quote their contributions to the command as well.
This commit is contained in:
parent
ff8c1828aa
commit
ca3ca0591e
@ -224,7 +224,7 @@ class utest(Task.Task):
|
||||
self.ut_exec = getattr(self.generator, 'ut_exec', [self.inputs[0].abspath()])
|
||||
ut_cmd = getattr(self.generator, 'ut_cmd', False)
|
||||
if ut_cmd:
|
||||
self.ut_exec = shlex.split(ut_cmd % ' '.join(self.ut_exec))
|
||||
self.ut_exec = shlex.split(ut_cmd % Utils.shell_escape(self.ut_exec))
|
||||
|
||||
return self.exec_command(self.ut_exec)
|
||||
|
||||
|
@ -11,7 +11,7 @@ through Python versions 2.5 to 3.X and across different platforms (win32, linux,
|
||||
|
||||
from __future__ import with_statement
|
||||
|
||||
import atexit, os, sys, errno, inspect, re, datetime, platform, base64, signal, functools, time
|
||||
import atexit, os, sys, errno, inspect, re, datetime, platform, base64, signal, functools, time, shlex
|
||||
|
||||
try:
|
||||
import cPickle
|
||||
@ -577,10 +577,13 @@ def quote_define_name(s):
|
||||
fu = fu.upper()
|
||||
return fu
|
||||
|
||||
re_sh = re.compile('\\s|\'|"')
|
||||
"""
|
||||
Regexp used for shell_escape below
|
||||
"""
|
||||
# shlex.quote didn't exist until python 3.3. Prior to that it was a non-documented
|
||||
# function in pipes.
|
||||
try:
|
||||
shell_quote = shlex.quote
|
||||
except AttributeError:
|
||||
import pipes
|
||||
shell_quote = pipes.quote
|
||||
|
||||
def shell_escape(cmd):
|
||||
"""
|
||||
@ -589,7 +592,7 @@ def shell_escape(cmd):
|
||||
"""
|
||||
if isinstance(cmd, str):
|
||||
return cmd
|
||||
return ' '.join(repr(x) if re_sh.search(x) else x for x in cmd)
|
||||
return ' '.join(shell_quote(x) for x in cmd)
|
||||
|
||||
def h_list(lst):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user