[py-svn] r57065 - in py/branch/event/py/test2: . rsession rsession/testing testing

hpk at codespeak.net hpk at codespeak.net
Thu Aug 7 17:30:07 CEST 2008


Author: hpk
Date: Thu Aug  7 17:30:04 2008
New Revision: 57065

Modified:
   py/branch/event/py/test2/collect.py
   py/branch/event/py/test2/rsession/hostmanage.py
   py/branch/event/py/test2/rsession/masterslave.py
   py/branch/event/py/test2/rsession/rsession.py
   py/branch/event/py/test2/rsession/testing/test_rsession.py
   py/branch/event/py/test2/testing/acceptance_test.py
Log:
dist-testing begins to work as expected


Modified: py/branch/event/py/test2/collect.py
==============================================================================
--- py/branch/event/py/test2/collect.py	(original)
+++ py/branch/event/py/test2/collect.py	Thu Aug  7 17:30:04 2008
@@ -209,7 +209,7 @@
                 relpath = "."
             else:
                 raise ValueError("%r not relative to topdir %s" 
-                         %(chain[0], topdir))
+                         %(chain[0].fspath, topdir))
         return relpath, tuple([x.name for x in chain[1:]])
 
     @staticmethod

Modified: py/branch/event/py/test2/rsession/hostmanage.py
==============================================================================
--- py/branch/event/py/test2/rsession/hostmanage.py	(original)
+++ py/branch/event/py/test2/rsession/hostmanage.py	Thu Aug  7 17:30:04 2008
@@ -154,12 +154,12 @@
 
     def setup_hosts(self):
         self.init_rsync()
+        self.queue = py.std.Queue.Queue()
+        self.session.bus.subscribe(self.queue.put)
         for host in self.hosts:
             host.node = MasterNode(host, self.session)
 
-    def wait_for_completion(self, maxtimeout=1.0):
-        queue = py.std.Queue.Queue()
-        self.session.bus.subscribe(queue.put)
+    def wait_for_completion(self, maxtimeout=2.0):
         #remaining = []
         pending_going_down = []
         while self.hosts:
@@ -172,13 +172,15 @@
                         pending_going_down.append(host)
                     else:
                         numitems += len(host.node.pending)
-            ev = queue.get(timeout=maxtimeout)
+            ev = self.queue.get(timeout=maxtimeout)
             if isinstance(ev, repevent.HostDown):
                 assert not ev.pending
                 self.hosts.remove(ev.host)
+                pending_going_down.remove(ev.host)
             elif isinstance(ev, repevent.HostCrashed):
-                print "host crashed", ev.host
-                print "lost items", ev.pending
+                if ev.host in pending_going_down:
+                    pending_going_down.remove(ev.host)
+                self.hosts.remove(ev.host)
                 #XXX remaining.extend(ev.pending)
                 pass
             #else:

Modified: py/branch/event/py/test2/rsession/masterslave.py
==============================================================================
--- py/branch/event/py/test2/rsession/masterslave.py	(original)
+++ py/branch/event/py/test2/rsession/masterslave.py	Thu Aug  7 17:30:04 2008
@@ -28,7 +28,10 @@
                 self.notify(repevent.HostDown(self.host, self.pending))
                 self._down = True
                 return 
-            item = self.pending.pop()
+            if isinstance(ev, repevent.ItemTestReport):
+                item = self.pending.pop()
+            else:
+                raise ev
         except KeyboardInterrupt:
             raise 
         except:

Modified: py/branch/event/py/test2/rsession/rsession.py
==============================================================================
--- py/branch/event/py/test2/rsession/rsession.py	(original)
+++ py/branch/event/py/test2/rsession/rsession.py	Thu Aug  7 17:30:04 2008
@@ -47,6 +47,7 @@
         sent = self.hm.trysendtest(item)
         if not sent and not self.shouldstop:
             self.sleepabit()
+            self.runtest(item)
 
     def sleepabit(self):
         py.std.time.sleep(0.1)

Modified: py/branch/event/py/test2/rsession/testing/test_rsession.py
==============================================================================
--- py/branch/event/py/test2/rsession/testing/test_rsession.py	(original)
+++ py/branch/event/py/test2/rsession/testing/test_rsession.py	Thu Aug  7 17:30:04 2008
@@ -107,7 +107,7 @@
         num_hosts = len(hm.hosts) 
         events = []
         while len(events) < 4 * num_hosts:
-            item = queue.get(timeout=0.5) 
+            item = queue.get(timeout=1.0)
             if isinstance(item, repevent.ItemTestReport):
                 events.append(item) 
         print "got all events", events

Modified: py/branch/event/py/test2/testing/acceptance_test.py
==============================================================================
--- py/branch/event/py/test2/testing/acceptance_test.py	(original)
+++ py/branch/event/py/test2/testing/acceptance_test.py	Thu Aug  7 17:30:04 2008
@@ -22,6 +22,9 @@
             stdout=p1.open("w"), stderr=p2.open("w"))
         ret = popen.wait()
         out, err = p1.readlines(cr=0), p2.readlines(cr=0)
+        if err:
+            for line in err: 
+                print >>py.std.sys.stderr, line
         return Result(ret, out, err)
 
     def makepyfile(self, **kwargs):
@@ -252,6 +255,38 @@
             "    1",
             "*doc.txt:2: DocTestFailure"
         ])
+
+    def test_dist_tests_with_crash(self):
+        p1 = self.makepyfile(
+            test_one="""
+                import py
+                def test_fail0():
+                    assert 0
+                def test_fail1():
+                    raise ValueError()
+                def test_ok():
+                    pass
+                def test_skip():
+                    py.test.skip("hello")
+                def test_crash():
+                    import time
+                    import os
+                    time.sleep(0.5)
+                    os.kill(os.getpid(), 15)
+            """, 
+            conftest="""
+                dist_hosts = ['localhost'] * 3
+            """
+        )
+        result = self.runpytest(p1, '-d')
+        assert_lines_contain_lines(result.outlines, [
+            "HostReady*localhost*",
+            "HostReady*localhost*",
+            "HostReady*localhost*",
+            "HostCrashed*localhost*",
+            "*1/3 passed + 1 skip*",
+            "*failures: 2*",
+        ])
         
     def test_looponfailing_looping(self):
         py.test.skip("thought needed to nicely test --looponfailing")



More information about the pytest-commit mailing list