[Zodb-checkins] CVS: Zope/lib/python/zdaemon/tests - testzdaemon.py:1.6.2.2

Chris McDonough chrism@zope.com
Fri, 3 Jan 2003 01:39:22 -0500


Update of /cvs-repository/Zope/lib/python/zdaemon/tests
In directory cvs.zope.org:/tmp/cvs-serv28978/tests

Modified Files:
      Tag: chrism-install-branch
	testzdaemon.py 
Log Message:
Merging chrism-install-branch with HEAD (hopefully for one of the last
times).



=== Zope/lib/python/zdaemon/tests/testzdaemon.py 1.6.2.1 => 1.6.2.2 ===
--- Zope/lib/python/zdaemon/tests/testzdaemon.py:1.6.2.1	Sun Nov 24 18:53:58 2002
+++ Zope/lib/python/zdaemon/tests/testzdaemon.py	Fri Jan  3 01:39:18 2003
@@ -45,15 +45,21 @@
         output = self.new_stdout.getvalue()
         self.assertEqual(self.expect, output)
 
+    def quoteargs(self, args):
+        for i in range(len(args)):
+            if " " in args[i]:
+                args[i] = '"%s"' % args[i]
+        return " ".join(args)
+
     def rundaemon(self, args):
-        if type(args) is type([]):
-            args = " ".join(args)
-        cmd = ("PYTHONPATH=%s %s %s -d -s %s %s" %
+        # Add quotes, in case some pathname contains spaces (e.g. Mac OS X)
+        args = self.quoteargs(args)
+        cmd = ('PYTHONPATH="%s" "%s" "%s" -d -s "%s" %s' %
                (self.ppath, self.python, self.zdaemon, self.zdsock, args))
         os.system(cmd)
         # When the daemon crashes, the following may help debug it:
         ##os.system("PYTHONPATH=%s %s %s -s %s %s &" %
-        ##          (self.ppath, self.python, self.zdaemon, self.zdsock, args))
+        ##    (self.ppath, self.python, self.zdaemon, self.zdsock, args))
 
     def run(self, args):
         if type(args) is type(""):
@@ -65,7 +71,7 @@
             pass
 
     def testSystem(self):
-        self.rundaemon("echo -n")
+        self.rundaemon(["echo", "-n"])
         self.expect = ""
 
     def testInvoke(self):
@@ -73,7 +79,7 @@
         self.expect = ""
 
     def testControl(self):
-        self.rundaemon("sleep 1000")
+        self.rundaemon(["sleep", "1000"])
         time.sleep(1)
         self.run("-c stop")
         time.sleep(1)