1
0
mirror of https://git.yoctoproject.org/poky synced 2026-06-01 13:09:50 +00:00

oeqa/runner: Simplify code

There doesn't appear to be any reason we need this _results indirection
any more so remove it.

(From OE-Core rev: b618261811c48ff3b98eab1b340a8cd09ef183c6)

(From OE-Core rev: ab271b49d9b55ea271d519c3a4da0b639a07f0bb)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie
2018-07-11 11:54:20 +00:00
parent 58678f5aa7
commit d8dc75de8b
4 changed files with 8 additions and 16 deletions
-1
View File
@@ -27,7 +27,6 @@ class OETestContext(object):
self.logger = logger self.logger = logger
self._registry = {} self._registry = {}
self._registry['cases'] = collections.OrderedDict() self._registry['cases'] = collections.OrderedDict()
self._results = {}
def _read_modules_from_manifest(self, manifest): def _read_modules_from_manifest(self, manifest):
if not os.path.exists(manifest): if not os.path.exists(manifest):
+1 -3
View File
@@ -63,12 +63,10 @@ def _order_test_case_by_depends(cases, depends):
return [cases[case_id] for case_id in cases_ordered] return [cases[case_id] for case_id in cases_ordered]
def _skipTestDependency(case, depends): def _skipTestDependency(case, depends):
results = case.tc._results
skipReasons = ['errors', 'failures', 'skipped'] skipReasons = ['errors', 'failures', 'skipped']
for reason in skipReasons: for reason in skipReasons:
for test, _ in results[reason]: for test, _ in getattr(case.tc.results, reason):
if test.id() in depends: if test.id() in depends:
raise SkipTest("Test case %s depends on %s and was in %s." \ raise SkipTest("Test case %s depends on %s and was in %s." \
% (case.id(), test.id(), reason)) % (case.id(), test.id(), reason))
+5 -10
View File
@@ -44,8 +44,10 @@ class OETestResult(_TestResult):
self.successes = [] self.successes = []
# Inject into tc so that TestDepends decorator can see results
tc.results = self
self.tc = tc self.tc = tc
self._tc_map_results()
def startTest(self, test): def startTest(self, test):
# Allow us to trigger the testcase buffer mode on a per test basis # Allow us to trigger the testcase buffer mode on a per test basis
@@ -55,13 +57,6 @@ class OETestResult(_TestResult):
self.buffer = test.buffer self.buffer = test.buffer
super(OETestResult, self).startTest(test) super(OETestResult, self).startTest(test)
def _tc_map_results(self):
self.tc._results['failures'] = self.failures
self.tc._results['errors'] = self.errors
self.tc._results['skipped'] = self.skipped
self.tc._results['expectedFailures'] = self.expectedFailures
self.tc._results['successes'] = self.successes
def logSummary(self, component, context_msg=''): def logSummary(self, component, context_msg=''):
elapsed_time = self.tc._run_end_time - self.tc._run_start_time elapsed_time = self.tc._run_end_time - self.tc._run_start_time
self.tc.logger.info("SUMMARY:") self.tc.logger.info("SUMMARY:")
@@ -73,7 +68,7 @@ class OETestResult(_TestResult):
msg = "%s - OK - All required tests passed" % component msg = "%s - OK - All required tests passed" % component
else: else:
msg = "%s - FAIL - Required tests failed" % component msg = "%s - FAIL - Required tests failed" % component
skipped = len(self.tc._results['skipped']) skipped = len(self.skipped)
if skipped: if skipped:
msg += " (skipped=%d)" % skipped msg += " (skipped=%d)" % skipped
self.tc.logger.info(msg) self.tc.logger.info(msg)
@@ -81,7 +76,7 @@ class OETestResult(_TestResult):
def _getDetailsNotPassed(self, case, type, desc): def _getDetailsNotPassed(self, case, type, desc):
found = False found = False
for (scase, msg) in self.tc._results[type]: for (scase, msg) in getattr(self, type):
# XXX: When XML reporting is enabled scase is # XXX: When XML reporting is enabled scase is
# xmlrunner.result._TestInfo instance instead of # xmlrunner.result._TestInfo instance instead of
# string. # string.
+2 -2
View File
@@ -21,7 +21,7 @@ class TestData(TestBase):
tc = self._testLoader(modules=self.modules) tc = self._testLoader(modules=self.modules)
self.assertEqual(False, tc.runTests().wasSuccessful()) self.assertEqual(False, tc.runTests().wasSuccessful())
for test, data in tc._results['errors']: for test, data in tc.errors:
expect = False expect = False
if expectedException in data: if expectedException in data:
expect = True expect = True
@@ -34,7 +34,7 @@ class TestData(TestBase):
tc = self._testLoader(d=d, modules=self.modules) tc = self._testLoader(d=d, modules=self.modules)
self.assertEqual(False, tc.runTests().wasSuccessful()) self.assertEqual(False, tc.runTests().wasSuccessful())
for test, data in tc._results['failures']: for test, data in tc.failures:
expect = False expect = False
if expectedError in data: if expectedError in data:
expect = True expect = True