From: Nicolai Hähnle <nicolai.haeh...@amd.com> --- framework/results.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)
diff --git a/framework/results.py b/framework/results.py index 26ebbe7a6..c13379b3e 100644 --- a/framework/results.py +++ b/framework/results.py @@ -202,20 +202,66 @@ class TestResult(object): if relative == '': if self.subtests: raise KeyError(key) return self.result try: return self.subtests[relative] except KeyError: raise KeyError(key) + def set_result(self, key, status): + """Set the result status of a (sub-)test covered by this object. + + Raises KeyError if the test is not covered. + """ + relative = grouptools.relative(self.root, key) + + if relative == '': + if self.subtests: + raise KeyError(key) + self.result = status + return + + if relative not in self.subtests: + raise KeyError(key) + + self.subtests[relative] = status + + @property + def tests(self): + """Iterator over the names of tests covered by this object.""" + if self.subtests: + for subtest in six.iterkeys(self.subtests): + yield grouptools.join(self.root, subtest) + else: + yield self.root + + def add_test(self, key): + """Add a (sub-)test to the tests covered by this object.""" + relative = grouptools.relative(self.root, key) + + if relative == '': + assert not self.subtests + return # Nothing to be done + + self.subtests[relative] = status.NOTRUN + + def have_test(self, key): + """Whether a given (sub-)test is covered by this object.""" + relative = grouptools.relative(self.root, key) + + if relative == '': + return not self.subtests + + return relative in self.subtests + def to_json(self): """Return the TestResult as a json serializable object.""" obj = { '__type__': 'TestResult', 'root': self.root, 'command': self.command, 'environment': self.environment, 'err': self.err, 'out': self.out, 'result': self.result, -- 2.11.0 _______________________________________________ Piglit mailing list Piglit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/piglit