[py-svn] r37950 - in py/trunk/py: doc test test/rsession test/rsession/testing

hpk at codespeak.net hpk at codespeak.net
Mon Feb 5 02:14:18 CET 2007


Author: hpk
Date: Mon Feb  5 02:14:17 2007
New Revision: 37950

Modified:
   py/trunk/py/doc/test.txt
   py/trunk/py/test/defaultconftest.py
   py/trunk/py/test/rsession/hostmanage.py
   py/trunk/py/test/rsession/testing/test_hostmanage.py
Log:
* add and document dist_rsync_ignore option to ignore 
  files and directories for rsyncing


Modified: py/trunk/py/doc/test.txt
==============================================================================
--- py/trunk/py/doc/test.txt	(original)
+++ py/trunk/py/doc/test.txt	Mon Feb  5 02:14:17 2007
@@ -693,6 +693,7 @@
 
 * `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 

Modified: py/trunk/py/test/defaultconftest.py
==============================================================================
--- py/trunk/py/test/defaultconftest.py	(original)
+++ py/trunk/py/test/defaultconftest.py	Mon Feb  5 02:14:17 2007
@@ -25,6 +25,7 @@
 else:
     dist_nicelevel = 0
 _dist_import_pypy = False # used for regenerating JS application 
+dist_rsync_ignore = []
 
 # ===================================================
 

Modified: py/trunk/py/test/rsession/hostmanage.py
==============================================================================
--- py/trunk/py/test/rsession/hostmanage.py	(original)
+++ py/trunk/py/test/rsession/hostmanage.py	Mon Feb  5 02:14:17 2007
@@ -72,6 +72,10 @@
     """
     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 @@
         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 @@
     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:

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	Mon Feb  5 02:14:17 2007
@@ -142,3 +142,21 @@
         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()



More information about the pytest-commit mailing list