from oeqa.core.loader import OETestLoader
from oeqa.core.runner import OETestRunner
-from oeqa.core.exception import OEQAMissingManifest
+from oeqa.core.exception import OEQAMissingManifest, OEQATestNotFound
class OETestContext(object):
loaderClass = OETestLoader
if args.run_tests:
self.tc_kwargs['load']['modules'] = args.run_tests
+ self.tc_kwargs['load']['modules_required'] = args.run_tests
else:
self.tc_kwargs['load']['modules'] = []
self._process_args(logger, args)
self.tc = self._context_class(**self.tc_kwargs['init'])
- self.tc.loadTests(self.module_paths, **self.tc_kwargs['load'])
+ try:
+ self.tc.loadTests(self.module_paths, **self.tc_kwargs['load'])
+ except OEQATestNotFound as ex:
+ logger.error(ex)
+ sys.exit(1)
if args.list_tests:
rc = self.tc.listTests(args.list_tests, **self.tc_kwargs['run'])
class OEQAPreRun(OEQAException):
pass
+
+class OEQATestNotFound(OEQAException):
+ pass
from oeqa.core.utils.path import findFile
from oeqa.core.utils.test import getSuiteModules, getCaseID
+from oeqa.core.exception import OEQATestNotFound
from oeqa.core.case import OETestCase
from oeqa.core.decorator import decoratorClasses, OETestDecorator, \
OETestFilter, OETestDiscover
return self.suiteClass(suite)
+ def _required_modules_validation(self):
+ """
+ Search in Test context registry if a required
+ test is found, raise an exception when not found.
+ """
+
+ for module in self.modules_required:
+ found = False
+
+ # The module name is splitted to only compare the
+ # first part of a test case id.
+ comp_len = len(module.split('.'))
+ for case in self.tc._registry['cases']:
+ case_comp = '.'.join(case.split('.')[0:comp_len])
+ if module == case_comp:
+ found = True
+ break
+
+ if not found:
+ raise OEQATestNotFound("Not found %s in loaded test cases" % \
+ module)
+
def discover(self):
big_suite = self.suiteClass()
for path in self.module_paths:
for clss in discover_classes:
cases = clss.discover(self.tc._registry)
+ if self.modules_required:
+ self._required_modules_validation()
+
return self.suiteClass(cases) if cases else big_suite
def _filterModule(self, module):
import oeqa
from oeqa.core.context import OETestContext, OETestContextExecutor
-from oeqa.core.exception import OEQAPreRun
+from oeqa.core.exception import OEQAPreRun, OEQATestNotFound
from oeqa.utils.commands import runCmd, get_bb_vars, get_test_layer
self.tc_kwargs['init']['td']['BBPATH'].split(':'))
self.tc = self._context_class(**self.tc_kwargs['init'])
- self.tc.loadTests(self.module_paths, **self.tc_kwargs['load'])
+ try:
+ self.tc.loadTests(self.module_paths, **self.tc_kwargs['load'])
+ except OEQATestNotFound as ex:
+ logger.error(ex)
+ sys.exit(1)
if args.list_tests:
rc = self.tc.listTests(args.list_tests, **self.tc_kwargs['run'])