[PATCH] D40077: [lit][test-suite] - Allow 1 test to report multiple individual test results
Brian Homerding via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 19 11:12:49 PST 2017
homerdin updated this revision to Diff 127571.
homerdin retitled this revision from "[RFC][LNT][test-suite] - Allow 1 test to report multiple individual test results" to "[lit][test-suite] - Allow 1 test to report multiple individual test results".
homerdin edited the summary of this revision.
https://reviews.llvm.org/D40077
Files:
utils/lit/lit/Test.py
utils/lit/lit/main.py
Index: utils/lit/lit/main.py
===================================================================
--- utils/lit/lit/main.py
+++ utils/lit/lit/main.py
@@ -81,6 +81,17 @@
print('%s: %s ' % (metric_name, value.format()))
print("*" * 10)
+ # Report micro-tests, if present
+ if test.result.microResults:
+ items = sorted(test.result.microResults.items())
+ for micro_test_name, micro_test in items:
+ print("%s MICRO-TEST '%s RESULTS %s" %
+ ('*'*3, micro_test_name, '*'*3))
+
+ for metric_name, value in micro_test.metrics.items():
+ print(' %s: %s ' % (metric_name, value.format()))
+ print("*" * 10)
+
# Ensure the output is flushed.
sys.stdout.flush()
@@ -113,6 +124,23 @@
for key, value in test.result.metrics.items():
metrics_data[key] = value.todata()
+ # Report micro-tests separately, if present
+ if test.result.microResults:
+ for key, micro_test in test.result.microResults.items():
+ micro_full_name = test.getFullName()[:-4] + key + ".test"
+
+ micro_test_data = {
+ 'name' : micro_full_name,
+ 'code' : micro_test.code.name,
+ 'output' : micro_test.output,
+ 'elapsed' : micro_test.elapsed }
+ if micro_test.metrics:
+ micro_test_data['metrics'] = micro_metrics_data = {}
+ for key, value in micro_test.metrics.items():
+ micro_metrics_data[key] = value.todata()
+
+ tests_data.append(micro_test_data)
+
tests_data.append(test_data)
# Write the output.
Index: utils/lit/lit/Test.py
===================================================================
--- utils/lit/lit/Test.py
+++ utils/lit/lit/Test.py
@@ -135,6 +135,8 @@
self.elapsed = elapsed
# The metrics reported by this test.
self.metrics = {}
+ # The micro-test results reported by this test.
+ self.microResults = {}
def addMetric(self, name, value):
"""
@@ -153,6 +155,24 @@
raise TypeError("unexpected metric value: %r" % (value,))
self.metrics[name] = value
+ def addMicroResult(self, name, microResult):
+ """
+ addMicroResult(microResult)
+
+ Attach a micro-test result to the test result, with the given name and
+ result. It is an error to attempt to attach a micro-test with the
+ same name multiple times.
+
+ Each micro-test result must be an instance of the Result class.
+ """
+ if name in self.microResults:
+ raise ValueError("Result already includes microResult for %r" % (
+ name,))
+ if not isinstance(microResult, Result):
+ raise TypeError("unexpected MicroResult value %r" % (microResult,))
+ self.microResults[name] = microResult
+
+
# Test classes.
class TestSuite:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40077.127571.patch
Type: text/x-patch
Size: 3105 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171219/ca18856e/attachment.bin>
More information about the llvm-commits
mailing list