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: NLucas Meneghel Rodrigues <lmr@redhat.com>
上级 9c52699e
...@@ -96,11 +96,11 @@ class TestRunner(plugin.Plugin): ...@@ -96,11 +96,11 @@ class TestRunner(plugin.Plugin):
help='Run a list of test modules or dropin tests (space separated)') help='Run a list of test modules or dropin tests (space separated)')
parser.add_argument('url', type=str, default=None, parser.add_argument('url', type=str, default=None,
help=('Test module names or paths to dropin tests ' help=('List of test IDs (aliases or paths)'),
'(space separated)')) nargs='?')
parser.add_argument('-z', '--archive', action='store_true', default=False, 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, parser.add_argument('-m', '--multiplex-file', type=str, default=None,
help=('Path to an avocado multiplex ' help=('Path to an avocado multiplex '
...@@ -108,7 +108,7 @@ class TestRunner(plugin.Plugin): ...@@ -108,7 +108,7 @@ class TestRunner(plugin.Plugin):
nargs='?') nargs='?')
parser.add_argument('--keep-tmp-files', action='store_true', default=False, 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, parser.add_argument('--unique-id', type=str, default=None,
help=('Unique Job id. Used by a server when job ' help=('Unique Job id. Used by a server when job '
...@@ -116,6 +116,7 @@ class TestRunner(plugin.Plugin): ...@@ -116,6 +116,7 @@ class TestRunner(plugin.Plugin):
'different test machine')) 'different test machine'))
parser.set_defaults(func=self.run_tests) parser.set_defaults(func=self.run_tests)
self.parser = parser
self.configured = True self.configured = True
def run_tests(self, args): def run_tests(self, args):
...@@ -125,7 +126,10 @@ class TestRunner(plugin.Plugin): ...@@ -125,7 +126,10 @@ class TestRunner(plugin.Plugin):
:param args: Command line args received from the run subparser. :param args: Command line args received from the run subparser.
""" """
job_instance = job.Job(args) 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): class SystemInformation(plugin.Plugin):
......
...@@ -168,9 +168,11 @@ class RunnerOperationTest(unittest.TestCase): ...@@ -168,9 +168,11 @@ class RunnerOperationTest(unittest.TestCase):
cmd_line = './scripts/avocado run' cmd_line = './scripts/avocado run'
result = process.run(cmd_line, ignore_status=True) result = process.run(cmd_line, ignore_status=True)
expected_rc = 2 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.assertEqual(result.exit_status, expected_rc)
self.assertIn(expected_output, result.stderr) self.assertIn(expected_output, result.stderr)
self.assertIn(expected_output_2, result.stdout)
def test_not_found(self): def test_not_found(self):
os.chdir(basedir) os.chdir(basedir)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册