do rsync-reporting in the plugin, directly to the terminalreporter if available.

This commit is contained in:
holger krekel
2010-01-18 00:41:38 +01:00
parent c607baca2b
commit c1ac3c08dc
2 changed files with 46 additions and 3 deletions

View File

@@ -383,6 +383,33 @@ class TestDSession:
assert node.gateway.spec.popen assert node.gateway.spec.popen
#XXX eq.geteventargs("pytest_sessionfinish") #XXX eq.geteventargs("pytest_sessionfinish")
def test_rsync_printing(self, testdir, linecomp):
config = testdir.parseconfig()
from py._plugin.pytest_terminal import TerminalReporter
rep = TerminalReporter(config, file=linecomp.stringio)
config.pluginmanager.register(rep, "terminalreporter")
dsession = DSession(config)
class gw1:
id = "X1"
spec = execnet.XSpec("popen")
class gw2:
id = "X2"
spec = execnet.XSpec("popen")
#class rinfo:
# version_info = (2, 5, 1, 'final', 0)
# executable = "hello"
# platform = "xyz"
# cwd = "qwe"
#dsession.pytest_gwmanage_newgateway(gw1, rinfo)
#linecomp.assert_contains_lines([
# "*X1*popen*xyz*2.5*"
#])
dsession.pytest_gwmanage_rsyncstart(source="hello", gateways=[gw1, gw2])
linecomp.assert_contains_lines([
"[X1,X2] rsyncing: hello",
])
def test_collected_function_causes_remote_skip(testdir): def test_collected_function_causes_remote_skip(testdir):
sub = testdir.mkpydir("testing") sub = testdir.mkpydir("testing")
sub.join("test_module.py").write(py.code.Source(""" sub.join("test_module.py").write(py.code.Source("""

View File

@@ -70,22 +70,38 @@ class DSession(Session):
self.node2pending = {} self.node2pending = {}
self.item2nodes = {} self.item2nodes = {}
super(DSession, self).__init__(config=config) super(DSession, self).__init__(config=config)
try:
self.terminal = config.pluginmanager.getplugin("terminalreporter")
except KeyError:
self.terminal = None
def report_line(self, line):
if self.terminal:
self.terminal.write_line(line)
def pytest_gwmanage_rsyncstart(self, source, gateways):
targets = ",".join([gw.id for gw in gateways])
msg = "[%s] rsyncing: %s" %(targets, source)
self.report_line(msg)
#def pytest_gwmanage_rsyncfinish(self, source, gateways):
# targets = ", ".join(["[%s]" % gw.id for gw in gateways])
# self.write_line("rsyncfinish: %s -> %s" %(source, targets))
def main(self, colitems): def main(self, colitems):
self.sessionstarts() self.sessionstarts()
self.setup() self.setup()
allitems = self.collect_all_items(colitems) allitems = self.collect_all_items(colitems)
self.nodemanager.wait_nodesready(5.0) self.nodemanager.wait_nodesready(5.0)
#for x in allitems:
# print x.listnames()
exitstatus = self.loop(allitems) exitstatus = self.loop(allitems)
self.teardown() self.teardown()
self.sessionfinishes(exitstatus=exitstatus) self.sessionfinishes(exitstatus=exitstatus)
return exitstatus return exitstatus
def collect_all_items(self, colitems): def collect_all_items(self, colitems):
self.report_line("[master] starting full item collection ...")
allitems = list(self.collect(colitems)) allitems = list(self.collect(colitems))
print ("collected %d items" %(len(allitems))) self.report_line("[master] collected %d items" %(len(allitems)))
return allitems return allitems
def loop_once(self, loopstate): def loop_once(self, loopstate):