summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/core/loader.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oeqa/core/loader.py')
-rw-r--r--meta/lib/oeqa/core/loader.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/meta/lib/oeqa/core/loader.py b/meta/lib/oeqa/core/loader.py
index e4c218b57f..332086a13d 100644
--- a/meta/lib/oeqa/core/loader.py
+++ b/meta/lib/oeqa/core/loader.py
@@ -9,6 +9,7 @@ import inspect
9from oeqa.core.utils.path import findFile 9from oeqa.core.utils.path import findFile
10from oeqa.core.utils.test import getSuiteModules, getCaseID 10from oeqa.core.utils.test import getSuiteModules, getCaseID
11 11
12from oeqa.core.exception import OEQATestNotFound
12from oeqa.core.case import OETestCase 13from oeqa.core.case import OETestCase
13from oeqa.core.decorator import decoratorClasses, OETestDecorator, \ 14from oeqa.core.decorator import decoratorClasses, OETestDecorator, \
14 OETestFilter, OETestDiscover 15 OETestFilter, OETestDiscover
@@ -277,6 +278,28 @@ class OETestLoader(unittest.TestLoader):
277 278
278 return self.suiteClass(suite) 279 return self.suiteClass(suite)
279 280
281 def _required_modules_validation(self):
282 """
283 Search in Test context registry if a required
284 test is found, raise an exception when not found.
285 """
286
287 for module in self.modules_required:
288 found = False
289
290 # The module name is splitted to only compare the
291 # first part of a test case id.
292 comp_len = len(module.split('.'))
293 for case in self.tc._registry['cases']:
294 case_comp = '.'.join(case.split('.')[0:comp_len])
295 if module == case_comp:
296 found = True
297 break
298
299 if not found:
300 raise OEQATestNotFound("Not found %s in loaded test cases" % \
301 module)
302
280 def discover(self): 303 def discover(self):
281 big_suite = self.suiteClass() 304 big_suite = self.suiteClass()
282 for path in self.module_paths: 305 for path in self.module_paths:
@@ -291,6 +314,9 @@ class OETestLoader(unittest.TestLoader):
291 for clss in discover_classes: 314 for clss in discover_classes:
292 cases = clss.discover(self.tc._registry) 315 cases = clss.discover(self.tc._registry)
293 316
317 if self.modules_required:
318 self._required_modules_validation()
319
294 return self.suiteClass(cases) if cases else big_suite 320 return self.suiteClass(cases) if cases else big_suite
295 321
296 def _filterModule(self, module): 322 def _filterModule(self, module):