From 11591c3c4f5f9e68930df7ceebea47dc2c67667e Mon Sep 17 00:00:00 2001 From: hpk Date: Mon, 5 Feb 2007 02:14:17 +0100 Subject: [PATCH] [svn r37950] * add and document dist_rsync_ignore option to ignore files and directories for rsyncing --HG-- branch : trunk --- py/doc/test.txt | 1 + py/test/defaultconftest.py | 1 + py/test/rsession/hostmanage.py | 13 +++++++++++-- py/test/rsession/testing/test_hostmanage.py | 18 ++++++++++++++++++ 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/py/doc/test.txt b/py/doc/test.txt index 0618c192c..c7e079e47 100644 --- a/py/doc/test.txt +++ b/py/doc/test.txt @@ -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 diff --git a/py/test/defaultconftest.py b/py/test/defaultconftest.py index eb52563de..75093b6b9 100644 --- a/py/test/defaultconftest.py +++ b/py/test/defaultconftest.py @@ -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 = [] # =================================================== diff --git a/py/test/rsession/hostmanage.py b/py/test/rsession/hostmanage.py index 373f7195c..e65b99b65 100644 --- a/py/test/rsession/hostmanage.py +++ b/py/test/rsession/hostmanage.py @@ -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: diff --git a/py/test/rsession/testing/test_hostmanage.py b/py/test/rsession/testing/test_hostmanage.py index dc81b42f1..c4340e8f8 100644 --- a/py/test/rsession/testing/test_hostmanage.py +++ b/py/test/rsession/testing/test_hostmanage.py @@ -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()