validate:launcher: Do not list tests on unneeded testers

This commit is contained in:
Thibault Saunier 2016-12-22 10:08:23 -03:00
parent 6504b9152c
commit d5de0b702c
2 changed files with 15 additions and 6 deletions

View file

@ -1527,6 +1527,12 @@ class _TestsLauncher(Loggable):
self.tests.extend(tests) self.tests.extend(tests)
return sorted(list(self.tests), key=lambda t: t.classname) return sorted(list(self.tests), key=lambda t: t.classname)
def _tester_needed(self, tester):
for testsuite in self.options.testsuites:
if tester.name in testsuite.TEST_MANAGER:
return True
return False
def _run_tests(self): def _run_tests(self):
cur_test_num = 0 cur_test_num = 0
@ -1534,11 +1540,14 @@ class _TestsLauncher(Loggable):
total_num_tests = 1 total_num_tests = 1
self.all_tests = [] self.all_tests = []
for tester in self.testers: for tester in self.testers:
if self._tester_needed(tester):
self.all_tests.extend(tester.list_tests()) self.all_tests.extend(tester.list_tests())
total_num_tests = len(self.all_tests) total_num_tests = len(self.all_tests)
self.reporter.init_timer() self.reporter.init_timer()
for tester in self.testers: for tester in self.testers:
if not self._tester_needed(tester):
continue
res = tester.run_tests(cur_test_num, total_num_tests) res = tester.run_tests(cur_test_num, total_num_tests)
cur_test_num += len(tester.list_tests()) cur_test_num += len(tester.list_tests())
if res != Result.PASSED and (self.options.forever or if res != Result.PASSED and (self.options.forever or

View file

@ -536,12 +536,12 @@ Note that all testsuite should be inside python modules, so the directory should
ScenarioManager().config = options ScenarioManager().config = options
if not tests_launcher.set_settings(options, []): if not tests_launcher.set_settings(options, []):
exit(1) exit(1)
if options.list_tests:
if tests_launcher.list_tests() == -1: if tests_launcher.list_tests() == -1:
printc("\nFailling as tests have been removed/added " printc("\nFailling as tests have been removed/added "
" (--fail-on-testlist-change)", Colors.FAIL) " (--fail-on-testlist-change)", Colors.FAIL)
exit(1) exit(1)
if options.list_tests:
l = tests_launcher.tests l = tests_launcher.tests
for test in l: for test in l:
printc(test) printc(test)