[OE-core] [PATCH 30/45] oeqa/core/runner: refactor for OEQA to write json testresult
Armin Kuster
akuster808 at gmail.com
Thu Dec 13 21:38:38 UTC 2018
From: Yeoh Ee Peng <ee.peng.yeoh at intel.com>
Refactor the original _getDetailsNotPassed method to return
testresult details (test status and log), which will be reused
by future OEQA code to write json testresult.
Take the opportunity to consolidate and simplify the logic used
to gather test status and log within the TestResult instance.
(From OE-Core rev: 79ee7d1c371a86edeb61c99679985118da657e5d)
(From OE-Core rev: bc444181f9658423856621b2f2c60364642ae5b1)
Signed-off-by: Yeoh Ee Peng <ee.peng.yeoh at intel.com>
Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
meta/lib/oeqa/core/runner.py | 70 ++++++++++++++++++--------------------------
1 file changed, 29 insertions(+), 41 deletions(-)
diff --git a/meta/lib/oeqa/core/runner.py b/meta/lib/oeqa/core/runner.py
index 429c216..a7b7463 100644
--- a/meta/lib/oeqa/core/runner.py
+++ b/meta/lib/oeqa/core/runner.py
@@ -61,40 +61,43 @@ class OETestResult(_TestResult):
else:
msg = "%s - FAIL - Required tests failed" % component
skipped = len(self.skipped)
- if skipped:
+ if skipped:
msg += " (skipped=%d)" % skipped
self.tc.logger.info(msg)
- def _getDetailsNotPassed(self, case, type, desc):
- found = False
+ def _getTestResultDetails(self, case):
+ result_types = {'failures': 'FAILED', 'errors': 'ERROR', 'skipped': 'SKIPPED',
+ 'expectedFailures': 'EXPECTEDFAIL', 'successes': 'PASSED'}
- for (scase, msg) in getattr(self, type):
- if case.id() == scase.id():
- found = True
- break
- scase_str = str(scase.id())
-
- # When fails at module or class level the class name is passed as string
- # so figure out to see if match
- m = re.search("^setUpModule \((?P<module_name>.*)\)$", scase_str)
- if m:
- if case.__class__.__module__ == m.group('module_name'):
+ for rtype in result_types:
+ found = False
+ for (scase, msg) in getattr(self, rtype):
+ if case.id() == scase.id():
found = True
break
+ scase_str = str(scase.id())
- m = re.search("^setUpClass \((?P<class_name>.*)\)$", scase_str)
- if m:
- class_name = "%s.%s" % (case.__class__.__module__,
- case.__class__.__name__)
+ # When fails at module or class level the class name is passed as string
+ # so figure out to see if match
+ m = re.search("^setUpModule \((?P<module_name>.*)\)$", scase_str)
+ if m:
+ if case.__class__.__module__ == m.group('module_name'):
+ found = True
+ break
- if class_name == m.group('class_name'):
- found = True
- break
+ m = re.search("^setUpClass \((?P<class_name>.*)\)$", scase_str)
+ if m:
+ class_name = "%s.%s" % (case.__class__.__module__,
+ case.__class__.__name__)
+
+ if class_name == m.group('class_name'):
+ found = True
+ break
- if found:
- return (found, msg)
+ if found:
+ return result_types[rtype], msg
- return (found, None)
+ return 'UNKNOWN', None
def addSuccess(self, test):
#Added so we can keep track of successes too
@@ -106,17 +109,7 @@ class OETestResult(_TestResult):
for case_name in self.tc._registry['cases']:
case = self.tc._registry['cases'][case_name]
- result_types = ['failures', 'errors', 'skipped', 'expectedFailures', 'successes']
- result_desc = ['FAILED', 'ERROR', 'SKIPPED', 'EXPECTEDFAIL', 'PASSED']
-
- fail = False
- desc = None
- for idx, name in enumerate(result_types):
- (fail, msg) = self._getDetailsNotPassed(case, result_types[idx],
- result_desc[idx])
- if fail:
- desc = result_desc[idx]
- break
+ (status, log) = self._getTestResultDetails(case)
oeid = -1
if hasattr(case, 'decorators'):
@@ -124,12 +117,7 @@ class OETestResult(_TestResult):
if hasattr(d, 'oeid'):
oeid = d.oeid
- if fail:
- self.tc.logger.info("RESULTS - %s - Testcase %s: %s" % (case.id(),
- oeid, desc))
- else:
- self.tc.logger.info("RESULTS - %s - Testcase %s: %s" % (case.id(),
- oeid, 'UNKNOWN'))
+ self.tc.logger.info("RESULTS - %s - Testcase %s: %s" % (case.id(), oeid, status))
class OEListTestsResult(object):
def wasSuccessful(self):
--
2.7.4
More information about the Openembedded-core
mailing list