1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-21 20:12:56 +02:00

[lit] Add helper for test.result.code.isFailure

This commit is contained in:
Julian Lettner 2019-02-24 21:59:55 -08:00 committed by Julian Lettner
parent aa70a4bf1b
commit 1ad1c85e01
3 changed files with 13 additions and 12 deletions

View File

@ -224,13 +224,14 @@ class Test:
self.result = None
def setResult(self, result):
if self.result is not None:
raise ValueError("test result already set")
if not isinstance(result, Result):
raise ValueError("unexpected result type")
assert self.result is None, "result already set"
assert isinstance(result, Result), "unexpected result type"
self.result = result
def isFailure(self):
assert self.result
return self.result.code.isFailure
def getFullName(self):
return self.suite.config.name + ' :: ' + '/'.join(self.path_in_suite)
@ -364,7 +365,7 @@ class Test:
elapsed_time = self.result.elapsed if self.result.elapsed is not None else 0.0
testcase_xml = testcase_template.format(class_name=class_name, test_name=test_name, time=elapsed_time)
fil.write(testcase_xml)
if self.result.code.isFailure:
if self.isFailure():
fil.write(">\n\t<failure ><![CDATA[")
# In Python2, 'str' and 'unicode' are distinct types, but in Python3, the type 'unicode' does not exist
# and instead 'bytes' is distinct

View File

@ -45,7 +45,7 @@ class ProgressDisplay(object):
def update(self, test):
self.completed += 1
show_result = test.result.code.isFailure or \
show_result = test.isFailure() or \
self.opts.showAllOutput or \
(not self.opts.quiet and not self.opts.succinct)
if show_result:
@ -65,9 +65,9 @@ class ProgressDisplay(object):
self.completed, self.numTests))
# Show the test failure output, if requested.
if (test.result.code.isFailure and self.opts.showOutput) or \
if (test.isFailure() and self.opts.showOutput) or \
self.opts.showAllOutput:
if test.result.code.isFailure:
if test.isFailure():
print("%s TEST '%s' FAILED %s" % ('*'*20, test.getFullName(),
'*'*20))
out = test.result.output

View File

@ -90,7 +90,7 @@ def main(builtin_params = {}):
if litConfig.numWarnings:
sys.stderr.write('\n%d warning(s) in tests.\n' % litConfig.numWarnings)
has_failure = any(t.result.code.isFailure for t in tests)
has_failure = any(t.isFailure() for t in tests)
if has_failure:
sys.exit(1)
@ -147,7 +147,7 @@ def determine_order(tests, order):
def touch_file(test):
if test.result.code.isFailure:
if test.isFailure():
os.utime(test.getFilePath(), None)
def filter_by_shard(tests, run, shards, litConfig):
@ -341,7 +341,7 @@ def write_test_results_xunit(tests, opts):
'skipped': 0,
'tests' : [] }
by_suite[suite]['tests'].append(result_test)
if result_test.result.code.isFailure:
if result_test.isFailure():
by_suite[suite]['failures'] += 1
elif result_test.result.code == lit.Test.UNSUPPORTED:
by_suite[suite]['skipped'] += 1