Test: Added detail env var to sum.sh, Changed make test to include detailed test
This commit is contained in:
parent
42efb59a75
commit
e724dd7f40
5 changed files with 34 additions and 7 deletions
|
|
@ -312,6 +312,7 @@ if $NGINXCHECK; then
|
|||
fi # systemctl
|
||||
fi
|
||||
|
||||
# Temp directory where all tests write their data to
|
||||
dir=/var/tmp/$0
|
||||
if [ ! -d $dir ]; then
|
||||
mkdir $dir
|
||||
|
|
|
|||
30
test/sum.sh
30
test/sum.sh
|
|
@ -8,6 +8,17 @@
|
|||
|
||||
: ${pattern:=test_*.sh}
|
||||
|
||||
# If set, show details of (first) failing test after all tests completed
|
||||
: ${detail:=false}
|
||||
|
||||
# temp directory, now used only by detail
|
||||
dir=/var/tmp/$0
|
||||
if $detail; then
|
||||
if [ ! -d $dir ]; then
|
||||
mkdir $dir
|
||||
fi
|
||||
fi
|
||||
|
||||
# You can specify tests files to exclude using the 'SKIPLIST' variable in a
|
||||
# site.sh file. See example in README.md. Files excluded by the 'SKIPLIST'
|
||||
# variable have precedence over files included by the 'pattern' variable.
|
||||
|
|
@ -28,20 +39,35 @@ fi
|
|||
let sumerr=0 # error counter
|
||||
for testfile in $pattern; do # For lib.sh the variable must be called testfile
|
||||
echo "Running $testfile"
|
||||
./$testfile > /dev/null 2>&1
|
||||
if $detail; then
|
||||
./$testfile > $dir/err.log 2>&1
|
||||
else
|
||||
./$testfile > /dev/null 2>&1
|
||||
fi
|
||||
errcode=$?
|
||||
if [ $errcode -ne 0 ]; then
|
||||
let sumerr++
|
||||
echo -e "\e[31mError in $testfile errcode=$errcode"
|
||||
echo -ne "\e[0m"
|
||||
if $detail; then
|
||||
detail=false; # Just once for now, print at end
|
||||
fi
|
||||
fi
|
||||
done
|
||||
if [ $sumerr -eq 0 ]; then
|
||||
echo "OK"
|
||||
else
|
||||
echo -e "\e[31m"
|
||||
if [ -f $dir/err.log ]; then
|
||||
echo "Detailed output of first error:"
|
||||
echo -ne "\e[0m"
|
||||
cat $dir/err.log
|
||||
echo
|
||||
fi
|
||||
echo -e "\e[31m${sumerr} Errors"
|
||||
echo -ne "\e[0m"
|
||||
rm -rf $dir
|
||||
exit -1
|
||||
fi
|
||||
|
||||
|
||||
rm -rf $dir
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue