提交 0b03fa54 编写于 作者: L Lucas Meneghel Rodrigues 提交者: Lucas Meneghel Rodrigues

Merge pull request #150 from lmr/more-usability-fixes

More usability fixes
......@@ -17,6 +17,7 @@ The core Avocado application.
"""
import os
import sys
from argparse import ArgumentParser
......@@ -64,7 +65,12 @@ class AvocadoApp(object):
description='valid subcommands',
help='subcommand help')
self.load_plugin_manager(args.plugins_dir)
args, _ = self.app_parser.parse_known_args()
default_args = None
if not sys.argv[1:]:
default_args = ['--help']
args, _ = self.app_parser.parse_known_args(args=default_args)
self.plugin_manager.activate(args)
self.args = self.app_parser.parse_args()
......
......@@ -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):
......
......@@ -154,14 +154,25 @@ class RunnerOperationTest(unittest.TestCase):
self.assertEqual(result.exit_status, expected_rc)
self.assertEqual(result.stderr, expected_output)
def test_empty_args_list(self):
os.chdir(basedir)
cmd_line = './scripts/avocado'
result = process.run(cmd_line, ignore_status=True)
expected_rc = 0
unexpected_output = 'too few arguments'
self.assertEqual(result.exit_status, expected_rc)
self.assertNotIn(unexpected_output, result.stdout)
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 = '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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册