From 0e7ac62b724393529172ab276c89b97e2c8539aa Mon Sep 17 00:00:00 2001 From: Cédric Ollivier Date: Tue, 7 Aug 2018 05:06:23 +0200 Subject: Allow calling a skip test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit run_tests shouldn't return an incorrect value if the test is skipped. Else it simply forbids running tests in parallel (one test per thread). Change-Id: I07efca28dbf6cf1c29ec8e5c999e38cfe3ad0aad Signed-off-by: Cédric Ollivier (cherry picked from commit 0b69c9ee6ca5188045a5927b41fa2666555631d9) --- xtesting/ci/run_tests.py | 14 +++++++------- xtesting/ci/tier_handler.py | 4 ++-- xtesting/tests/unit/ci/test_tier_builder.py | 5 +++-- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/xtesting/ci/run_tests.py b/xtesting/ci/run_tests.py index 26fad9b8..27f9d946 100644 --- a/xtesting/ci/run_tests.py +++ b/xtesting/ci/run_tests.py @@ -49,11 +49,6 @@ class BlockingTestFailed(Exception): pass -class TestNotEnabled(Exception): - """Exception when the test is not enabled""" - pass - - class RunTestsParser(object): """Parser to run tests""" # pylint: disable=too-few-public-methods @@ -144,8 +139,13 @@ class Runner(object): def run_test(self, test): """Run one test case""" if not test.is_enabled(): - raise TestNotEnabled( - "The test case {} is not enabled".format(test.get_name())) + msg = prettytable.PrettyTable( + header_style='upper', padding_width=5, + field_names=['test case', 'project', 'duration', + 'result']) + msg.add_row([test.get_name(), test.get_project(), "00:00", "SKIP"]) + LOGGER.info("Test result:\n\n%s\n", msg) + return testcase.TestCase.EX_TESTCASE_SKIPPED result = testcase.TestCase.EX_RUN_ERROR run_dict = self.get_run_dict(test.get_name()) if run_dict: diff --git a/xtesting/ci/tier_handler.py b/xtesting/ci/tier_handler.py index 0adc9b81..51f031c0 100644 --- a/xtesting/ci/tier_handler.py +++ b/xtesting/ci/tier_handler.py @@ -67,13 +67,13 @@ class Tier(object): def get_test(self, test_name): if self.is_test(test_name): - for test in self.tests_array: + for test in self.tests_array + self.skipped_tests_array: if test.get_name() == test_name: return test return None def is_test(self, test_name): - for test in self.tests_array: + for test in self.tests_array + self.skipped_tests_array: if test.get_name() == test_name: return True return False diff --git a/xtesting/tests/unit/ci/test_tier_builder.py b/xtesting/tests/unit/ci/test_tier_builder.py index 402fc664..0b42bf5c 100644 --- a/xtesting/tests/unit/ci/test_tier_builder.py +++ b/xtesting/tests/unit/ci/test_tier_builder.py @@ -68,8 +68,9 @@ class TierBuilderTesting(unittest.TestCase): self.tier_obj.get_test('test_name')) def test_get_test_disabled(self): - self.assertEqual(self.tierbuilder.get_test('test_name_disabled'), None) - self.assertEqual(self.tier_obj.get_test('test_name_disabled'), None) + self.assertEqual( + self.tierbuilder.get_test('test_name_disabled'), + self.tier_obj.get_test('test_name_disabled')) self.assertEqual( self.tier_obj.get_skipped_test()[0].name, 'test_name_disabled') -- cgit 1.2.3-korg