do rsync-reporting in the plugin, directly to the terminalreporter if available.
This commit is contained in:
@@ -383,6 +383,33 @@ class TestDSession:
|
||||
assert node.gateway.spec.popen
|
||||
#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):
|
||||
sub = testdir.mkpydir("testing")
|
||||
sub.join("test_module.py").write(py.code.Source("""
|
||||
|
||||
@@ -70,22 +70,38 @@ class DSession(Session):
|
||||
self.node2pending = {}
|
||||
self.item2nodes = {}
|
||||
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):
|
||||
self.sessionstarts()
|
||||
self.setup()
|
||||
allitems = self.collect_all_items(colitems)
|
||||
self.nodemanager.wait_nodesready(5.0)
|
||||
#for x in allitems:
|
||||
# print x.listnames()
|
||||
exitstatus = self.loop(allitems)
|
||||
self.teardown()
|
||||
self.sessionfinishes(exitstatus=exitstatus)
|
||||
return exitstatus
|
||||
|
||||
def collect_all_items(self, colitems):
|
||||
self.report_line("[master] starting full item collection ...")
|
||||
allitems = list(self.collect(colitems))
|
||||
print ("collected %d items" %(len(allitems)))
|
||||
self.report_line("[master] collected %d items" %(len(allitems)))
|
||||
return allitems
|
||||
|
||||
def loop_once(self, loopstate):
|
||||
|
||||
Reference in New Issue
Block a user