mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
subunit: Use RemoteError when passing errors to upstream subunit.
This commit is contained in:
parent
8e328c4e32
commit
dcadb90bd3
@ -32,6 +32,7 @@ class PlainFormatter(subunithelper.TestsuiteEnabledTestResult):
|
|||||||
|
|
||||||
def __init__(self, summaryfile, verbose, immediate, statistics,
|
def __init__(self, summaryfile, verbose, immediate, statistics,
|
||||||
totaltests=None):
|
totaltests=None):
|
||||||
|
super(PlainFormatter, self).__init__()
|
||||||
self.verbose = verbose
|
self.verbose = verbose
|
||||||
self.immediate = immediate
|
self.immediate = immediate
|
||||||
self.statistics = statistics
|
self.statistics = statistics
|
||||||
@ -124,8 +125,8 @@ class PlainFormatter(subunithelper.TestsuiteEnabledTestResult):
|
|||||||
def startTest(self, test):
|
def startTest(self, test):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def addSuccess(self, test, details=None):
|
def addSuccess(self, test):
|
||||||
self.end_test(test.id(), "success", False, details)
|
self.end_test(test.id(), "success", False)
|
||||||
|
|
||||||
def addError(self, test, details=None):
|
def addError(self, test, details=None):
|
||||||
self.end_test(test.id(), "error", True, details)
|
self.end_test(test.id(), "error", True, details)
|
||||||
@ -150,9 +151,12 @@ class PlainFormatter(subunithelper.TestsuiteEnabledTestResult):
|
|||||||
'success': '.'}.get(result, "?(%s)" % result))
|
'success': '.'}.get(result, "?(%s)" % result))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if not self.name in self.test_output:
|
||||||
|
self.test_output[self.name] = ""
|
||||||
|
|
||||||
self.test_output[self.name] += "UNEXPECTED(%s): %s\n" % (result, testname)
|
self.test_output[self.name] += "UNEXPECTED(%s): %s\n" % (result, testname)
|
||||||
if reason is not None:
|
if reason is not None:
|
||||||
self.test_output[self.name] += "REASON: %s\n" % (reason.strip(),)
|
self.test_output[self.name] += "REASON: %s\n" % (reason[1].message.encode("utf-8").strip(),)
|
||||||
|
|
||||||
if self.immediate and not self.verbose:
|
if self.immediate and not self.verbose:
|
||||||
print self.test_output[self.name]
|
print self.test_output[self.name]
|
||||||
|
@ -50,7 +50,7 @@ def parse_results(msg_ops, statistics, fh):
|
|||||||
name = arg.rstrip()
|
name = arg.rstrip()
|
||||||
test = subunit.RemotedTestCase(name)
|
test = subunit.RemotedTestCase(name)
|
||||||
if name in open_tests:
|
if name in open_tests:
|
||||||
msg_ops.addError(open_tests.pop(name), "Test already running")
|
msg_ops.addError(open_tests.pop(name), subunit.RemoteError(u"Test already running"))
|
||||||
msg_ops.startTest(test)
|
msg_ops.startTest(test)
|
||||||
open_tests[name] = test
|
open_tests[name] = test
|
||||||
elif command == "time":
|
elif command == "time":
|
||||||
@ -81,40 +81,43 @@ def parse_results(msg_ops, statistics, fh):
|
|||||||
else:
|
else:
|
||||||
reason += l
|
reason += l
|
||||||
|
|
||||||
|
remote_error = subunit.RemoteError(reason.decode("utf-8"))
|
||||||
|
|
||||||
if not terminated:
|
if not terminated:
|
||||||
statistics['TESTS_ERROR']+=1
|
statistics['TESTS_ERROR']+=1
|
||||||
msg_ops.addError(subunit.RemotedTestCase(testname), "reason (%s) interrupted" % result)
|
msg_ops.addError(subunit.RemotedTestCase(testname), subunit.RemoteError(u"reason (%s) interrupted" % result))
|
||||||
return 1
|
return 1
|
||||||
else:
|
else:
|
||||||
reason = None
|
reason = None
|
||||||
|
remote_error = subunit.RemoteError(u"No reason specified")
|
||||||
if result in ("success", "successful"):
|
if result in ("success", "successful"):
|
||||||
try:
|
try:
|
||||||
test = open_tests.pop(testname)
|
test = open_tests.pop(testname)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
statistics['TESTS_ERROR']+=1
|
statistics['TESTS_ERROR']+=1
|
||||||
msg_ops.addError(subunit.RemotedTestCase(testname), "Test was never started")
|
msg_ops.addError(subunit.RemotedTestCase(testname), subunit.RemoteError(u"Test was never started"))
|
||||||
else:
|
else:
|
||||||
statistics['TESTS_EXPECTED_OK']+=1
|
statistics['TESTS_EXPECTED_OK']+=1
|
||||||
msg_ops.addSuccess(test, reason)
|
msg_ops.addSuccess(test)
|
||||||
elif result in ("xfail", "knownfail"):
|
elif result in ("xfail", "knownfail"):
|
||||||
try:
|
try:
|
||||||
test = open_tests.pop(testname)
|
test = open_tests.pop(testname)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
statistics['TESTS_ERROR']+=1
|
statistics['TESTS_ERROR']+=1
|
||||||
msg_ops.addError(subunit.RemotedTestCase(testname), "Test was never started")
|
msg_ops.addError(subunit.RemotedTestCase(testname), subunit.RemoteError(u"Test was never started"))
|
||||||
else:
|
else:
|
||||||
statistics['TESTS_EXPECTED_FAIL']+=1
|
statistics['TESTS_EXPECTED_FAIL']+=1
|
||||||
msg_ops.addExpectedFail(test, reason)
|
msg_ops.addExpectedFailure(test, remote_error)
|
||||||
expected_fail+=1
|
expected_fail+=1
|
||||||
elif result in ("failure", "fail"):
|
elif result in ("failure", "fail"):
|
||||||
try:
|
try:
|
||||||
test = open_tests.pop(testname)
|
test = open_tests.pop(testname)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
statistics['TESTS_ERROR']+=1
|
statistics['TESTS_ERROR']+=1
|
||||||
msg_ops.addError(subunit.RemotedTestCase(testname), "Test was never started")
|
msg_ops.addError(subunit.RemotedTestCase(testname), subunit.RemoteError(u"Test was never started"))
|
||||||
else:
|
else:
|
||||||
statistics['TESTS_UNEXPECTED_FAIL']+=1
|
statistics['TESTS_UNEXPECTED_FAIL']+=1
|
||||||
msg_ops.addFailure(test, reason)
|
msg_ops.addFailure(test, remote_error)
|
||||||
elif result == "skip":
|
elif result == "skip":
|
||||||
statistics['TESTS_SKIP']+=1
|
statistics['TESTS_SKIP']+=1
|
||||||
# Allow tests to be skipped without prior announcement of test
|
# Allow tests to be skipped without prior announcement of test
|
||||||
@ -129,7 +132,7 @@ def parse_results(msg_ops, statistics, fh):
|
|||||||
test = open_tests.pop(testname)
|
test = open_tests.pop(testname)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
test = subunit.RemotedTestCase(testname)
|
test = subunit.RemotedTestCase(testname)
|
||||||
msg_ops.addError(test, reason)
|
msg_ops.addError(test, remote_error)
|
||||||
elif result == "skip-testsuite":
|
elif result == "skip-testsuite":
|
||||||
msg_ops.skip_testsuite(testname)
|
msg_ops.skip_testsuite(testname)
|
||||||
elif result == "testsuite-success":
|
elif result == "testsuite-success":
|
||||||
@ -160,13 +163,13 @@ def parse_results(msg_ops, statistics, fh):
|
|||||||
|
|
||||||
while open_tests:
|
while open_tests:
|
||||||
test = subunit.RemotedTestCase(open_tests.popitem()[1])
|
test = subunit.RemotedTestCase(open_tests.popitem()[1])
|
||||||
msg_ops.addError(test, "was started but never finished!")
|
msg_ops.addError(test, subunit.RemoteError(u"was started but never finished!"))
|
||||||
statistics['TESTS_ERROR']+=1
|
statistics['TESTS_ERROR']+=1
|
||||||
|
|
||||||
if statistics['TESTS_ERROR'] > 0:
|
if statistics['TESTS_ERROR'] > 0:
|
||||||
return 1
|
return 1
|
||||||
if statistics['TESTS_UNEXPECTED_FAIL'] > 0:
|
if statistics['TESTS_UNEXPECTED_FAIL'] > 0:
|
||||||
return 1
|
return 1
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
@ -258,9 +261,9 @@ class FilterOps(testtools.testresult.TestResult):
|
|||||||
self._ops.addSkip(test, details)
|
self._ops.addSkip(test, details)
|
||||||
self.output = None
|
self.output = None
|
||||||
|
|
||||||
def addExpectedFail(self, test, details=None):
|
def addExpectedFailure(self, test, details=None):
|
||||||
test = self._add_prefix(test)
|
test = self._add_prefix(test)
|
||||||
self._ops.addExpectedFail(test, details)
|
self._ops.addExpectedFailure(test, details)
|
||||||
self.output = None
|
self.output = None
|
||||||
|
|
||||||
def addFailure(self, test, details=None):
|
def addFailure(self, test, details=None):
|
||||||
@ -270,10 +273,10 @@ class FilterOps(testtools.testresult.TestResult):
|
|||||||
self.xfail_added+=1
|
self.xfail_added+=1
|
||||||
self.total_xfail+=1
|
self.total_xfail+=1
|
||||||
if details is not None:
|
if details is not None:
|
||||||
details += xfail_reason
|
details = subunit.RemoteError(details[1].message + xfail_reason.decode("utf-8"))
|
||||||
else:
|
else:
|
||||||
details = xfail_reason
|
details = subunit.RemoteError(xfail_reason.decode("utf-8"))
|
||||||
self._ops.addExpectedFail(test, details)
|
self._ops.addExpectedFailure(test, details)
|
||||||
else:
|
else:
|
||||||
self.fail_added+=1
|
self.fail_added+=1
|
||||||
self.total_fail+=1
|
self.total_fail+=1
|
||||||
|
Loading…
Reference in New Issue
Block a user