[Piglit] [PATCH 2/5] summary_tests: Add tests to for status change attribute assignment
Dylan Baker
baker.dylan.c at gmail.com
Mon Mar 17 12:06:11 PDT 2014
Summary stores sets of tests that are known to be of a certain status
(changes, fixes, regressions, etc). These tests take known status
combinations and ensure that they are added to the appropriate list.
Signed-off-by: Dylan Baker <baker.dylan.c at gmail.com>
---
framework/tests/summary_tests.py | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/framework/tests/summary_tests.py b/framework/tests/summary_tests.py
index 68d7002..e6d996e 100644
--- a/framework/tests/summary_tests.py
+++ b/framework/tests/summary_tests.py
@@ -21,6 +21,9 @@
""" Module providing tests for the summary module """
+import json
+import copy
+import nose.tools as nt
import framework.summary as summary
import framework.tests.utils as utils
@@ -30,3 +33,33 @@ def test_initialize_summary():
with utils.resultfile() as tfile:
test = summary.Summary([tfile.name])
assert test
+
+
+def test_summary_add_to_set():
+ """ Generate tests for testing Summary.test sets """
+ old = copy.deepcopy(utils.JSON_DATA)
+ new = copy.deepcopy(utils.JSON_DATA)
+
+ for ostat, nstat, set_ in [('fail', 'pass', 'fixes'),
+ ('pass', 'warn', 'regressions'),
+ ('dmesg-fail', 'warn', 'changes'),
+ ('dmesg-warn', 'crash', 'problems'),
+ ('skip', 'skip', 'skipped')]:
+ check_sets.description = "{0} -> {1} should be added to {2}".format(
+ ostat, nstat, set_)
+
+ yield check_sets, old, ostat, new, nstat, set_
+
+
+def check_sets(old, ostat, new, nstat, set_):
+ """ Check that the statuses are added to the correct set """
+ old['tests']['sometest']['result'] = ostat
+ new['tests']['sometest']['result'] = nstat
+
+ with utils.with_tempfile(json.dumps(old)) as ofile:
+ with utils.with_tempfile(json.dumps(new)) as nfile:
+ summ = summary.Summary([ofile, nfile])
+
+ print summ.tests
+ nt.assert_equal(1, len(summ.tests[set_]),
+ msg="{0} was not appended".format(set_))
--
1.9.0
More information about the Piglit
mailing list