[svn r37950] * add and document dist_rsync_ignore option to ignore

files and directories for rsyncing

--HG--
branch : trunk
This commit is contained in:
hpk 2007-02-05 02:14:17 +01:00
parent 03dc73b195
commit 11591c3c4f
4 changed files with 31 additions and 2 deletions

View File

@ -693,6 +693,7 @@ The options that you need to specify in that conftest.py file are:
* `dist_hosts`: a required list of host specifications
* `dist_rsync_roots` - a list of relative locations to copy to the remote machines.
* `dist_rsync_ignore` - a list of relative locations to ignore for rsyncing
* `dist_remotepython` - the remote python executable to run.
* `dist_nicelevel` - process priority of remote nodes.
* `dist_boxing` - will run each single test in a separate process

View File

@ -25,6 +25,7 @@ if hasattr(py.std.os, 'nice'):
else:
dist_nicelevel = 0
_dist_import_pypy = False # used for regenerating JS application
dist_rsync_ignore = []
# ===================================================

View File

@ -72,6 +72,10 @@ class HostRSync(py.execnet.RSync):
"""
def __init__(self, *args, **kwargs):
self._synced = {}
ignores= None
if 'ignores' in kwargs:
ignores = kwargs.pop('ignores')
self._ignores = ignores or []
super(HostRSync, self).__init__(*args, **kwargs)
def filter(self, path):
@ -79,7 +83,11 @@ class HostRSync(py.execnet.RSync):
if not path.ext in ('.pyc', '.pyo'):
if not path.basename.endswith('~'):
if path.check(dotfile=0):
return True
for x in self._ignores:
if path == x:
break
else:
return True
def add_target_host(self, host, destrelpath=None, finishedcallback=None):
key = host.hostname, host.relpath
@ -115,10 +123,11 @@ class HostManager(object):
def init_rsync(self, reporter):
# 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()
rsync = HostRSync(ignores=ignores)
for root in roots:
destrelpath = root.relto(self.config.topdir)
for host in self.hosts:

View File

@ -142,3 +142,21 @@ class TestHostManager(DirSetup):
assert self.dest.join("dir1", "dir2").check()
assert self.dest.join("dir1", "dir2", 'hello').check()
assert not self.dest.join("bogus").check()
def test_hostmanager_rsync_ignore(self):
dir2 = self.source.ensure("dir1", "dir2", dir=1)
dir5 = self.source.ensure("dir5", "dir6", "bogus")
dirf = self.source.ensure("dir5", "file")
dir2.ensure("hello")
self.source.join("conftest.py").write(py.code.Source("""
dist_rsync_ignore = ['dir1/dir2', 'dir5/dir6']
"""))
config = py.test.config._reparse([self.source])
hm = HostManager(config,
hosts=[HostInfo("localhost:" + str(self.dest))])
events = []
hm.init_rsync(reporter=events.append)
assert self.dest.join("dir1").check()
assert not self.dest.join("dir1", "dir2").check()
assert self.dest.join("dir5","file").check()
assert not self.dest.join("dir6").check()