59 lines
1.3 KiB
Bash
Executable File
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 [ "$#" = '1' ] && [ -d "$1" ]
|
|
then
|
|
echo Running tests
|
|
recurse "$1"
|
|
echo
|
|
echo Done
|
|
else
|
|
echo "usage: $0 <test directory>"
|
|
echo 'Go to http://www.urchin.sh for documentation on writing tests.'
|
|
fi
|