From 1fba3b2d3d3079c8b0345cb18ad3d99abf726d80 Mon Sep 17 00:00:00 2001 From: Lucas Meneghel Rodrigues Date: Thu, 14 Aug 2014 08:49:07 -0300 Subject: [PATCH] avocado.job: Give an error message on an empty test list If an empty list of tests was passed, give an error validation message and exit. Provide a functional test for it. Signed-off-by: Lucas Meneghel Rodrigues --- avocado/job.py | 4 ++++ selftests/all/functional/avocado/basic_tests.py | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/avocado/job.py b/avocado/job.py index a51ca8d1..24a88c8c 100644 --- a/avocado/job.py +++ b/avocado/job.py @@ -399,6 +399,10 @@ class Job(object): e_msg = "Empty test ID. A test path or alias must be provided" raise exceptions.OptionValidationError(e_msg) + if not params_list: + e_msg = "Empty test ID. A test path or alias must be provided" + raise exceptions.OptionValidationError(e_msg) + if self.args is not None: self.args.test_result_total = len(params_list) diff --git a/selftests/all/functional/avocado/basic_tests.py b/selftests/all/functional/avocado/basic_tests.py index 7c62ab79..2b99d304 100644 --- a/selftests/all/functional/avocado/basic_tests.py +++ b/selftests/all/functional/avocado/basic_tests.py @@ -150,10 +150,18 @@ class RunnerOperationTest(unittest.TestCase): result = process.run(cmd_line, ignore_status=True) expected_rc = 0 expected_output = '' - print repr(result.stdout) self.assertEqual(result.exit_status, expected_rc) self.assertEqual(result.stderr, expected_output) + def test_empty_test_list(self): + os.chdir(basedir) + cmd_line = './scripts/avocado run' + result = process.run(cmd_line, ignore_status=True) + expected_rc = 2 + expected_output = 'Empty test ID. A test path or alias must be provided' + self.assertEqual(result.exit_status, expected_rc) + self.assertIn(expected_output, result.stderr) + class RunnerDropinTest(unittest.TestCase): -- GitLab