[py-svn] r37990 - in py/trunk/py/test/rsession: . testing
fijal at codespeak.net
fijal at codespeak.net
Tue Feb 6 00:53:39 CET 2007
Author: fijal
Date: Tue Feb 6 00:53:29 2007
New Revision: 37990
Modified:
py/trunk/py/test/rsession/hostmanage.py
py/trunk/py/test/rsession/testing/test_hostmanage.py
Log:
Fix reporting (and a test for that)
Modified: py/trunk/py/test/rsession/hostmanage.py
==============================================================================
--- py/trunk/py/test/rsession/hostmanage.py (original)
+++ py/trunk/py/test/rsession/hostmanage.py Tue Feb 6 00:53:29 2007
@@ -122,23 +122,31 @@
host.initgateway(python=dist_remotepython)
host.gw.host = host
+ def _send_rsync(self, root, reporter, ignores, make_callback=False):
+ rsync = HostRSync(ignores=ignores)
+ destrelpath = root.relto(self.config.topdir)
+ for host in self.hosts:
+ reporter(repevent.HostRSyncing(host))
+ if make_callback:
+ def donecallback():
+ reporter(repevent.HostReady(host))
+ else:
+ donecallback = None
+ rsync.add_target_host(host, destrelpath,
+ finishedcallback=donecallback)
+ rsync.send(root)
+
+
def init_rsync(self, reporter):
- # send each rsync root
+ # send each rsync root
roots = self.config.getvalue_pathlist("dist_rsync_roots")
ignores = self.config.getvalue_pathlist("dist_rsync_ignore")
if roots is None:
roots = [self.config.topdir]
self.prepare_gateways()
- rsync = HostRSync(ignores=ignores)
- for root in roots:
- destrelpath = root.relto(self.config.topdir)
- for host in self.hosts:
- reporter(repevent.HostRSyncing(host))
- def donecallback():
- reporter(repevent.HostReady(host))
- rsync.add_target_host(host, destrelpath,
- finishedcallback=donecallback)
- rsync.send(root)
+ for root in roots[:-1]:
+ self._send_rsync(root, reporter, ignores)
+ self._send_rsync(roots[-1], reporter, ignores, True)
def setup_hosts(self, reporter):
self.init_rsync(reporter)
Modified: py/trunk/py/test/rsession/testing/test_hostmanage.py
==============================================================================
--- py/trunk/py/test/rsession/testing/test_hostmanage.py (original)
+++ py/trunk/py/test/rsession/testing/test_hostmanage.py Tue Feb 6 00:53:29 2007
@@ -4,7 +4,8 @@
import py
from py.__.test.rsession.hostmanage import HostRSync
-from py.__.test.rsession.hostmanage import HostInfo, HostManager
+from py.__.test.rsession.hostmanage import HostInfo, HostManager
+from py.__.test.rsession import repevent
class DirSetup:
def setup_method(self, method):
@@ -177,3 +178,15 @@
assert self.dest.join("dir5","file").check()
assert not self.dest.join("dir6").check()
+ def test_hostmanager_rsync_reported_once(self):
+ dir2 = self.source.ensure("dir1", "dir2", dir=1)
+ dir5 = self.source.ensure("dir5", "dir6", "bogus")
+ dirf = self.source.ensure("dir3", "file")
+ config = py.test.config._reparse([self.source])
+ hm = HostManager(config,
+ hosts=[HostInfo("localhost:" + str(self.dest))
+ for i in range(3)])
+ events = []
+ hm.init_rsync(reporter=events.append)
+ readies = [i for i in events if isinstance(i, repevent.HostReady)]
+ assert len(readies) == 3
More information about the py-svn
mailing list