2022-01-21 15:38:47 +00:00
|
|
|
#!/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 "$@")
|
2022-01-24 16:16:59 +00:00
|
|
|
echo -e "\\n------------ INPUT -------------------" | tee -a $tempLogfile
|
2022-01-21 15:38:47 +00:00
|
|
|
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
|
|
|
|
}
|