[llvm] 89e34d3 - [lit] Add helper for `test.result.code.isFailure`
Julian Lettner via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 30 15:12:12 PDT 2019
Author: Julian Lettner
Date: 2019-10-30T15:09:43-07:00
New Revision: 89e34d3e5a4619aa0306e904f505b0feafad2aff
URL: https://github.com/llvm/llvm-project/commit/89e34d3e5a4619aa0306e904f505b0feafad2aff
DIFF: https://github.com/llvm/llvm-project/commit/89e34d3e5a4619aa0306e904f505b0feafad2aff.diff
LOG: [lit] Add helper for `test.result.code.isFailure`
Added:
Modified:
llvm/utils/lit/lit/Test.py
llvm/utils/lit/lit/display.py
llvm/utils/lit/lit/main.py
Removed:
################################################################################
diff --git a/llvm/utils/lit/lit/Test.py b/llvm/utils/lit/lit/Test.py
index dffa735fde7c..62f1bbf1f03a 100644
--- a/llvm/utils/lit/lit/Test.py
+++ b/llvm/utils/lit/lit/Test.py
@@ -224,13 +224,14 @@ def __init__(self, suite, path_in_suite, config, file_path = None):
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 @@ def writeJUnitXML(self, fil):
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
diff --git a/llvm/utils/lit/lit/display.py b/llvm/utils/lit/lit/display.py
index 26700134d2e4..8a3857c9c321 100644
--- a/llvm/utils/lit/lit/display.py
+++ b/llvm/utils/lit/lit/display.py
@@ -45,7 +45,7 @@ def finish(self):
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 @@ def print_result(self, test):
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
diff --git a/llvm/utils/lit/lit/main.py b/llvm/utils/lit/lit/main.py
index 1276fdaf2731..81731e7efdc3 100755
--- a/llvm/utils/lit/lit/main.py
+++ b/llvm/utils/lit/lit/main.py
@@ -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 by_mtime(test):
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
More information about the llvm-commits
mailing list