mirror of
https://gitlab.com/ita1024/waf.git
synced 2024-11-26 11:51:20 +01:00
Merge branch 'windows-unit-test-fix' into 'master'
waf_unit_test: Fix command handling under windows See merge request ita1024/waf!2314
This commit is contained in:
commit
9ace152810
@ -206,7 +206,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