Files
exercises-in-programming-style/test/test.sh
Chad Whitacre b89f438108 Don't care where test.sh is run from
We were trying to run ./test/test.sh and it didn't work because test.sh
assumed we were in ./test/. This change moves into ./test/ for us.
2013-09-25 19:54:42 -04:00

41 lines
856 B
Bash
Executable File

#!/bin/bash
function msg() {
echo $(date +%T) "$@"
}
# Move to a predictable place.
cd $(dirname $0)
failures=0
total=0
mydir=$(pwd)
files=$(echo *.txt)
for dir in ../[0-9][0-9]-* ; do
cd $dir
for file in $files ; do
for exe in * ; do
if [ -x $exe ]; then
msg testing $(basename $dir)/$exe with $file
./$exe ../$file | diff -b - $mydir/$file
result=$?
total=$((total+1))
if [ $result -ne 0 ]; then
failures=$(($failures+1))
msg FAILED!
else
msg passed.
fi
fi
done
done
cd $mydir
done
msg $(date +%T) Ran $total tests with $failures failures.
if [ $failures -ne 0 ]; then
msg FAILED!
exit $failures
fi
msg PASSED