summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorDylan Baker <baker.dylan.c@gmail.com>2015-10-19 14:33:21 -0700
committerDylan Baker <baker.dylan.c@gmail.com>2015-10-20 15:28:46 -0700
commitaddca94d820661f29a77f7c1e984b0e8942512fe (patch)
treefe3d5c4114ca5a9f470d4fc6ab89a3cf897e0daa /framework
parentc36bada7565387b1710bd8ec6c5cc43b226aec36 (diff)
framework/sumamry/common.py: Fix subtest handling in non-all groups
The gist of the problem is that we handle lookup for subtests in the all group correctly, but when we went to compare between multiple results we don't. This patch makes use of the get_result from the previous patch to simplify test name lookups, and fix the non-all case. This also fixes the unit tests introduced in the previous patch. Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com> Tested-by: Marek Olšák <marek.olsak@amd.com>
Diffstat (limited to 'framework')
-rw-r--r--framework/summary/common.py33
-rw-r--r--framework/tests/summary_console_tests.py2
2 files changed, 19 insertions, 16 deletions
diff --git a/framework/summary/common.py b/framework/summary/common.py
index b67a98352..95af02abd 100644
--- a/framework/summary/common.py
+++ b/framework/summary/common.py
@@ -55,19 +55,9 @@ class Results(object): # pylint: disable=too-few-public-methods
results = []
for res in self.results:
try:
- results.append(res.tests[name].result)
+ results.append(res.get_result(name))
except KeyError:
results.append(so.NOTRUN)
- if all(x == so.NOTRUN for x in results):
- # this is likely a subtest, see if that's the case
- name, test = grouptools.splitname(name)
-
- results = []
- for res in self.results:
- try:
- results.append(res.tests[name].subtests[test])
- except KeyError:
- results.append(so.NOTRUN)
return results
@@ -138,8 +128,9 @@ class Names(object):
@lazy_property
def enabled(self):
def handler(names, name, prev, cur):
- if name not in prev.tests and name in cur.tests:
+ if _result_in(name, cur) and not _result_in(name, prev):
names.add(name)
+
return self.__diff(
lambda x, y: x is so.NOTRUN and y is not so.NOTRUN,
handler=handler)
@@ -147,8 +138,9 @@ class Names(object):
@lazy_property
def disabled(self):
def handler(names, name, prev, cur):
- if name in prev.tests and name not in cur.tests:
+ if _result_in(name, prev) and not _result_in(name, cur):
names.add(name)
+
return self.__diff(
lambda x, y: x is not so.NOTRUN and y is so.NOTRUN,
handler=handler)
@@ -266,6 +258,17 @@ def escape_pathname(key):
return re.sub(r'[/\\]', '_', key)
+def _result_in(name, result):
+ """If a result (or a subtest result) exists return True, else False."""
+ try:
+ # This is a little hacky, but I don't know of a better way where we
+ # ensure the value is truthy
+ _ = result.get_result(name)
+ return True
+ except KeyError:
+ return False
+
+
def find_diffs(results, tests, comparator, handler=lambda *a: None):
"""Generate diffs between two or more sets of results.
@@ -290,7 +293,7 @@ def find_diffs(results, tests, comparator, handler=lambda *a: None):
names = set()
for name in tests:
try:
- if comparator(prev.tests[name].result, cur.tests[name].result):
+ if comparator(prev.get_result(name), cur.get_result(name)):
names.add(name)
except KeyError:
handler(names, name, prev, cur)
@@ -305,7 +308,7 @@ def find_single(results, tests, func):
names = set()
for name in tests:
try:
- if func(res.tests[name].result):
+ if func(res.get_result(name)):
names.add(name)
except KeyError:
pass
diff --git a/framework/tests/summary_console_tests.py b/framework/tests/summary_console_tests.py
index 5d9d448d5..53ecdf1a0 100644
--- a/framework/tests/summary_console_tests.py
+++ b/framework/tests/summary_console_tests.py
@@ -93,7 +93,7 @@ class Test_print_summary(object):
incomplete=template.format('0', '0'),
dmesg_warn=template.format('0', '0'),
dmesg_fail=template.format('0', '0'),
- changes=template.format('0', '1'),
+ changes=template.format('0', '2'),
fixes=template.format('0', '1'),
regressions=template.format('0', '0'),
total=template.format('3', '3')).split('\n')