From c282cbfc468da341f4d506a5964591d0695beeda Mon Sep 17 00:00:00 2001 From: Attila Fazekas Date: Sat, 20 May 2017 20:21:08 +0200 Subject: [PATCH] Fail when no test case selected When the list based filtering logic was used and no test was selected at the end. testr was invoked to run all test. For example: ostestr --regex a --black-regex a Change-Id: I7b580c3954f71dc5fe347b82d6d14004bfdb8f22 --- os_testr/ostestr.py | 4 ++++ os_testr/tests/test_return_codes.py | 3 +++ 2 files changed, 7 insertions(+) diff --git a/os_testr/ostestr.py b/os_testr/ostestr.py index 990f088..1c41079 100755 --- a/os_testr/ostestr.py +++ b/os_testr/ostestr.py @@ -256,6 +256,10 @@ def _call_testr_with_list(opts, test_list, others): print("\n".join(test_list)) return 0 + if not test_list: + print("No testcase selected to run") + return 8 + ec = call_testr(None, opts.subunit, opts.pretty, opts.list, opts.slowest, opts.parallel, opts.concurrency, opts.until_failure, opts.color, test_list, others) diff --git a/os_testr/tests/test_return_codes.py b/os_testr/tests/test_return_codes.py index 082a74a..4c336b1 100644 --- a/os_testr/tests/test_return_codes.py +++ b/os_testr/tests/test_return_codes.py @@ -102,3 +102,6 @@ class TestReturnCodes(base.TestCase): def test_list(self): self.assertRunExit('ostestr --list', 0) + + def test_no_test(self): + self.assertRunExit('ostestr --regex a --black-regex a', 8)