From: Douglas Bagnall Date: Mon, 18 Dec 2017 04:06:07 +0000 (+1300) Subject: samba-tool test: ensure `samba-tool help` works X-Git-Tag: talloc-2.1.11~89 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8a42954775df6795efa9b5ba5676301d14b3efac;p=thirdparty%2Fsamba.git samba-tool test: ensure `samba-tool help` works We make sure the output is identical to `samba-tool --help` for the same subcommands. Signed-off-by: Douglas Bagnall Reviewed-by: Andrew Bartlett Autobuild-User(master): Andrew Bartlett Autobuild-Date(master): Fri Dec 22 07:50:21 CET 2017 on sn-devel-144 --- diff --git a/python/samba/tests/samba_tool/help.py b/python/samba/tests/samba_tool/help.py index 4c12eeff33d..62e0b3eaa23 100644 --- a/python/samba/tests/samba_tool/help.py +++ b/python/samba/tests/samba_tool/help.py @@ -23,7 +23,7 @@ from samba.tests import BlackboxProcessError class HelpTestCase(SambaToolCmdTest): - """Tests for samba-tool --help + """Tests for samba-tool help and --help We test for consistency and lack of crashes.""" @@ -48,12 +48,22 @@ class HelpTestCase(SambaToolCmdTest): output = e.stdout failed_commands.append(c) - output = output.partition('Available subcommands:')[2] - subcommands = re.findall(r'^\s*([\w-]+)\s+-', output, + tail = output.partition('Available subcommands:')[2] + subcommands = re.findall(r'^\s*([\w-]+)\s+-', tail, re.MULTILINE) for s in subcommands: new_commands.append(c + [s]) + # check that `samba-tool help X Y` == `samba-tool X Y --help` + line = ' '.join(['samba-tool', 'help'] + c) + try: + output2 = self.check_output(line) + except BlackboxProcessError as e: + output2 = e.stdout + failed_commands.append(c) + + self.assertEqual(output, output2) + if not new_commands: break