]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
tests: make a plan for man page checks
authorMichael Meffie <mmeffie@sinenomine.net>
Tue, 30 Apr 2013 19:38:24 +0000 (15:38 -0400)
committerDerrick Brashear <shadow@your-file-system.com>
Wed, 1 May 2013 14:19:01 +0000 (07:19 -0700)
Split the man page check routine into two routines; one to get the list
of sub-commands for a command, and another to verify a man page exists
for each sub-command.  Use the list of sub-commands to set up the
Test::More plan before running the tests.

Setting the plan before running the tests allows the the man page tests
to run on systems which ship older versions the Test::More module.

Change-Id: I1ed6fb87989e1deff4696562f3b917140592ed17
Reviewed-on: http://gerrit.openafs.org/9835
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Ken Dreyer <ktdreyer@ktdreyer.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
tests/bozo/bos-man-t
tests/bucoord/backup-man-t
tests/kauth/kas-man-t
tests/ptserver/pts-man-t
tests/tests-lib/perl5/mancheck_utils.pm
tests/venus/fs-man-t
tests/volser/vos-man-t

index 73facd259d7d494797d2bcd2859cadef14fe16c3..fedcf5863de9edfc02aef0f99274b11a48522bfd 100755 (executable)
@@ -18,9 +18,8 @@ my $srcdir = "$builddir/src/bozo";
 
 #---------------------------------------------------------------------
 
-# Keep track of number of tests we ran. We don't know up front.
-my $testcount = 0;
+my @sub_commands = lookup_sub_commands($srcdir, $command);
+plan tests => scalar @sub_commands;
+
+test_command_man_pages($builddir, $command, @sub_commands);
 
-check_command_binary("$srcdir/$command");
-my $count = test_command_man_pages($builddir, "$srcdir/$command");
-done_testing($count);
index 714df268a3c919668b180b90dccd70dc8c31acf9..d8df2c823b4b5cb9abb234b4866cc3e03514f4fd 100755 (executable)
@@ -18,9 +18,8 @@ my $srcdir = "$builddir/src/bucoord";
 
 #---------------------------------------------------------------------
 
-# Keep track of number of tests we ran. We don't know up front.
-my $testcount = 0;
+my @sub_commands = lookup_sub_commands($srcdir, $command);
+plan tests => scalar @sub_commands;
+
+test_command_man_pages($builddir, $command, @sub_commands);
 
-check_command_binary("$srcdir/$command");
-my $count = test_command_man_pages($builddir, "$srcdir/$command");
-done_testing($count);
index e45b7070e1a979ca382575845fc69410072b4fb6..16295889644219e689adeed01221a3b239bc5fc3 100755 (executable)
@@ -18,9 +18,8 @@ my $srcdir = "$builddir/src/kauth";
 
 #---------------------------------------------------------------------
 
-# Keep track of number of tests we ran. We don't know up front.
-my $testcount = 0;
+my @sub_commands = lookup_sub_commands($srcdir, $command);
+plan tests => scalar @sub_commands;
+
+test_command_man_pages($builddir, $command, @sub_commands);
 
-check_command_binary("$srcdir/$command");
-my $count = test_command_man_pages($builddir, "$srcdir/$command");
-done_testing($count);
index cac87e0109c5f20bd86227b41b6072275cb1a986..60645ea2bfb40cedc6ab78e4b290abf0e905a616 100755 (executable)
@@ -18,9 +18,8 @@ my $srcdir = "$builddir/src/ptserver";
 
 #---------------------------------------------------------------------
 
-# Keep track of number of tests we ran. We don't know up front.
-my $testcount = 0;
+my @sub_commands = lookup_sub_commands($srcdir, $command);
+plan tests => scalar @sub_commands;
+
+test_command_man_pages($builddir, $command, @sub_commands);
 
-check_command_binary("$srcdir/$command");
-my $count = test_command_man_pages($builddir, "$srcdir/$command");
-done_testing($count);
index 834e603643ef197f5d4e61786e7ee15c3f06b7c7..6b562741d0be9cbce2a0e6b39b8c2804d3a0494e 100644 (file)
@@ -19,27 +19,14 @@ sub check_command_binary {
     }
 }
 
-# TAP test: test_command_man_pages
-#
-# Gather a list of a command's subcommands (like listvol for vos)
-# by running a command with the "help" argument.  From that list
-# of subcommands spit out, see if a man page exists for that
-# command_subcommand
-#
-# Arguments: two scalars:
-#
-#                builddir : A path to the OpenAFS build directory,
-#                           such as /tmp/1.4.14
-#
-#         fullpathcommand : The full path to the actual command's
-#                           binary, such as /tmp/1.4.14/src/volser/vos
 #
-# Returns: the number of tests run
+# Run the command help to determine the list of sub-commands.
 #
-sub test_command_man_pages {
-    my ($builddir, $fullpathcommand) = @_;
+sub lookup_sub_commands {
+    my ($srcdir, $command) = @_;
 
-    my $command = basename($fullpathcommand);
+    my $fullpathcommand = "$srcdir/$command";
+    check_command_binary($fullpathcommand);
 
     # build up our list of available commands from the help output
     open(HELPOUT, "$fullpathcommand help 2>&1 |") or BAIL_OUT("can't fork: $!");
@@ -53,6 +40,25 @@ sub test_command_man_pages {
     }
     close HELPOUT;
     @subcommlist = sort(@subcommlist);
+    return @subcommlist;
+}
+
+# TAP test: test_command_man_pages
+#
+# Test if a man page exists for each command sub-command.
+# Runs one test per sub-command.
+#
+# Arguments:
+#
+#                builddir : A path to the OpenAFS build directory,
+#                           such as /tmp/1.4.14
+#
+#                 command : the name of the command (e.g. vos)
+#
+#             subcommlist : a list of sub-commands for command
+#
+sub test_command_man_pages {
+    my ($builddir, $command, @subcommlist) = @_;
 
     # The following is because File::Find makes no sense to me
     # for this purpose, and actually seems totally misnamed
@@ -78,9 +84,7 @@ sub test_command_man_pages {
                last;
            }
        }
-       $testcount = $testcount + 1;
        ok($found eq 1, "existence of man page for $command" . "_$subcommand");
     }
-    return $testcount;
 }
 1;
index 6e29fd390a5a28c7444e9ac4007ed0118a17ad45..3267b5ddd8c1d26c4b8d55b29d0383d2da0f68cb 100755 (executable)
@@ -18,9 +18,8 @@ my $srcdir = "$builddir/src/venus";
 
 #---------------------------------------------------------------------
 
-# Keep track of number of tests we ran. We don't know up front.
-my $testcount = 0;
+my @sub_commands = lookup_sub_commands($srcdir, $command);
+plan tests => scalar @sub_commands;
+
+test_command_man_pages($builddir, $command, @sub_commands);
 
-check_command_binary("$srcdir/$command");
-my $count = test_command_man_pages($builddir, "$srcdir/$command");
-done_testing($count);
index 4f7aad906978e1b5309071bec410b5a9e2bde6f7..2e2cc3560c5545b65ea743acdb10f0056d5ced63 100755 (executable)
@@ -3,6 +3,8 @@
 use strict;
 use warnings;
 use File::Basename;
+use lib "./tests-lib/perl5";
+use mancheck_utils;
 
 # Set this to the bare command to test
 my $command = 'vos';
@@ -16,12 +18,8 @@ my $srcdir = "$builddir/src/volser";
 
 #---------------------------------------------------------------------
 
-# Keep track of number of tests we ran. We don't know up front.
-my $testcount = 0;
+my @sub_commands = lookup_sub_commands($srcdir, $command);
+plan tests => scalar @sub_commands;
 
-use lib "./tests-lib/perl5";
-use mancheck_utils;
+test_command_man_pages($builddir, $command, @sub_commands);
 
-check_command_binary("$srcdir/$command");
-my $count = test_command_man_pages($builddir, "$srcdir/$command");
-done_testing($count);