diff --git a/py/doc/test.txt b/py/doc/test.txt index 97c5e22b7..2096e379d 100644 --- a/py/doc/test.txt +++ b/py/doc/test.txt @@ -691,9 +691,8 @@ You must create a conftest.py in any parent directory above your tests. The options that you need to specify in that conftest.py file are: -* **`dist_hosts`**: a required list of ssh addresses (which each may - include a path, default path is: ``$HOME/pytestcache-HOSTNAME``) -* `dist_rsyncroots` - a list of packages to copy to the remote machines. +* `dist_hosts`: a required list of host specifications +* `dist_rsync_roots` - a list of relative locations to copy to the remote machines. * `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 @@ -703,7 +702,7 @@ The options that you need to specify in that conftest.py file are: Sample configuration:: dist_hosts = ['localhost', 'user@someserver:/tmp/somedir'] - dist_rsyncroots = ['pypy', 'py'] + dist_rsyncroots = ['../pypy', '../py'] dist_remotepython = 'python2.4' dist_nicelevel = 10 dist_boxing = True diff --git a/py/test/config.py b/py/test/config.py index daa084e48..14508bc31 100644 --- a/py/test/config.py +++ b/py/test/config.py @@ -118,13 +118,6 @@ class Config(object): except KeyError: return self.conftest.rget(name, path) - def getvalue_and_confpath(self, name, path=None): - """ same as previous, but returns conftest's path - as well - """ - val, mod = self.conftest.rget_with_confmod(name, path) - return val, py.path.local(mod.__file__).dirpath() - def initsession(self): """ return an initialized session object. """ cls = self._getsessionclass() diff --git a/py/test/rsession/hostmanage.py b/py/test/rsession/hostmanage.py index b12588e64..cae0a31ff 100644 --- a/py/test/rsession/hostmanage.py +++ b/py/test/rsession/hostmanage.py @@ -51,10 +51,10 @@ class HostRSync(py.execnet.RSync): dir, base = os.path.split(path) if base == '.svn': return False - if self.rsync_roots is None or dir != self.sourcedir: + if dir != self.sourcedir: return True else: - return base in self.rsync_roots + return self.rsync_roots is None or path in self.rsync_roots class DummyGateway(object): pass diff --git a/py/test/rsession/rsession.py b/py/test/rsession/rsession.py index 52a264bc8..0e39421c4 100644 --- a/py/test/rsession/rsession.py +++ b/py/test/rsession/rsession.py @@ -133,17 +133,17 @@ class RSession(AbstractSession): super(RSession, self).fixoptions() config = self.config try: - config.getvalue('disthosts') + config.getvalue('dist_hosts') except KeyError: - print "You're trying to run RSession without disthosts specified" - print "you need to specify it in your conftest.py (ie. ~/conftest.py)" + print "For running ad-hoc distributed tests you need to specify" + print "dist_hosts in a local conftest.py file, for example:" print "for example:" - print " disthosts = ['localhost'] * 4 # for 3 processors" - print " - or -" - print " disthosts = ['you@some.remote.com'] # for remote testing" - print " # with your remote ssh account" - print "http://codespeak.net/py/current/doc/test.html#automated-distributed-testing" - print " for more info..." + print + print " dist_hosts = ['localhost'] * 4 # for 3 processors" + print " dist_hosts = ['you@remote.com', '...'] # for testing on ssh accounts" + print " # with your remote ssh accounts" + print + print "see also: http://codespeak.net/py/current/doc/test.html#automated-distributed-testing" raise SystemExit def main(self, reporter=None): @@ -195,11 +195,22 @@ class RSession(AbstractSession): """ Read from conftest file the configuration of distributed testing """ try: - rsync_roots = self.config.getvalue("distrsync_roots") - except: - rsync_roots = None # all files and directories in the pkgdir + conftest = self.config.conftest + value, mod = conftest.rget_with_confmod('dist_rsync_roots') + except KeyError: + rsync_roots = [self.config.topdir] # our best guess likely + else: + assert isinstance(value, (list,tuple)), value + base = py.path.local(mod.__file__).dirpath() + print "base", base + rsync_roots = [base.join(path, abs=True) + for path in value] + for root in rsync_roots: + assert root.check(dir=1) + #rsync_roots = value + print "rsync_roots", rsync_roots sshhosts = [HostInfo(i) for i in - self.config.getvalue("disthosts")] + self.config.getvalue("dist_hosts")] parse_directories(sshhosts) remotepython = self.config.getvalue("dist_remotepython") return sshhosts, remotepython, rsync_roots diff --git a/py/test/rsession/testing/test_rsession.py b/py/test/rsession/testing/test_rsession.py index cff78dfa1..a37fd8adf 100644 --- a/py/test/rsession/testing/test_rsession.py +++ b/py/test/rsession/testing/test_rsession.py @@ -76,7 +76,7 @@ class TestRSessionRemote: def test_example_distribution_minus_x(self): tmpdir = py.test.ensuretemp("example_distribution_minus_x") tmpdir.ensure("sub", "conftest.py").write(py.code.Source(""" - disthosts = [%r] + dist_hosts = [%r] """ % ('localhost',))) tmpdir.ensure("sub", "__init__.py") tmpdir.ensure("sub", "test_one.py").write(py.code.Source(""" @@ -106,9 +106,9 @@ class TestRSessionRemote: subdir = "sub_example_dist" tmpdir = py.test.ensuretemp("example_distribution") tmpdir.ensure(subdir, "conftest.py").write(py.code.Source(""" - disthosts = [%r] - distrsync_roots = ["%s", "py"] - """ % ('localhost', subdir))) + dist_hosts = [%r] + dist_rsync_roots = ["%s", "../py"] + """ % ('localhost', tmpdir.join(subdir), ))) tmpdir.ensure(subdir, "__init__.py") tmpdir.ensure(subdir, "test_one.py").write(py.code.Source(""" def test_1(): @@ -161,7 +161,8 @@ class TestRSessionRemote: teardown_events = [] config = py.test.config._reparse([]) - opts = HostOptions(optimise_localhost=False, rsync_roots=['py']) + opts = HostOptions(optimise_localhost=False, + rsync_roots=[py.path.local(py.__file__).dirpath()]) hm = HostManager(hosts, config, opts) nodes = hm.init_hosts(setup_events.append) hm.teardown_hosts(teardown_events.append, @@ -188,7 +189,8 @@ class TestRSessionRemote: allevents = [] config = py.test.config._reparse([]) - opts = HostOptions(optimise_localhost=False, rsync_roots=['py']) + opts = HostOptions(optimise_localhost=False, + rsync_roots=[py.path.local(py.__file__).dirpath()]) hm = HostManager(hosts, config, opts) nodes = hm.init_hosts(allevents.append) @@ -235,7 +237,8 @@ class TestRSessionRemote: from py.__.test.rsession.master import defaultconftestnames defaultconftestnames.append("custom") try: - opts = HostOptions(optimise_localhost=False, rsync_roots=['py']) + opts = HostOptions(optimise_localhost=False, + rsync_roots=[py.path.local(py.__file__).dirpath()]) hm = HostManager(hosts, config, opts) nodes = hm.init_hosts(allevents.append) @@ -267,7 +270,7 @@ class TestRSessionRemote: tmpdir = py.test.ensuretemp("nice") tmpdir.ensure("__init__.py") tmpdir.ensure("conftest.py").write(py.code.Source(""" - disthosts = ['localhost'] + dist_hosts = ['localhost'] dist_nicelevel = 10 """)) tmpdir.ensure("test_one.py").write("""def test_nice():