From ef3fb75261d1ce0d10da3e0c636c895aeb8b8441 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 30 Mar 2010 00:30:52 +0200 Subject: selftest: Replace perl subunit formatter with python subunit formatter, so we can leverage the work happening in python-subunit. --- selftest/subunithelper.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'selftest/subunithelper.py') diff --git a/selftest/subunithelper.py b/selftest/subunithelper.py index 3cd0f013d0..770b14befa 100644 --- a/selftest/subunithelper.py +++ b/selftest/subunithelper.py @@ -28,24 +28,29 @@ def parse_results(msg_ops, statistics, fh): while fh: l = fh.readline() + if l == "": + break if l.startswith("test: "): msg_ops.control_msg(l) name = l.split(":", 1)[1].strip() msg_ops.start_test(name) open_tests.append(name) elif l.startswith("time: "): - (year, month, day, hour, minute, second) = re.match( - "^time: (\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)\n/", l) - msg_ops.report_time(time.mktime(second, minute, hour, day, month-1, year-1900)) + grp = re.match( + "^time: (\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)\n", l) + 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(grp.group(6)), 0, 0, 0))) elif re.match("^(" + "|".join(VALID_RESULTS) + "): (.*?)( \[)?([ \t]*)( multipart)?\n", l): msg_ops.control_msg(l) - (result, testname, hasreason) = re.match("^(" + "|".join(VALID_RESULTS) + "): (.*?)( \[)?([ \t]*)( multipart)?\n", l) + grp = re.match("^(" + "|".join(VALID_RESULTS) + "): (.*?)( \[)?([ \t]*)( multipart)?\n", l) + (result, testname, hasreason) = (grp.group(1), grp.group(2), grp.group(3)) if hasreason: reason = "" # reason may be specified in next lines terminated = False while fh: l = fh.readline() + if l == "": + break msg_ops.control_msg(l) if l == "]\n": terminated = True @@ -58,6 +63,8 @@ def parse_results(msg_ops, statistics, fh): msg_ops.end_test(testname, "error", 1, "reason (%s) interrupted" % result) return 1 + else: + reason = None if result in ("success", "successful"): open_tests.pop() #FIXME: Check that popped value == $testname statistics['TESTS_EXPECTED_OK']+=1 @@ -104,12 +111,6 @@ def parse_results(msg_ops, statistics, fh): "was started but never finished!") statistics['TESTS_ERROR']+=1 - # if the Filter module is in use, it will have the right counts - if 'total_error' in msg_ops: - statistics['TESTS_ERROR'] = msg_ops['total_error'] - statistics['TESTS_UNEXPECTED_FAIL'] = msg_ops['total_fail'] - statistics['TESTS_EXPECTED_FAIL'] = msg_ops['total_xfail'] - if statistics['TESTS_ERROR'] > 0: return 1 if statistics['TESTS_UNEXPECTED_FAIL'] > 0: -- cgit