Add the ability to run individual shell tests manually

This commit is contained in:
James Shubin
2016-02-02 04:37:55 -05:00
parent ff838700d0
commit 4cb76d3347

View File

@@ -13,17 +13,22 @@ make build
MGMT="$DIR/test/shell/mgmt" MGMT="$DIR/test/shell/mgmt"
cp -a "$DIR/mgmt" "$MGMT" # put a copy there cp -a "$DIR/mgmt" "$MGMT" # put a copy there
failures="" failures=""
count=0
# loop through tests # loop through tests
for i in $DIR/test/shell/*.sh; do for i in $DIR/test/shell/*.sh; do
[ -x "$i" ] || continue # file must be executable [ -x "$i" ] || continue # file must be executable
# TODO: if ARGV has test names, only execute those!
ii=`basename "$i"` # short name ii=`basename "$i"` # short name
# if ARGV has test names, only execute those!
if [ "$1" != '' ]; then
[ "$ii" != "$1" ] && continue
fi
cd $DIR/test/shell/ >/dev/null # shush the cd operation cd $DIR/test/shell/ >/dev/null # shush the cd operation
mkdir -p '/tmp/mgmt/' # directory for mgmt to put files in mkdir -p '/tmp/mgmt/' # directory for mgmt to put files in
#echo "Running: $ii" #echo "Running: $ii"
set +o errexit # don't kill script on test failure
export MGMT_TMPDIR='/tmp/mgmt/' # we can add to env like this export MGMT_TMPDIR='/tmp/mgmt/' # we can add to env like this
count=`expr $count + 1`
set +o errexit # don't kill script on test failure
out=$($i 2>&1) # run and capture stdout & stderr out=$($i 2>&1) # run and capture stdout & stderr
e=$? # save exit code e=$? # save exit code
set -o errexit # re-enable killing on script failure set -o errexit # re-enable killing on script failure
@@ -53,6 +58,12 @@ done
rm -f "$MGMT" rm -f "$MGMT"
make clean make clean
if [ "$count" = '0' ]; then
echo 'FAIL'
echo 'No tests were run!'
exit 1
fi
# display errors # display errors
if [[ -n "${failures}" ]]; then if [[ -n "${failures}" ]]; then
echo 'FAIL' echo 'FAIL'