Anonymous avatar Anonymous committed e33c1bf

Portability fixes (win32) in tests and test infrastructure.

Comments (0)

Files changed (4)

 # 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
 
 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():
     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
             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):

etc/TestCommon.py

 # 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

test/Perforce/Perforce.py

         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

test/rebuild-generated.py

 test.write('main.cc', """\
 int
 main(int, char *[])
-{}
+{
+    return (0);
+}
 """)
 
 test.write('target.cc', """\
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.