urchin/urchin

50 lines
1.1 KiB
Plaintext
Raw Normal View History

#!/bin/bash
2012-10-04 07:24:03 -04:00
2012-10-04 07:29:34 -04:00
recurse() {
potential_test="$1"
if [ -d "$potential_test" ]
then
(
cd "$potential_test"
2012-10-10 14:25:44 -04:00
[ -f setup_dir ] && . ./setup_dir
2012-10-08 10:16:49 -04:00
for test in *
2012-10-08 08:50:48 -04:00
do recurse "${test}"
done
2012-10-10 14:25:44 -04:00
[ -f teardown_dir ] && [ -x teardown_dir ] && ./teardown_dir
2012-10-04 07:29:34 -04:00
)
2012-10-08 08:59:14 -04:00
elif [ -x "$potential_test" ]
2012-10-04 07:29:34 -04:00
then
#stdout_file=$(mktemp)
stdout_file=/tmp/urchin_stdout
2012-10-10 14:25:44 -04:00
# Run the test
[ -f setup ] && . ./setup
./"$potential_test" > $stdout_file
2012-10-10 14:25:44 -04:00
[ -f teardown ] && [ -x teardown ] && ./teardown
2012-10-08 08:59:14 -04:00
if [ "$?" = '0' ]
2012-10-04 07:29:34 -04:00
then
2012-10-10 14:25:44 -04:00
# On success, print a '✓'
echo -ne '\033[32m✓ \033[0m'
echo "${potential_test}"
2012-10-04 07:29:34 -04:00
else
2012-10-10 14:25:44 -04:00
# On fail, print a red '✗'
echo -ne '\033[31m✗ \033[0m'
echo "${potential_test}"
cat $stdout_file
2012-10-04 07:29:34 -04:00
fi
rm $stdout_file
2012-10-04 07:29:34 -04:00
fi
}
2012-10-04 12:43:49 -04:00
2012-10-10 06:09:18 -04:00
if [ "$#" = '0' ]
2012-10-08 10:43:14 -04:00
then
echo Running tests
recurse .
echo
echo Done
else
echo 'Run `urchin` without arguments from a directory containing urchin tests.'
echo 'Go to http://www.urchin.sh for documentation on writing tests.'
fi