[svn r37502] unify dist_* options and give dist_rsync_roots more precision:

you now specify relative paths (relative to the conftest.py
where a dist_rsync_root setting resides) or absolute paths.

--HG--
branch : trunk
This commit is contained in:
hpk 2007-01-28 22:54:12 +01:00
parent 216919d612
commit ad127323e3
5 changed files with 40 additions and 34 deletions

View File

@ -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

View File

@ -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()

View File

@ -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

View File

@ -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

View File

@ -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():