[svn r37990] Fix reporting (and a test for that)

--HG--
branch : trunk
This commit is contained in:
fijal 2007-02-06 00:53:29 +01:00
parent 9b6787782d
commit eb01cfa78e
2 changed files with 33 additions and 12 deletions

View File

@ -122,23 +122,31 @@ class HostManager(object):
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)

View File

@ -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 @@ class TestHostManager(DirSetup):
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