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: 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')