[svn r63019] some simple ssh tests, always transfer py lib as rsyncroot

--HG--
branch : trunk
This commit is contained in:
hpk 2009-03-18 01:38:02 +01:00
parent b5b7f9b3a9
commit fcaefb841b
3 changed files with 29 additions and 4 deletions

View File

@ -96,7 +96,7 @@ def ansi_print(text, esc, file=None, newline=True, flush=False):
if esc and sys.platform == "win32" and file.isatty():
if 1 in esc:
bold = True
esc = tuple(x for x in esc if x != 1)
esc = tuple([x for x in esc if x != 1])
else:
bold = False
esctable = {() : FOREGROUND_WHITE, # normal

View File

@ -25,9 +25,16 @@ def getconfigroots(config):
conftestroots = config.getconftest_pathlist("rsyncdirs")
if conftestroots:
roots.extend(conftestroots)
pydir = py.path.local(py.__file__).dirpath()
for root in roots:
if not root.check():
raise ValueError("rsyncdir doesn't exist: %r" %(root,))
if pydir is not None and root.basename == "py":
if root != pydir:
raise ValueError("root %r conflicts with current %r" %(root, pydir))
pydir = None
if pydir is not None:
roots.append(pydir)
return roots
class HostManager(object):
@ -98,6 +105,11 @@ class HostManager(object):
""" % nice).waitclose()
self.trace_hoststatus()
multigw = self.gwmanager.getgateways(inplacelocal=False, remote=True)
multigw.remote_exec("""
import os, sys
sys.path.insert(0, os.getcwd())
""").waitclose()
for gateway in self.gwmanager.gateways:
host = gateway.spec

View File

@ -33,6 +33,7 @@ class TestHostManager:
hm = HostManager(session.config, hosts=[1,2,3])
assert hm.hosts == [1,2,3]
@py.test.mark.xfail("consider / forbid implicit rsyncdirs?")
def test_hostmanager_rsync_roots_no_roots(self, source, dest):
source.ensure("dir1", "file1").write("hello")
config = py.test.config._reparse([source])
@ -133,6 +134,18 @@ class TestHostManager:
assert l
hm.teardown_hosts()
def test_hostmanage_ssh_setup_hosts(self, testdir):
sshhost = py.test.config.getvalueorskip("sshhost")
testdir.makepyfile(__init__="", test_x="""
def test_one():
pass
""")
sorter = testdir.inline_run("-d", "--rsyncdirs=%s" % testdir.tmpdir,
"--gateways=%s" % sshhost, testdir.tmpdir)
ev = sorter.getfirstnamed("itemtestreport")
assert ev.passed
@py.test.mark.xfail("implement double-rsync test")
def test_ssh_rsync_samehost_twice(self):
option = py.test.config.option
@ -162,8 +175,8 @@ def test_getconfiggwspecs_disthosts():
def test_getconfigroots(testdir):
config = testdir.parseconfig('--rsyncdirs=' + str(testdir.tmpdir))
roots = getconfigroots(config)
assert len(roots) == 1
assert roots == [testdir.tmpdir]
assert len(roots) == 1 + 1
assert testdir.tmpdir in roots
def test_getconfigroots_with_conftest(testdir):
testdir.chdir()
@ -175,7 +188,7 @@ def test_getconfigroots_with_conftest(testdir):
""")
config = testdir.parseconfig(testdir.tmpdir, '--rsyncdirs=y,z')
roots = getconfigroots(config)
assert len(roots) == 3
assert len(roots) == 3 + 1
assert py.path.local('y') in roots
assert py.path.local('z') in roots
assert testdir.tmpdir.join('x') in roots