#---------------------------------------------------------------------
-# 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);
#---------------------------------------------------------------------
-# 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);
#---------------------------------------------------------------------
-# 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);
#---------------------------------------------------------------------
-# 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);
}
}
-# 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: $!");
}
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
last;
}
}
- $testcount = $testcount + 1;
ok($found eq 1, "existence of man page for $command" . "_$subcommand");
}
- return $testcount;
}
1;
#---------------------------------------------------------------------
-# 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);
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';
#---------------------------------------------------------------------
-# 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);