summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2006-02-22 03:18:38 (GMT)
committerSteven Knight <knight@baldmt.com>2006-02-22 03:18:38 (GMT)
commit39b08fdb0fb2eac589fdbbb93c2e45bf6d4d21d5 (patch)
treee5f975a63b2c77e2f1bbb44f79ef678776ebc329
parentb47d0563f5e57520c3e67d7beef04858c81f459d (diff)
downloadSCons-39b08fdb0fb2eac589fdbbb93c2e45bf6d4d21d5.zip
SCons-39b08fdb0fb2eac589fdbbb93c2e45bf6d4d21d5.tar.gz
SCons-39b08fdb0fb2eac589fdbbb93c2e45bf6d4d21d5.tar.bz2
Portability fixes (win32) in tests and test infrastructure.
-rw-r--r--etc/TestCmd.py58
-rw-r--r--etc/TestCommon.py4
-rw-r--r--test/Perforce/Perforce.py14
-rw-r--r--test/rebuild-generated.py4
4 files changed, 44 insertions, 36 deletions
diff --git a/etc/TestCmd.py b/etc/TestCmd.py
index a2635c9..c3d438c 100644
--- a/etc/TestCmd.py
+++ b/etc/TestCmd.py
@@ -176,8 +176,8 @@ version.
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
__author__ = "Steven Knight <knight at baldmt dot com>"
-__revision__ = "TestCmd.py 0.20.D001 2006/02/16 06:28:21 knight"
-__version__ = "0.20"
+__revision__ = "TestCmd.py 0.21.D001 2006/02/21 21:18:43 knight"
+__version__ = "0.21"
import os
import os.path
@@ -220,31 +220,6 @@ tempfile.template = 'testcmd.'
re_space = re.compile('\s')
-if os.name == 'posix':
-
- def escape(arg):
- "escape shell special characters"
- slash = '\\'
- special = '"$'
-
- arg = string.replace(arg, slash, slash+slash)
- for c in special:
- arg = string.replace(arg, c, slash+c)
-
- if re_space.search(arg):
- arg = '"' + arg + '"'
- return arg
-
-else:
-
- # Windows does not allow special characters in file names
- # anyway, so no need for an escape function, we will just quote
- # the arg.
- def escape(arg):
- if re_space.search(arg):
- arg = '"' + arg + '"'
- return arg
-
_Cleanup = []
def _clean():
@@ -499,6 +474,31 @@ class TestCmd:
def __repr__(self):
return "%x" % id(self)
+ if os.name == 'posix':
+
+ def escape(self, arg):
+ "escape shell special characters"
+ slash = '\\'
+ special = '"$'
+
+ arg = string.replace(arg, slash, slash+slash)
+ for c in special:
+ arg = string.replace(arg, c, slash+c)
+
+ if re_space.search(arg):
+ arg = '"' + arg + '"'
+ return arg
+
+ else:
+
+ # Windows does not allow special characters in file names
+ # anyway, so no need for an escape function, we will just quote
+ # the arg.
+ def escape(self, arg):
+ if re_space.search(arg):
+ arg = '"' + arg + '"'
+ return arg
+
def cleanup(self, condition = None):
"""Removes any temporary working directories for the specified
TestCmd environment. If the environment variable PRESERVE was
@@ -675,12 +675,14 @@ class TestCmd:
if type(arguments) == type(''):
arguments = string.split(arguments)
cmd.extend(arguments)
- cmd_string = string.join(map(escape, cmd), ' ')
+ cmd_string = string.join(map(self.escape, cmd), ' ')
if self.verbose:
sys.stderr.write(cmd_string + "\n")
try:
p = popen2.Popen3(cmd, 1)
except AttributeError:
+ if sys.platform == 'win32' and cmd_string[0] == '"':
+ cmd_string = '"' + cmd_string + '"'
(tochild, fromchild, childerr) = os.popen3(' ' + cmd_string)
if stdin:
if is_List(stdin):
diff --git a/etc/TestCommon.py b/etc/TestCommon.py
index af38ab5..008cf5a 100644
--- a/etc/TestCommon.py
+++ b/etc/TestCommon.py
@@ -80,8 +80,8 @@ The TestCommon module also provides the following variables
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
__author__ = "Steven Knight <knight at baldmt dot com>"
-__revision__ = "TestCommon.py 0.20.D001 2006/02/16 06:28:21 knight"
-__version__ = "0.20"
+__revision__ = "TestCommon.py 0.21.D001 2006/02/21 21:18:43 knight"
+__version__ = "0.21"
import os
import os.path
diff --git a/test/Perforce/Perforce.py b/test/Perforce/Perforce.py
index 04127f5..f813f10 100644
--- a/test/Perforce/Perforce.py
+++ b/test/Perforce/Perforce.py
@@ -59,11 +59,15 @@ class TestPerforce(TestSCons.TestSCons):
if self.p4d:
self.p4portflags = ['-p', self.host + ':1777']
self.subdir('depot', ['depot', 'testme'])
- args = [self.p4d, '-q', '-d'] + \
- self.p4portflags + \
- ['-J', 'Journal',
- '-L', 'Log',
- '-r', self.workpath('depot')]
+ def quote_space(a):
+ if ' ' in a:
+ a = '"%s"' % a
+ return a
+ args = map(quote_space, [self.p4d, '-q', '-d'] + \
+ self.p4portflags + \
+ ['-J', 'Journal',
+ '-L', 'Log',
+ '-r', self.workpath('depot')])
# We don't use self.run() because the TestCmd logic will hang
# waiting for the daemon to exit, even when we pass it
diff --git a/test/rebuild-generated.py b/test/rebuild-generated.py
index 973fc8f..7f8a6d5 100644
--- a/test/rebuild-generated.py
+++ b/test/rebuild-generated.py
@@ -93,7 +93,9 @@ osLinuxModule = env.StaticObject(
test.write('main.cc', """\
int
main(int, char *[])
-{}
+{
+ return (0);
+}
""")
test.write('target.cc', """\