summaryrefslogtreecommitdiff
path: root/testrepository/tests/ui
diff options
context:
space:
mode:
authorRobert Collins <robertc@robertcollins.net>2012-12-03 19:11:56 +1300
committerRobert Collins <robertc@robertcollins.net>2012-12-03 19:11:56 +1300
commita536d5efb4c5973ee4cd281bfae7581c2017391a (patch)
treeeb5ef84be530e20cdcd55b0329a6cb969c5d8c73 /testrepository/tests/ui
parent53d870aed04d4b6245086a2c70d455b4d301d4ef (diff)
downloadtestrepository-a536d5efb4c5973ee4cd281bfae7581c2017391a.tar.gz
* As a side effect of fixing bug #597060 additional arguments passed to testr
run or testr list are only passed to the underlying test runner if they are preceeded by '--'. (Robert Collins, #597060) * ``AbstractArgument`` now handles the case where additional arguments are present that the argument type cannot parse, but enough have been parsed for it to be valid. This allows optional arguments to be in the middle of a grammar. (Robert Collins) * ``cli.UI`` now passed '--' down to the argument layer for handling rather than implicitly stripping it. (Robert Collins) * ``DoubledashArgument`` added to allow fine grained control over the impact of -- in command lines. (Robert Collins) * ``StringArgument`` now rejects '--' - it should be handled by the use of a ``DoubledashArgument`` where one is expected. This is a bit awkward and does not permit passing '--' down to a child process, so further work may be needed - file a bug if this affects you. (Robert Collins) * ``testr run foo`` now applies foo as a regex filter against the tests found by doing a listing of the test runners tests. Likewise ``testr list-tests foo`` will apply foo as a filter against the found tests. This makes it easy to limit the tests that will be requested for running by the backend test process - simply pass one or more regex filters into testr run. (Robert Collins, #597060)
Diffstat (limited to 'testrepository/tests/ui')
-rw-r--r--testrepository/tests/ui/test_cli.py25
1 files changed, 22 insertions, 3 deletions
diff --git a/testrepository/tests/ui/test_cli.py b/testrepository/tests/ui/test_cli.py
index 8a30ff5..62ca7db 100644
--- a/testrepository/tests/ui/test_cli.py
+++ b/testrepository/tests/ui/test_cli.py
@@ -190,15 +190,34 @@ AssertionError: quux...
ui.set_command(cmd)
self.assertEqual("Unexpected arguments: ['one']\n", stderr.getvalue())
- def test_parse_after_double_dash_are_arguments(self):
+ def test_parse_options_after_double_dash_are_arguments(self):
stdout = StringIO()
stdin = StringIO()
stderr = StringIO()
ui = cli.UI(['one', '--', '--two', 'three'], stdin, stdout, stderr)
cmd = commands.Command(ui)
- cmd.args = [arguments.string.StringArgument('args', max=None)]
+ cmd.args = [arguments.string.StringArgument('myargs', max=None),
+ arguments.doubledash.DoubledashArgument(),
+ arguments.string.StringArgument('subargs', max=None)]
ui.set_command(cmd)
- self.assertEqual({'args':['one', '--two', 'three']}, ui.arguments)
+ self.assertEqual({
+ 'doubledash': ['--'],
+ 'myargs': ['one'],
+ 'subargs': ['--two', 'three']},
+ ui.arguments)
+
+ def test_double_dash_passed_to_arguments(self):
+ class CaptureArg(arguments.AbstractArgument):
+ def _parse_one(self, arg):
+ return arg
+ stdout = StringIO()
+ stdin = StringIO()
+ stderr = StringIO()
+ ui = cli.UI(['one', '--', '--two', 'three'], stdin, stdout, stderr)
+ cmd = commands.Command(ui)
+ cmd.args = [CaptureArg('args', max=None)]
+ ui.set_command(cmd)
+ self.assertEqual({'args':['one', '--', '--two', 'three']}, ui.arguments)
def test_run_subunit_option(self):
ui, cmd = get_test_ui_and_cmd(options=[('subunit', True)])