[svn r38021] Simple refactoring to be a bit more verbose when starting.

--HG--
branch : trunk
This commit is contained in:
fijal 2007-02-06 19:44:16 +01:00
parent 3690e384a9
commit f69c77a7ab
6 changed files with 22 additions and 12 deletions

View File

@ -115,6 +115,10 @@ class HostManager(object):
hosts = self.config.getvalue("dist_hosts")
hosts = [HostInfo(x) for x in hosts]
self.hosts = hosts
roots = self.config.getvalue_pathlist("dist_rsync_roots")
if roots is None:
roots = [self.config.topdir]
self.roots = roots
def prepare_gateways(self):
dist_remotepython = self.config.getvalue("dist_remotepython")
@ -124,14 +128,11 @@ class HostManager(object):
def init_rsync(self, reporter):
# send each rsync root
roots = self.config.getvalue_pathlist("dist_rsync_roots")
ignores = self.config.getvalue_pathlist("dist_rsync_ignore")
if roots is None:
roots = [self.config.topdir]
self.prepare_gateways()
for host in self.hosts:
reporter(repevent.HostRSyncRoots(host, roots))
for root in roots:
reporter(repevent.HostRSyncRoots(host, self.roots))
for root in self.roots:
rsync = HostRSync(ignores=ignores)
destrelpath = root.relto(self.config.topdir)
for host in self.hosts:

View File

@ -88,8 +88,10 @@ class HostRSyncRootReady(ReportEvent):
self.root = root
class TestStarted(ReportEvent):
def __init__(self, hosts):
def __init__(self, hosts, topdir, roots):
self.hosts = hosts
self.topdir = topdir
self.roots = roots
self.timestart = time.time()
class TestFinished(ReportEvent):

View File

@ -82,6 +82,11 @@ class AbstractReporter(object):
self.hosts_to_rsync = len(item.hosts)
self.out.sep("=", txt)
self.timestart = item.timestart
self.out.write("Root directory: %s\n" % item.topdir)
roots = [str(i.relto(item.topdir)) for i in item.roots]
self.out.write("To rsync:\n")
for root in roots:
self.out.write(" => %s\n" % root)
def report_RsyncFinished(self, item):
self.timersync = item.time

View File

@ -132,7 +132,8 @@ class RSession(AbstractSession):
hm.hosts, RemoteReporter)
reporter, checkfun = self.wrap_reporter(reporter)
reporter(repevent.TestStarted(hm.hosts))
reporter(repevent.TestStarted(hm.hosts, self.config.topdir,
hm.roots))
try:
nodes = hm.setup_hosts(reporter)
@ -186,7 +187,7 @@ class LSession(AbstractSession):
hosts, LocalReporter, args[0])
reporter, checkfun = self.wrap_reporter(reporter)
reporter(repevent.TestStarted(hosts))
reporter(repevent.TestStarted(hosts, self.config.topdir, []))
colitems = self.config.getcolitems()
reporter(repevent.RsyncFinished())

View File

@ -142,7 +142,7 @@ class AbstractTestReporter(object):
rootcol = py.test.collect.Directory(tmpdir)
host = HostInfo('localhost')
r = self.reporter(config, [host])
r.report(repevent.TestStarted([host]))
r.report(repevent.TestStarted([host], config.topdir, ["a"]))
r.report(repevent.RsyncFinished())
list(rootcol._tryiter(reporterror=lambda x : AbstractSession.reporterror(r.report, x)))
r.report(repevent.TestFinished())
@ -160,7 +160,7 @@ class AbstractTestReporter(object):
config = py.test.config._reparse([str(tmpdir)])
hosts = [HostInfo(i) for i in ["host1", "host2", "host3"]]
r = self.reporter(config, hosts)
r.report(repevent.TestStarted(hosts))
r.report(repevent.TestStarted(hosts, config.topdir, ["a", "b", "c"]))
for host in hosts:
r.report(repevent.HostRSyncRoots(host, ["a", "b", "c"]))
for host in hosts:

View File

@ -66,8 +66,9 @@ class TestRestUnits(object):
assert stdout.getvalue() == '::\n\n localhost: READY\n\n'
def test_report_TestStarted(self):
event = repevent.TestStarted(hosts=[HostInfo('localhost'),
HostInfo('foo.com')])
event = repevent.TestStarted([HostInfo('localhost'),
HostInfo('foo.com')],
"aa", ["a", "b"])
reporter.report(event)
assert stdout.getvalue() == """\
===========================================