aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYeoh Ee Peng <ee.peng.yeoh@intel.com>2018-10-18 17:11:05 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-10-18 16:47:59 +0100
commit79ee7d1c371a86edeb61c99679985118da657e5d (patch)
treec2da5ddee1dffabf7025b5eefbf23d83b6a01f50
parent405e822e9da4b53ec9ee8019364fdcb13ccc2587 (diff)
downloadopenembedded-core-contrib-79ee7d1c371a86edeb61c99679985118da657e5d.tar.gz
openembedded-core-contrib-79ee7d1c371a86edeb61c99679985118da657e5d.tar.bz2
openembedded-core-contrib-79ee7d1c371a86edeb61c99679985118da657e5d.zip
oeqa/core/runner: refactor for OEQA to write json testresult
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. Signed-off-by: Yeoh Ee Peng <ee.peng.yeoh@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/lib/oeqa/core/runner.py70
1 files changed, 29 insertions, 41 deletions
diff --git a/meta/lib/oeqa/core/runner.py b/meta/lib/oeqa/core/runner.py
index eeb625b7ff..f1dd08014c 100644
--- a/meta/lib/oeqa/core/runner.py
+++ b/meta/lib/oeqa/core/runner.py
@@ -76,40 +76,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
@@ -121,17 +124,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'):
@@ -143,12 +136,7 @@ class OETestResult(_TestResult):
if case.id() in self.starttime and case.id() in self.endtime:
t = " (" + "{0:.2f}".format(self.endtime[case.id()] - self.starttime[case.id()]) + "s)"
- if fail:
- self.tc.logger.info("RESULTS - %s - Testcase %s: %s%s" % (case.id(),
- oeid, desc, t))
- else:
- self.tc.logger.info("RESULTS - %s - Testcase %s: %s%s" % (case.id(),
- oeid, 'UNKNOWN', t))
+ self.tc.logger.info("RESULTS - %s - Testcase %s: %s%s" % (case.id(), oeid, status, t))
class OEListTestsResult(object):
def wasSuccessful(self):