From bc009c4aefc8eecc4efbc336659891820dfc0b85 Mon Sep 17 00:00:00 2001 From: hpk Date: Sat, 10 Feb 2007 16:05:32 +0100 Subject: [PATCH] [svn r38391] check more exactly if we are working from a default rsync_root (checking for rsync_root == topdir is not safe as the topdir may be explicitely contained in the rsync_root list) --HG-- branch : trunk --- py/test/rsession/hostmanage.py | 3 ++- py/test/rsession/testing/test_hostmanage.py | 25 ++++++++++++++++----- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/py/test/rsession/hostmanage.py b/py/test/rsession/hostmanage.py index db0f5968f..17960b76a 100644 --- a/py/test/rsession/hostmanage.py +++ b/py/test/rsession/hostmanage.py @@ -124,6 +124,7 @@ class HostManager(object): if roots is None: roots = [self.config.topdir] addrel = self.config.topdir.basename + self._addrel = addrel self.roots = roots if hosts is None: hosts = self.config.getvalue("dist_hosts") @@ -144,7 +145,7 @@ class HostManager(object): for root in self.roots: rsync = HostRSync(root, ignores=ignores, verbose=self.config.option.verbose) - if root == self.config.topdir: + if self._addrel: destrelpath = "" else: destrelpath = root.basename diff --git a/py/test/rsession/testing/test_hostmanage.py b/py/test/rsession/testing/test_hostmanage.py index d0d005e95..6240f264f 100644 --- a/py/test/rsession/testing/test_hostmanage.py +++ b/py/test/rsession/testing/test_hostmanage.py @@ -169,10 +169,11 @@ class TestSyncing(DirSetup): assert not res2 class TestHostManager(DirSetup): - def gethostmanager(self, dist_hosts): - self.source.join("conftest.py").write(py.code.Source(""" - dist_hosts = %r - """ % (dist_hosts,))) + def gethostmanager(self, dist_hosts, dist_rsync_roots=None): + l = ["dist_hosts = %r" % dist_hosts] + if dist_rsync_roots: + l.append("dist_rsync_roots = %r" % dist_rsync_roots) + self.source.join("conftest.py").write("\n".join(l)) config = py.test.config._reparse([self.source]) assert config.topdir == self.source hm = HostManager(config) @@ -197,7 +198,21 @@ class TestHostManager(DirSetup): assert dest.join("dir1", "dir2").check() assert dest.join("dir1", "dir2", 'hello').check() - def test_hostmanager_init_rsync_rsync_roots(self): + def test_hostmanager_init_rsync_topdir_explicit(self): + dir2 = self.source.ensure("dir1", "dir2", dir=1) + dir2.ensure("hello") + hm = self.gethostmanager( + dist_hosts = ["localhost:%s" % self.dest] + dist_rsync_roots = [self.source] + ) + assert hm.config.topdir == self.source + hm.init_rsync([].append) + dest = self.dest.join(self.source.basename) + assert dest.join("dir1").check() + assert dest.join("dir1", "dir2").check() + assert dest.join("dir1", "dir2", 'hello').check() + + def test_hostmanager_init_rsync_roots(self): dir2 = self.source.ensure("dir1", "dir2", dir=1) self.source.ensure("dir1", "somefile", dir=1) dir2.ensure("hello")