From 314ba6867efa27328c8ff6353dc517954fcf4f70 Mon Sep 17 00:00:00 2001 From: Lucas Meneghel Rodrigues Date: Tue, 19 Aug 2014 22:17:10 -0300 Subject: [PATCH] avocado: Display error message and usage on empty 'run' subcommand Instead of displaying a not very informative 'too few arguments' message, display the original error message that mentions about test IDs *and* the run help output. Adjustments to the original functional test were made accordingly. Signed-off-by: Lucas Meneghel Rodrigues --- avocado/plugins/runner.py | 14 +++++++++----- selftests/all/functional/avocado/basic_tests.py | 4 +++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/avocado/plugins/runner.py b/avocado/plugins/runner.py index 4ddeb94d..8fd89d8f 100644 --- a/avocado/plugins/runner.py +++ b/avocado/plugins/runner.py @@ -96,11 +96,11 @@ class TestRunner(plugin.Plugin): help='Run a list of test modules or dropin tests (space separated)') parser.add_argument('url', type=str, default=None, - help=('Test module names or paths to dropin tests ' - '(space separated)')) + help=('List of test IDs (aliases or paths)'), + nargs='?') parser.add_argument('-z', '--archive', action='store_true', default=False, - help='Archive (ZIP) files generated by tests.') + help='Archive (ZIP) files generated by tests') parser.add_argument('-m', '--multiplex-file', type=str, default=None, help=('Path to an avocado multiplex ' @@ -108,7 +108,7 @@ class TestRunner(plugin.Plugin): nargs='?') parser.add_argument('--keep-tmp-files', action='store_true', default=False, - help='Keep temporary files generated by tests.') + help='Keep temporary files generated by tests') parser.add_argument('--unique-id', type=str, default=None, help=('Unique Job id. Used by a server when job ' @@ -116,6 +116,7 @@ class TestRunner(plugin.Plugin): 'different test machine')) parser.set_defaults(func=self.run_tests) + self.parser = parser self.configured = True def run_tests(self, args): @@ -125,7 +126,10 @@ class TestRunner(plugin.Plugin): :param args: Command line args received from the run subparser. """ job_instance = job.Job(args) - return job_instance.run() + rc = job_instance.run() + if args.url is None: + self.parser.print_help() + return rc class SystemInformation(plugin.Plugin): diff --git a/selftests/all/functional/avocado/basic_tests.py b/selftests/all/functional/avocado/basic_tests.py index 0834656f..678add1c 100644 --- a/selftests/all/functional/avocado/basic_tests.py +++ b/selftests/all/functional/avocado/basic_tests.py @@ -168,9 +168,11 @@ class RunnerOperationTest(unittest.TestCase): cmd_line = './scripts/avocado run' result = process.run(cmd_line, ignore_status=True) expected_rc = 2 - expected_output = 'avocado run: error: too few arguments' + expected_output = 'Empty test ID. A test path or alias must be provided' + expected_output_2 = 'usage:' self.assertEqual(result.exit_status, expected_rc) self.assertIn(expected_output, result.stderr) + self.assertIn(expected_output_2, result.stdout) def test_not_found(self): os.chdir(basedir) -- GitLab