Skip to content

Commit

Permalink
Change test script to use runlist.txt in subdirectories
Browse files Browse the repository at this point in the history
This changes the testall.sh script so that it will find runlist.txt
files in all subdirectories of the current directory, allowing the
script to be used to test the collection of report queries located in
many directories.
  • Loading branch information
nassibnassar committed Jun 16, 2022
1 parent b889919 commit 37ba919
Showing 1 changed file with 26 additions and 19 deletions.
45 changes: 26 additions & 19 deletions testall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,11 @@ while getopts 'JTcfhtvX' flag; do
exit 1 ;;
esac
done
# Check that the runlist exists.
if [[ ! -f runlist.txt ]]; then
echo "testall.sh: runlist.txt not found" 1>&2
exit 1
fi
# Check for duplicates in runlist.
if [[ $(sort runlist.txt | uniq -d) ]]; then
echo "testall.sh: runlist.txt contains duplicates: `sort runlist.txt | uniq -d`" 1>&2
exit 1
fi
# Check which operating system is running.
case "$(uname -s)" in
Linux*) tmpfile=`mktemp --tmpdir=. testall-XXXXXXXXXX.tmp`
Linux*) tmpfile=`pwd`/`mktemp --tmpdir=. tmp-testall-XXXXXXXXXX`
gnutime=/usr/bin/time ;;
Darwin*) tmpfile=`mktemp testall.XXXXXXXXXX`
Darwin*) tmpfile=`pwd`/`mktemp tmp-testall.XXXXXXXXXX`
gnutime=gtime ;;
*) echo "testall.sh: unsupported operating system: `uname -s`" 1>&2
exit 1 ;;
Expand All @@ -56,13 +46,30 @@ if $fmttime; then
else
gtimefmt='%es'
fi
for f in $( cat runlist.txt ); do
if ! PGOPTIONS='--client-min-messages=warning' $gnutime -o $tmpfile -f $gtimefmt psql -c '\set ON_ERROR_STOP on' -f $f -Xq ; then
exit 1
IFS=$'\n'
for d in $( find `pwd` -type d ); do
cd "$d"
# Check that the runlist exists.
if [[ ! -f runlist.txt ]]; then
continue
fi
if $fmttime; then
printf '%s\t%-50s\n' `cat $tmpfile` $f
else
printf 'ok\t%-50s\t%s\n' $f `cat $tmpfile`
echo ""
echo "###############################################################################"
echo "# $d"
echo "###############################################################################"
# Check for duplicates in runlist.
if [[ $(sort runlist.txt | uniq -d) ]]; then
echo "testall.sh: runlist.txt contains duplicates: `sort runlist.txt | uniq -d`" 1>&2
exit 1
fi
for f in $( cat runlist.txt ); do
if ! PGOPTIONS='--client-min-messages=warning' $gnutime -o $tmpfile -f $gtimefmt psql -P pager -c '\set ON_ERROR_STOP on' -f $f -Xq ; then
exit 1
fi
if $fmttime; then
printf '%s\t%-50s\n' `cat $tmpfile` $f
else
printf 'ok\t%-50s\t%s\n' $f `cat $tmpfile`
fi
done || exit 1
done || exit 1

0 comments on commit 37ba919

Please sign in to comment.