Portability fixes (win32) in tests and test infrastructure.
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Wed, 22 Feb 2006 03:18:38 +0000 (03:18 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Wed, 22 Feb 2006 03:18:38 +0000 (03:18 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@1429 fdb21ef1-2011-0410-befe-b5e4ea1792b1

etc/TestCmd.py
etc/TestCommon.py
test/Perforce/Perforce.py
test/rebuild-generated.py

index a2635c97744e13bef2a02ea1b57f0bef8d32c4c4..c3d438ce40051cb4552770ef815c18d5e91dd2b0 100644 (file)
@@ -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):
index af38ab5fa86803f9d15b4a5488ba763f127275f4..008cf5a784ef31a452f35003cf5fbec268245f61 100644 (file)
@@ -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
index 04127f51e78a6d2d2485fc8b913c63d0e9f4f95e..f813f106586c118bc7deafdbdabbf00d06f39aa8 100644 (file)
@@ -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
index 973fc8f8a08dca9b69acff7698ce5480a51d56e2..7f8a6d578a9998dcd25b2cdaf9dba0d237ff32c2 100644 (file)
@@ -93,7 +93,9 @@ osLinuxModule = env.StaticObject(
 test.write('main.cc', """\
 int
 main(int, char *[])
-{}
+{
+    return (0);
+}
 """)
 
 test.write('target.cc', """\