Skip to content

Instantly share code, notes, and snippets.

@mambocab
Created October 10, 2013 23:22
Show Gist options
  • Save mambocab/6927198 to your computer and use it in GitHub Desktop.
Save mambocab/6927198 to your computer and use it in GitHub Desktop.
bash test harness
#!/bin/bash
FILES=./test/*.in
failures=0
for f in $FILES
do
bn=`basename "$f" .in`
if cmp -s <(./ush <"$f") ./test/"$bn".out; then
echo "$bn":
echo -e -n "\033[1;36m"
echo -e '\t' success
else
let failures+=1
echo "$bn":
echo -e -n "\033[1;31m"
echo -e '\t' FAILURE
echo -e -n "\033[1;34m"
echo -e '\t' Input:
cat "$f"
echo -e -n "\033[1;33m"
diff -y <(./ush <"$f") ./test/"$bn".out
fi
echo -e -n '\033[0m'
echo
done
if [ $failures -ne 0 ] ; then
echo -e -n "\033[1;31m"
if [ $failures -eq 1 ]; then
echo -e $failures FAILURE
else
echo -e $failures FAILURES
fi
echo -e -n '\033[0m'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment