From 563ed75651d053f3275d97788d4f5396e08a8956 Mon Sep 17 00:00:00 2001 From: hpk Date: Tue, 6 Feb 2007 22:12:36 +0100 Subject: [PATCH] [svn r38035] be more precise when reporting about hosts (enumerate them) --HG-- branch : trunk --- py/test/rsession/hostmanage.py | 2 +- py/test/rsession/reporter.py | 29 ++++++++++++------- .../{test_report.py => test_repevent.py} | 0 py/test/rsession/testing/test_reporter.py | 13 +++++---- 4 files changed, 27 insertions(+), 17 deletions(-) rename py/test/rsession/testing/{test_report.py => test_repevent.py} (100%) diff --git a/py/test/rsession/hostmanage.py b/py/test/rsession/hostmanage.py index 821cd53e7..fbefc9fcc 100644 --- a/py/test/rsession/hostmanage.py +++ b/py/test/rsession/hostmanage.py @@ -25,7 +25,7 @@ class HostInfo(object): def _getuniqueid(self, hostname): l = self._hostname2list.setdefault(hostname, []) - hostid = hostname + "_" * len(l) + hostid = hostname + "[%d]" % len(l) l.append(hostid) return hostid diff --git a/py/test/rsession/reporter.py b/py/test/rsession/reporter.py index b37292b76..6d0f6806a 100644 --- a/py/test/rsession/reporter.py +++ b/py/test/rsession/reporter.py @@ -57,13 +57,15 @@ class AbstractReporter(object): address) def report_HostRSyncing(self, item): - print "%10s: RSYNC ==> %s" % (item.host.hostname[:10], + hostrepr = self._hostrepr(item.host) + print "%15s: RSYNC ==> %s" % (hostrepr, item.host.relpath) def report_HostGatewayReady(self, item): self.to_rsync[item.host] = len(item.roots) - self.out.write("%10s: gateway initialised (remote topdir: %s)\n"\ - % (item.host.hostname, item.host.gw_remotepath)) + hostrepr = self._hostrepr(item.host) + self.out.write("%15s: gateway initialised (remote topdir: %s)\n"\ + % (hostrepr, item.host.gw_remotepath)) def report_HostRSyncRootReady(self, item): self.to_rsync[item.host] -= 1 @@ -72,15 +74,16 @@ class AbstractReporter(object): def _host_ready(self, item): self.hosts_to_rsync -= 1 + hostrepr = self._hostrepr(item.host) if self.hosts_to_rsync: - print "%10s: READY (still %d to go)" % (item.host.hostname[:10], - self.hosts_to_rsync) + print "%15s: READY (still %d to go)" % (hostrepr, + self.hosts_to_rsync) else: - print "%10s: READY" % item.host.hostname[:10] + print "%15s: READY" % hostrepr def report_TestStarted(self, item): - hostnames = [host.hostname for host in item.hosts] - txt = " Test started, hosts: %s " % ", ".join(hostnames) + hostreprs = [self._hostrepr(host) for host in item.hosts] + txt = " Test started, hosts: %s " % ", ".join(hostreprs) self.hosts_to_rsync = len(item.hosts) self.out.sep("=", txt) self.timestart = item.timestart @@ -163,6 +166,9 @@ class AbstractReporter(object): signal = outcome.signal self.out.line("Received signal: %d" % outcome.signal) self.repr_out_err(outcome) + + def _hostrepr(self, host): + return host.hostid def skips(self): texts = {} @@ -223,17 +229,18 @@ class AbstractReporter(object): def report_ReceivedItemOutcome(self, event): host = event.host + hostrepr = self._hostrepr(host) if event.outcome.passed: self.passed[host] += 1 - sys.stdout.write("%10s: PASSED " % host.hostname[:10]) + sys.stdout.write("%15s: PASSED " % hostrepr) elif event.outcome.skipped: self.skipped_tests_outcome.append(event) self.skipped[host] += 1 - sys.stdout.write("%10s: SKIPPED " % host.hostname[:10]) + sys.stdout.write("%15s: SKIPPED " % hostrepr) else: self.failed[host] += 1 self.failed_tests_outcome.append(event) - sys.stdout.write("%10s: " % host.hostname[:10]) + sys.stdout.write("%15s: " % hostrepr) ansi_print("FAILED", esc=(31,1), newline=False, file=sys.stdout) sys.stdout.write(" ") # we should have printed 20 characters to this point diff --git a/py/test/rsession/testing/test_report.py b/py/test/rsession/testing/test_repevent.py similarity index 100% rename from py/test/rsession/testing/test_report.py rename to py/test/rsession/testing/test_repevent.py diff --git a/py/test/rsession/testing/test_reporter.py b/py/test/rsession/testing/test_reporter.py index ee183f36e..fa164f651 100644 --- a/py/test/rsession/testing/test_reporter.py +++ b/py/test/rsession/testing/test_reporter.py @@ -157,12 +157,15 @@ class AbstractTestReporter(BasicRsessionTest): r.report(repevent.HostRSyncRootReady(host, root)) out, err = cap.reset() assert not err - expected1 = "Test started, hosts: host1, host2, host3" - expected2 = """host1: READY (still 2 to go) - host2: READY (still 1 to go) - host3: READY""" + expected1 = "Test started, hosts: host1[0], host2[0], host3[0]" assert out.find(expected1) != -1 - assert out.find(expected2) != -1 + for expected in py.code.Source(""" + host1[0]: READY (still 2 to go) + host2[0]: READY (still 1 to go) + host3[0]: READY + """).lines: + expected = expected.strip() + assert out.find(expected) != -1 class TestLocalReporter(AbstractTestReporter): reporter = LocalReporter