test: improve semi-manual testing
This commit is contained in:
35
tests/integration/testfunctions.sh
Normal file
35
tests/integration/testfunctions.sh
Normal file
@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ -z $1 ]; then
|
||||
logfile=/dev/null
|
||||
else
|
||||
logfile=$1
|
||||
fi
|
||||
|
||||
if [ -z $logall ]; then
|
||||
logall=no
|
||||
fi
|
||||
|
||||
run_test () {
|
||||
if [ -z "$@" ]; then
|
||||
echo "run_test needs a command to run"
|
||||
else
|
||||
tempLogfile=$(mktemp)
|
||||
cmd=$(eval echo "$@")
|
||||
echo "------------ INPUT -------------------" | tee -a $tempLogfile
|
||||
echo "$" "$cmd" | tee -a $tempLogfile
|
||||
echo "------------ OUTPUT ------------------" | tee -a $tempLogfile
|
||||
eval $cmd 2>&1 | tee -a $tempLogfile
|
||||
if [ $logall = "yes" ]; then
|
||||
cat $tempLogfile >> $logfile
|
||||
echo -e "\\n\\n" >> $logfile
|
||||
else
|
||||
read -N 1 -p "Did the test pass? [y/n]: " pass
|
||||
if [ $pass = 'n' ]; then
|
||||
cat $tempLogfile >> $logfile
|
||||
echo -e "\\n\\n" >> $logfile
|
||||
fi
|
||||
fi
|
||||
rm $tempLogfile
|
||||
fi
|
||||
}
|
Reference in New Issue
Block a user