]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
samba-tool test: ensure `samba-tool help` works
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Mon, 18 Dec 2017 04:06:07 +0000 (17:06 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 22 Dec 2017 06:50:21 +0000 (07:50 +0100)
We make sure the output is identical to `samba-tool --help` for the same
subcommands.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Fri Dec 22 07:50:21 CET 2017 on sn-devel-144

python/samba/tests/samba_tool/help.py

index 4c12eeff33d6fe361d3c0ea4174ae52a834aba47..62e0b3eaa23d7f13b657e1ed9509236e5ebfe1c6 100644 (file)
@@ -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