[py-svn] r38173 - in py/trunk/py/test/rsession: . testing
fijal at codespeak.net
fijal at codespeak.net
Thu Feb 8 16:56:35 CET 2007
Author: fijal
Date: Thu Feb 8 16:56:33 2007
New Revision: 38173
Modified:
py/trunk/py/test/rsession/hostmanage.py
py/trunk/py/test/rsession/testing/test_hostmanage.py
Log:
* Minor semantics change, now host and host: are the same (we don't
want to rsync to home dir usually)
* Make a flag rsync_flag in hostinfo which tells whether to rsync
or no, semantics are that in case of localhost we do not rsync
and in case of localhost: we do.
Modified: py/trunk/py/test/rsession/hostmanage.py
==============================================================================
--- py/trunk/py/test/rsession/hostmanage.py (original)
+++ py/trunk/py/test/rsession/hostmanage.py Thu Feb 8 16:56:33 2007
@@ -17,10 +17,14 @@
def __init__(self, spec):
parts = spec.split(':', 1)
self.hostname = parts.pop(0)
- if parts:
+ if parts and parts[0]:
self.relpath = parts[0]
else:
- self.relpath = "pytestcache-" + self.hostname
+ self.relpath = "pytestcache-" + self.hostname
+ if spec.find(':') == -1 and self.hostname == 'localhost':
+ self.rsync_flag = False
+ else:
+ self.rsync_flag = True
self.hostid = self._getuniqueid(self.hostname)
def _getuniqueid(self, hostname):
@@ -90,7 +94,7 @@
def add_target_host(self, host, reporter=lambda x: None,
destrelpath=None, finishedcallback=None):
key = host.hostname, host.relpath
- if key in self._synced:
+ if not host.rsync_flag or key in self._synced:
if finishedcallback:
finishedcallback()
return False
@@ -139,7 +143,7 @@
host, reporter, destrelpath, finishedcallback=
lambda host=host, root=root: donecallback(host, root))
reporter(repevent.HostRSyncing(host, root, remotepath))
- rsync.send()
+ rsync.send_if_targets()
def setup_hosts(self, reporter):
self.init_rsync(reporter)
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 Thu Feb 8 16:56:33 2007
@@ -24,7 +24,7 @@
return hostinfo
def test_defaultpath(self):
- x = HostInfo("localhost")
+ x = HostInfo("localhost:")
assert x.hostname == "localhost"
assert x.relpath == "pytestcache-" + x.hostname
@@ -34,11 +34,11 @@
assert x.hostname == "localhost"
def test_hostid(self):
- x = HostInfo("localhost")
- y = HostInfo("localhost")
+ x = HostInfo("localhost:")
+ y = HostInfo("localhost:")
assert x.hostid != y.hostid
x = HostInfo("localhost:/tmp")
- y = HostInfo("localhost")
+ y = HostInfo("localhost:")
assert x.hostid != y.hostid
def test_non_existing_hosts(self):
@@ -192,6 +192,20 @@
assert self.dest.join("dir5","file").check()
assert not self.dest.join("dir6").check()
+ def test_hostmanage_optimise_localhost(self):
+ def add_target(self, a, b, c):
+ assert 0, "Should not rsync here"
+ try:
+ config = py.test.config._reparse([self.source])
+ old_add_target = HostRSync.add_target
+ HostRSync.add_target = add_target
+ hm = HostManager(config, hosts=[HostInfo('localhost') for i in
+ range(3)])
+ events = []
+ hm.init_rsync(reporter=events.append)
+ finally:
+ HostRSync.add_target = old_add_target
+
def test_getpath_relto_home():
x = getpath_relto_home("hello")
assert x == py.path.local._gethomedir().join("hello")
More information about the pytest-commit
mailing list