[PATCH] D16871: lit: Allow arbitrary key/value data in a test result

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 3 17:38:20 PST 2016


MatzeB created this revision.
MatzeB added reviewers: ddunbar, cmatthews, EricWF.
MatzeB added a subscriber: llvm-commits.
MatzeB set the repository for this revision to rL LLVM.
Herald added a subscriber: mcrosier.

The test-suite will use this to attach additional infos like the md5sum
of the executable to the test result. We should not use the existing
addMetric() interface for this as an md5sum is not really a metric.

Repository:
  rL LLVM

http://reviews.llvm.org/D16871

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
@@ -94,19 +94,19 @@
     # Encode the tests.
     data['tests'] = tests_data = []
     for test in run.tests:
-        test_data = {
-            'name' : test.getFullName(),
-            'code' : test.result.code.name,
-            'output' : test.result.output,
-            'elapsed' : test.result.elapsed }
+        result = test.result
+        result.data['name'] = test.getFullName()
+        result.data['code'] = result.code.name
+        result.data['output'] = result.output
+        result.data['elapsed'] = result.elapsed
 
         # Add test metrics, if present.
-        if test.result.metrics:
-            test_data['metrics'] = metrics_data = {}
-            for key, value in test.result.metrics.items():
+        if result.metrics:
+            result.data['metrics'] = metrics_data = {}
+            for key, value in result.metrics.items():
                 metrics_data[key] = value.todata()
 
-        tests_data.append(test_data)
+        tests_data.append(result.data)
 
     # Write the output.
     f = open(output_path, 'w')
Index: utils/lit/lit/Test.py
===================================================================
--- utils/lit/lit/Test.py
+++ utils/lit/lit/Test.py
@@ -126,6 +126,8 @@
         self.elapsed = elapsed
         # The metrics reported by this test.
         self.metrics = {}
+        # Additional data reported by this test.
+        self.data = {}
 
     def addMetric(self, name, value):
         """
@@ -144,6 +146,15 @@
             raise TypeError("unexpected metric value: %r" % (value,))
         self.metrics[name] = value
 
+    def addData(self, name, value):
+        """
+        Attach additional data to the test result.
+
+        The data must be encodable as JSon (strings, numbers, lists,
+        dictionaires)
+        """
+        self.data[name] = value
+
 # Test classes.
 
 class TestSuite:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16871.46855.patch
Type: text/x-patch
Size: 2018 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160204/579b9aeb/attachment.bin>


More information about the llvm-commits mailing list