urchin/urchin
Thomas Levine 1bd7b4adf6 changes
2012-10-10 15:47:21 -04:00

59 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
recurse() {
potential_test="$1"
[ "$potential_test" = 'setup_dir' ] && return
[ "$potential_test" = 'teardown_dir' ] && return
[ "$potential_test" = 'setup' ] && return
[ "$potential_test" = 'teardown' ] && return
if [ -d "$potential_test" ]
then
(
cd "$potential_test"
[ -f setup_dir ] && [ -x setup_dir ] && . ./setup_dir
for test in *
do recurse "${test}"
done
[ -f teardown_dir ] && [ -x teardown_dir ] && ./teardown_dir
)
elif [ -x "$potential_test" ]
then
#stdout_file=$(mktemp)
stdout_file=/tmp/urchin_stdout
[ -f setup ] && [ -x setup ] && . ./setup &>> $stdout_file
# Run the test
./"$potential_test" &>> $stdout_file
exit_code="$?"
[ -f teardown ] && [ -x teardown ] && ./teardown &>> $stdout_file
if [ "$exit_code" = '0' ]
then
# On success, print a '✓'
echo -ne '\033[32m✓ \033[0m'
echo "${potential_test}"
else
# On fail, print a red '✗'
echo -ne '\033[31m✗ \033[0m'
echo "${potential_test}"
# cat $stdout_file
fi
rm $stdout_file
fi
}
if [ "$#" = '0' ]
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