diff options
-rwxr-xr-x | selftest/format-subunit | 12 | ||||
-rw-r--r-- | selftest/subunithelper.py | 38 |
2 files changed, 15 insertions, 35 deletions
diff --git a/selftest/format-subunit b/selftest/format-subunit index ff57b54ace..25cc206fef 100755 --- a/selftest/format-subunit +++ b/selftest/format-subunit @@ -14,10 +14,10 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../lib/testtools")) import subunithelper import subunit -import testtools -def format_time(t): - minutes, seconds = divmod(t, 60) + +def format_time(delta): + minutes, seconds = divmod(delta.seconds, 60) hours, minutes = divmod(minutes, 60) ret = "" if hours: @@ -57,10 +57,10 @@ class PlainFormatter(subunithelper.TestsuiteEnabledTestResult): elif whence == subunit.PROGRESS_CUR: raise NotImplementedError - def report_time(self, time): + def time(self, dt): if self.start_time is None: - self.start_time = time - self.last_time = time + self.start_time = dt + self.last_time = dt def start_testsuite(self, name): self.index += 1 diff --git a/selftest/subunithelper.py b/selftest/subunithelper.py index f15db87d9e..255595da45 100644 --- a/selftest/subunithelper.py +++ b/selftest/subunithelper.py @@ -20,8 +20,8 @@ __all__ = ['parse_results'] import re import sys import subunit +import subunit.iso8601 import testtools -import time VALID_RESULTS = ['success', 'successful', 'failure', 'fail', 'skip', 'knownfail', 'error', 'xfail', 'skip-testsuite', 'testsuite-failure', 'testsuite-xfail', 'testsuite-success', 'testsuite-error'] @@ -51,15 +51,12 @@ def parse_results(msg_ops, statistics, fh): open_tests.append(arg.rstrip()) elif command == "time": msg_ops.control_msg(l) - grp = re.match( - '(\d+)-(\d+)-(\d+) (\d+):(\d+):([.0-9]+)\n', arg) - if grp is None: - grp = re.match( - '(\d+)-(\d+)-(\d+) (\d+):(\d+):([.0-9]+)Z\n', arg) - if grp is None: - print "Unable to parse time line: %s" % arg - if grp is not None: - msg_ops.report_time(time.mktime((int(grp.group(1)), int(grp.group(2)), int(grp.group(3)), int(grp.group(4)), int(grp.group(5)), int(float(grp.group(6))), 0, 0, 0))) + try: + dt = subunit.iso8601.parse_date(arg.rstrip("\n")) + except TypeError, e: + print "Unable to parse time line: %s" % arg.rstrip("\n") + else: + msg_ops.time(dt) elif command in VALID_RESULTS: msg_ops.control_msg(l) result = command @@ -195,23 +192,6 @@ class SubunitOps(subunit.TestProtocolClient,TestsuiteEnabledTestResult): def xfail_test(self, name, reason=None): self.end_test(name, "xfail", reason) - def report_time(self, t): - (year, mon, mday, hour, min, sec, wday, yday, isdst) = time.localtime(t) - self._stream.write("time: %04d-%02d-%02d %02d:%02d:%02d\n" % (year, mon, mday, hour, min, sec)) - - def progress(self, offset, whence): - if whence == subunit.PROGRESS_CUR and offset > -1: - prefix = "+" - elif whence == subunit.PROGRESS_PUSH: - prefix = "" - offset = "push" - elif whence == subunit.PROGRESS_POP: - prefix = "" - offset = "pop" - else: - prefix = "" - self._stream.write("progress: %s%s\n" % (prefix, offset)) - # The following are Samba extensions: def start_testsuite(self, name): self._stream.write("testsuite: %s\n" % name) @@ -261,8 +241,8 @@ class FilterOps(testtools.testresult.TestResult): def control_msg(self, msg): pass # We regenerate control messages, so ignore this - def report_time(self, time): - self._ops.report_time(time) + def time(self, time): + self._ops.time(time) def progress(self, delta, whence): self._ops.progress(delta, whence) |