Simplify and individuate Bash tests so prove reports failures where they happen.

This commit is contained in:
Daniel Nichter
2012-02-23 13:58:57 -07:00
parent a33031e6e4
commit b99293d1b3
17 changed files with 77 additions and 81 deletions

View File

@@ -1,25 +0,0 @@
#!/usr/bin/env perl
BEGIN {
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
};
use strict;
use warnings FATAL => 'all';
use English qw(-no_match_vars);
use PerconaTest;
my ($tool) = $PROGRAM_NAME =~ m/([\w-]+)\.t$/;
push @ARGV, "$trunk/t/lib/bash/*.sh" unless @ARGV;
$ENV{BIN_DIR} = "$trunk/bin";
$ENV{LIB_DIR} = "$trunk/lib/bash";
$ENV{T_LIB_DIR} = "$trunk/t/lib";
$ENV{SANDBOX_VERSION} = "$sandbox_version";
system("$trunk/util/test-bash-functions $trunk/t/lib/samples/bash/dummy.sh @ARGV");
exit;

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash
TESTS=1
plan 1
source "$LIB_DIR/alt_cmds.sh"

1
t/lib/bash/alt_cmds.t Symbolic link
View File

@@ -0,0 +1 @@
../../../util/test-bash-functions

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash
TESTS=20
plan 20
TMPFILE="$TEST_TMPDIR/parse-opts-output"
TMPDIR="$TEST_TMPDIR"
@@ -18,7 +18,7 @@ source "$LIB_DIR/collect.sh"
parse_options "$BIN_DIR/pt-stalk" --run-time 1 -- --defaults-file=/tmp/12345/my.sandbox.cnf
# Prefix (with path) for the collect files.
local p="$TMPDIR/collect/2011_12_05"
p="$TMPDIR/collect/2011_12_05"
# Default collect, no extras like gdb, tcpdump, etc.
collect "$TMPDIR/collect" "2011_12_05" > $p-output 2>&1
@@ -113,7 +113,7 @@ cmd_ok \
"grep -qP '^wait_timeout\t\d' $p-variables" \
"variables"
local iters=$(cat $p-df | grep -c '^TS ')
iters=$(cat $p-df | grep -c '^TS ')
is "$iters" "1" "1 iteration/1s run time"
empty_files=0
@@ -140,7 +140,7 @@ rm $TMPDIR/collect/*
collect "$TMPDIR/collect" "2011_12_05" > $p-output 2>&1
local iters=$(cat $p-df | grep -c '^TS ')
iters=$(cat $p-df | grep -c '^TS ')
is "$iters" "2" "2 iteration/2s run time"
# ############################################################################

1
t/lib/bash/collect.t Symbolic link
View File

@@ -0,0 +1 @@
../../../util/test-bash-functions

View File

@@ -1,9 +1,9 @@
#!/usr/bin/env bash
TESTS=9
plan 9
TMPDIR="$TEST_TMPDIR"
local file="$TMPDIR/pid-file"
file="$TMPDIR/pid-file"
source "$LIB_DIR/log_warn_die.sh"
source "$LIB_DIR/daemon.sh"
@@ -18,7 +18,7 @@ cmd_ok \
"test -f $file" \
"PID file created"
local pid=`cat $file`
pid=`cat $file`
is \
"$pid" \
"$$" \

1
t/lib/bash/daemon.t Symbolic link
View File

@@ -0,0 +1 @@
../../../util/test-bash-functions

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash
TESTS=6
plan 6
source "$LIB_DIR/log_warn_die.sh"

1
t/lib/bash/log_warn_die.t Symbolic link
View File

@@ -0,0 +1 @@
../../../util/test-bash-functions

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash
TESTS=78
plan 78
TMPFILE="$TEST_TMPDIR/parse-opts-output"
TOOL="pt-stalk"
@@ -93,7 +93,7 @@ parse_options "$T_LIB_DIR/samples/bash/po001.sh" --foo >$TMPFILE 2>&1
cmd_ok "grep -q 'Unknown option: --foo' $TMPFILE" "Error on unknown option"
usage_or_errors "$T_LIB_DIR/samples/bash/po001.sh" >$TMPFILE 2>&1
local err=$?
err=$?
is "$err" "1" "Non-zero exit on unknown option"
# ###########################################################################

1
t/lib/bash/parse_options.t Symbolic link
View File

@@ -0,0 +1 @@
../../../util/test-bash-functions

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash
TESTS=11
plan 11
source "$LIB_DIR/log_warn_die.sh"
source "$LIB_DIR/safeguards.sh"

1
t/lib/bash/safeguards.t Symbolic link
View File

@@ -0,0 +1 @@
../../../util/test-bash-functions

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash
TESTS=9
plan 9
source "$LIB_DIR/log_warn_die.sh"
source "$LIB_DIR/tmpdir.sh"
@@ -21,7 +21,7 @@ is "$TMPDIR" "" "rm_tmpdir resets TMPDIR"
# User-specified tmpdir.
# ###########################################################################
local dir="/tmp/use--tmpdir"
dir="/tmp/use--tmpdir"
is "$TMPDIR" "" "TMPDIR not defined"

1
t/lib/bash/tmpdir.t Symbolic link
View File

@@ -0,0 +1 @@
../../../util/test-bash-functions

View File

@@ -1,4 +0,0 @@
#!/bin/sh
# This is a dummy script for testing the Bash libs. t/lib/bashLibs.t
# calls "util/test-bash-functions dummy.sh <lib-test-files.sh>".