parse_options.sh: Make sure that --help works under sh

This commit is contained in:
Brian Fraser fraserb@gmail.com
2012-11-27 18:05:53 -03:00
parent b1e0aac38f
commit 84043cee75
3 changed files with 17 additions and 4 deletions

View File

@@ -71,7 +71,7 @@ PO_DIR="" # Directory with program option spec files
usage() {
local file="$1"
local usage=$(grep '^Usage: ' "$file")
local usage="$(grep '^Usage: ' "$file")"
echo $usage
echo
echo "For more information, 'man $TOOL' or 'perldoc $file'."

View File

@@ -68,7 +68,7 @@ PO_DIR="" # Directory with program option spec files
usage() {
local file="$1"
local usage=$(grep '^Usage: ' "$file")
local usage="$(grep '^Usage: ' "$file")"
echo $usage
echo
echo "For more information, 'man $TOOL' or 'perldoc $file'."

View File

@@ -14,7 +14,7 @@ use PerconaTest;
my ($tool) = $PROGRAM_NAME =~ m/([\w-]+)\.t$/;
use Test::More tests => 7;
use Test::More;
use File::Temp qw( tempdir );
local $ENV{PTDEBUG} = "";
@@ -61,7 +61,8 @@ for my $i (2..5) {
no_diff(
sub {
local $ENV{_NO_FALSE_NEGATIVES} = 1;
print `$trunk/bin/$tool --read-samples $trunk/t/pt-mysql-summary/samples/temp00$i -- --defaults-file=/tmp/12345/my.sandbox.cnf | tail -n+3 | perl -wlnpe 's/Skipping schema analysis.*/Skipping schema analysis/'`
my $out = `$trunk/bin/$tool --read-samples $trunk/t/pt-mysql-summary/samples/temp00$i -- --defaults-file=/tmp/12345/my.sandbox.cnf | tail -n+3 | perl -wlnpe 's/Skipping schema analysis.*/Skipping schema analysis/'`;
print $out;
},
"t/pt-mysql-summary/samples/expected_output_temp00$i.txt",
),
@@ -69,4 +70,16 @@ for my $i (2..5) {
);
}
# Test that --help works under sh
my $sh = `sh $trunk/bin/$tool --help`;
my $bash = `bash $trunk/bin/$tool --help`;
is(
$sh,
$bash,
"--help works under sh and bash"
);
done_testing;
exit;