[svn r63091] report some more info on dist-setup

shift comments

--HG--
branch : trunk
This commit is contained in:
hpk 2009-03-19 19:25:13 +01:00
parent 6f2cca80ae
commit a94359c791
8 changed files with 42 additions and 18 deletions

View File

@ -26,6 +26,7 @@ NO_ENDMARKER_WANTED = object()
class GatewaySpec(object):
python = None
def __init__(self, spec, defaultjoinpath="pyexecnetcache"):
self._spec = spec
if spec == "popen" or spec.startswith("popen:"):
parts = spec.split(":", 2)
self.type = self.address = parts.pop(0)
@ -66,7 +67,7 @@ class GatewaySpec(object):
return bool(self.type == "popen" and not self.joinpath)
def __str__(self):
return "<GatewaySpec %s:%s>" % (self.address, self.joinpath)
return "<GatewaySpec %s>" % self._spec
__repr__ = __str__
def makegateway(self, waitclose=True):
@ -102,13 +103,18 @@ class GatewayManager:
self.gateways = []
def trace(self, msg):
py._com.pyplugins.notify("trace", "gatewaymanage", msg)
self.notify("trace", "gatewaymanage", msg)
def notify(self, eventname, *args, **kwargs):
py._com.pyplugins.notify(eventname, *args, **kwargs)
def makegateways(self):
assert not self.gateways
for spec in self.specs:
self.trace("makegateway %s" %(spec))
self.gateways.append(spec.makegateway())
gw = spec.makegateway()
self.gateways.append(gw)
gw.id = "[%s]" % len(self.gateways)
self.notify("gwmanage_newgateway", gw)
def getgateways(self, remote=True, inplacelocal=True):
if not self.gateways and self.specs:

View File

@ -565,9 +565,9 @@ class SocketGatewaySetup:
## cls.gw.exit()
## cls.proxygw.exit()
def getsshhost():
def getsshhost(withpython=False):
sshhost = py.test.config.getvalueorskip("sshhost")
if sshhost.find(":") != -1:
if not withpython and sshhost.find(":") != -1:
sshhost = sshhost.split(":")[0]
ssh = py.path.local.sysfind("ssh")
if not ssh:

View File

@ -1,7 +1,5 @@
"""
tests for
- gateway specifications
- multi channels and multi gateways
- gateway management
- manage rsyncing of hosts
@ -10,10 +8,18 @@
import py
from py.__.execnet.gwmanage import GatewayManager, HostRSync
pytest_plugins = "pytest_pytester"
class TestGatewayManagerPopen:
def test_hostmanager_popen_makegateway(self):
def test_hostmanager_popen_makegateway(self, eventrecorder):
hm = GatewayManager(["popen"] * 2)
hm.makegateways()
event = eventrecorder.popevent("gwmanage_newgateway")
gw = event.args[0]
assert gw.id == "[1]"
event = eventrecorder.popevent("gwmanage_newgateway")
gw = event.args[0]
assert gw.id == "[2]"
assert len(hm.gateways) == 2
hm.exit()
assert not len(hm.gateways)

View File

@ -50,6 +50,11 @@ class HostManager(object):
self.gwmanager = GatewayManager(hosts)
def makegateways(self):
# we change to the topdir sot that
# PopenGateways will have their cwd
# such that unpickling configs will
# pick it up as the right topdir
# (for other gateways this chdir is irrelevant)
old = self.config.topdir.chdir()
try:
self.gwmanager.makegateways()
@ -74,11 +79,6 @@ class HostManager(object):
have the same set of roots in their
current directory.
"""
# we change to the topdir sot that
# PopenGateways will have their cwd
# such that unpickling configs will
# pick it up as the right topdir
# (for other gateways this chdir is irrelevant)
self.makegateways()
options = {
'ignores': self.config_getignores(),

View File

@ -65,9 +65,12 @@ class TestAsyncFunctional:
p = subdir.join("test_one.py")
p.write("def test_5(): assert not __file__.startswith(%r)" % str(p))
result = testdir.runpytest("-d", "--rsyncdirs=%(subdir)s" % locals(),
"--gateways=popen::%(dest)s" % locals(), p)
"--gateways=popen::%(dest)s" % locals(), p)
assert result.ret == 0
result.stdout.fnmatch_lines([
"*1* instantiated gateway *popen*",
#"RSyncStart: [G1]",
#"RSyncFinished: [G1]",
"*1 passed*"
])
assert dest.join(subdir.basename).check(dir=1)

View File

@ -136,7 +136,7 @@ class TestHostManager:
hm.teardown_hosts()
def test_hostmanage_ssh_setup_hosts(self, testdir):
sshhost = getsshhost()
sshhost = getsshhost(withpython=True)
testdir.makepyfile(__init__="", test_x="""
def test_one():
pass
@ -149,7 +149,7 @@ class TestHostManager:
@py.test.mark.xfail("implement double-rsync test")
def test_ssh_rsync_samehost_twice(self):
sshhost = getsshhost()
sshhost = getsshhost(withpython=True)
host1 = Host("%s" % (sshhost, ))
host2 = Host("%s" % (sshhost, ))
hm = HostManager(config, hosts=[host1, host2])

View File

@ -186,7 +186,13 @@ class PytestPluginHooks:
""" whole test run starts. """
def pyevent_testrunfinish(self, event):
""" whole test run starts. """
""" whole test run finishes. """
def pyevent_gwmanage_newgateway(self, gateway):
""" execnet gateway manager has instantiated a gateway.
The gateway will have an 'id' attribute that is unique
within the gateway manager context.
"""
def pyevent_hostup(self, event):
""" Host is up. """

View File

@ -84,6 +84,9 @@ class TerminalReporter:
for line in str(event.repr).split("\n"):
self.write_line("InternalException: " + line)
def pyevent_gwmanage_newgateway(self, gateway):
self.write_line("%s instantiated gateway from spec %r" %(gateway.id, gateway.spec._spec))
def pyevent_hostgatewayready(self, event):
if self.config.option.verbose:
self.write_line("HostGatewayReady: %s" %(event.host,))