[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[minion-cvs] Make minion pass all its test cases on win32



Update of /home/minion/cvsroot/src/minion/lib/mixminion
In directory moria.mit.edu:/tmp/cvs-serv19208/lib/mixminion

Modified Files:
	ClientMain.py test.py 
Log Message:
Make minion pass all its test cases on win32

Index: ClientMain.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/ClientMain.py,v
retrieving revision 1.97
retrieving revision 1.98
diff -u -d -r1.97 -r1.98
--- ClientMain.py	10 Jul 2003 20:01:30 -0000	1.97
+++ ClientMain.py	10 Jul 2003 21:16:05 -0000	1.98
@@ -157,10 +157,14 @@
         # Start downloading the directory.
         url = MIXMINION_DIRECTORY_URL
         LOG.info("Downloading directory from %s", url)
-        def sigalrmHandler(sig, _):
-            pass
-        signal.signal(signal.SIGALRM, sigalrmHandler)
-        signal.alarm(DIRECTORY_TIMEOUT)
+
+        # XXXX005 refactor download logic.
+
+        if hasattr(signal, 'alarm'):
+            def sigalrmHandler(sig, _):
+                pass
+            signal.signal(signal.SIGALRM, sigalrmHandler)
+            signal.alarm(DIRECTORY_TIMEOUT)
         try:
             try:
                 infile = urllib2.urlopen(url)
@@ -169,13 +173,14 @@
                     ("Couldn't connect to directory server: %s.\n"
                      "Try '-D no' to run without downloading a directory.")%e)
             except socket.error, e:
-                if e.errno == errno.EINTR:
+                if getattr(e,"errno",-1) == errno.EINTR:
                     raise UIError("Connection to directory server timed out")
                 else:
-                    raise UIError("Error connecting: %s",e)
+                    raise UIError("Error connecting: %s"%e)
                 raise UIError
         finally:
-            signal.alarm(0)
+            if hasattr(signal, 'alarm'):
+                signal.alarm(0)
         
         # Open a temporary output file.
         if url.endswith(".gz"):
@@ -751,7 +756,40 @@
     #        Nickname
     #     or "<swap>"
     #     or "?"
-    p = path.replace(":", ",<swap>,").split(",")
+    p = []
+    while path:
+        if path[0] == "'":
+            m = re.match(r"'([^']+|\\')*'", path)
+            if not m: 
+                raise UIError("Mismatched quotes in path.")
+            p.append(m.group(1).replace("\\'", "'"))
+            path = path[m.end():]
+            if path and path[0] not in ":,":
+                raise UIError("Invalid quotes in path.")
+        elif path[0] == '"':
+            m = re.match(r'"([^"]+|\\")*"', path)
+            if not m: 
+                raise UIError("Mismatched quotes in path.")
+            p.append(m.group(1).replace('\\"', '"'))
+            path = path[m.end():]
+            if path and path[0] not in ":,":
+                raise UIError("Invalid quotes in path.")
+        else:
+            m = re.match(r"[^,:]+",path)
+            if not m:
+                raise UIError("Invalid path") 
+            p.append(m.group(0))
+            path = path[m.end():]
+        if not path:
+            break 
+        elif path[0] == ',':
+            path = path[1:]
+        elif path[0] == ':':
+            path = path[1:]
+            p.append("<swap>")
+
+
+    #p = path.replace(":", ",<swap>,").split(",")
     path = []
     for ent in p:
         if re.match(r'\*(\d+)', ent):
@@ -763,7 +801,7 @@
     explicitSwap = path.count("<swap>")
     # set colonPos to the index of the explicit swap point, if any.
     if path.count("<swap>") > 1:
-        raise UIError("Can't specify swap point twise")
+        raise UIError("Can't specify swap point twice")
 
     # set starPos to the index of the var-length wildcard, if any.
     if path.count("*") > 1:

Index: test.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/test.py,v
retrieving revision 1.134
retrieving revision 1.135
diff -u -d -r1.134 -r1.135
--- test.py	10 Jul 2003 20:01:30 -0000	1.134
+++ test.py	10 Jul 2003 21:16:05 -0000	1.135
@@ -114,6 +114,14 @@
     else:
         return abs(f1-f2) < .00001
 
+def fileURL(fname):
+    fname = os.path.abspath(fname)
+    if sys.platform == 'win32':
+        drive, path = os.path.splitdrive(fname)
+        return "file:%s" % fname 
+    else:
+        return "file://%s"%fname
+
 #----------------------------------------------------------------------
 # RSA key caching functionality
 
@@ -477,6 +485,10 @@
         self.assertEquals(fn, dX+".2")
 
     def test_lockfile(self):
+        if ON_WIN32:
+            #WWWW
+            return
+
         fn = mix_mktemp()
         LF1 = Lockfile(fn)
         LF2 = Lockfile(fn)
@@ -5522,9 +5534,13 @@
              ("Fred1", "Fred2", "Lola2", "Alice0", "Alice1",
               "Bob3", "Bob4", "Lisa1") ], identity)
 
+        print
+        print fname, fileURL(fname)
+        print "================================"
+
         # Replace the real URL and fingerprint with the ones we have; for
         # unit testing purposes, we can't rely on an http server.
-        mixminion.ClientMain.MIXMINION_DIRECTORY_URL = "file://%s"%fname
+        mixminion.ClientMain.MIXMINION_DIRECTORY_URL = fileURL(fname)
         mixminion.ClientMain.MIXMINION_DIRECTORY_FINGERPRINT = fingerprint
 
         # Reload the directory.
@@ -5561,7 +5577,7 @@
             [os.path.join(impdirname, s) for s in
              ("Fred1", "Fred2", "Lola2", "Alice0", "Alice1",
               "Bob3", "Bob4", "Lisa1", "Lisa2") ], identity)
-        mixminion.ClientMain.MIXMINION_DIRECTORY_URL = "file://%s"%fname
+        mixminion.ClientMain.MIXMINION_DIRECTORY_URL = fileURL(fname)
         ks.updateDirectory(forceDownload=1)
         # Previous entries.
         self.assertSameSD(ks.getServerInfo("Alice"), edesc["Alice"][0])
@@ -5742,7 +5758,7 @@
         p1,p2 = ppath(ks, None, "Alice,Fred,Bob,Joe", email)
         pathIs((p1,p2), ((alice,fred),(bob,joe)))
         fredfile = os.path.join(impdirname, "Fred1")
-        p1,p2 = ppath(ks, None, "Alice,%s,Bob,Joe"%fredfile, email)
+        p1,p2 = ppath(ks, None, "Alice,%r,Bob,Joe"%fredfile, email)
         pathIs((p1,p2), ((alice,fred),(bob,joe)))
         p1,p2 = ppath(ks, None, "Alice,Fred,Bob,Lola,Joe", email, nHops=5)
         pathIs((p1,p2), ((alice,fred,bob),(lola,joe)))
@@ -6105,7 +6121,7 @@
     tc = loader.loadTestsFromTestCase
 
     if 0:
-        suite.addTest(tc(MinionlibFECTests))
+        suite.addTest(tc(ClientMainTests))
         return suite
 
     suite.addTest(tc(MiscTests))