This commit is contained in:
Thomas Levine 2012-10-10 15:47:21 -04:00
parent 693e6cd438
commit 1bd7b4adf6
2 changed files with 10 additions and 7 deletions

View File

@ -30,6 +30,7 @@ and directories have special meanings.
tests/ tests/
setup setup
setup_dir
bar/ bar/
setup setup
test_that_something_works test_that_something_works
@ -46,11 +47,11 @@ and directories have special meanings.
teardown teardown
Directories are processed in a depth-first order. When a particular directory Directories are processed in a depth-first order. When a particular directory
is processed, `setup` is sourced before everything else in the directory, including is processed, `setup_dir` is run before everything else in the directory, including
subdirectories. Export variables from the setup function to make them available subdirectories. `teardown_dir` is run after everything else in the directory.
to other files in the same directory.
`teardown` is run after everything else in the directory. A directory's `setup` file, if it exists, is run right before each test file
within the particular directory, and the `teardown` file is run right after.
Files are only run if they are executable, and files beginning with `.` are Files are only run if they are executable, and files beginning with `.` are
ignored. Thus, fixtures and libraries can be included sloppily within the test ignored. Thus, fixtures and libraries can be included sloppily within the test

8
urchin
View File

@ -12,7 +12,7 @@ recurse() {
then then
( (
cd "$potential_test" cd "$potential_test"
[ -f setup_dir ] && . ./setup_dir [ -f setup_dir ] && [ -x setup_dir ] && . ./setup_dir
for test in * for test in *
do recurse "${test}" do recurse "${test}"
done done
@ -23,10 +23,12 @@ recurse() {
#stdout_file=$(mktemp) #stdout_file=$(mktemp)
stdout_file=/tmp/urchin_stdout stdout_file=/tmp/urchin_stdout
[ -f setup ] && [ -x setup ] && . ./setup &>> $stdout_file
# Run the test # Run the test
[ -f setup ] && . ./setup &>> $stdout_file
./"$potential_test" &>> $stdout_file ./"$potential_test" &>> $stdout_file
exit_code="$?" exit_code="$?"
[ -f teardown ] && [ -x teardown ] && ./teardown &>> $stdout_file [ -f teardown ] && [ -x teardown ] && ./teardown &>> $stdout_file
if [ "$exit_code" = '0' ] if [ "$exit_code" = '0' ]
@ -38,7 +40,7 @@ recurse() {
# On fail, print a red '✗' # On fail, print a red '✗'
echo -ne '\033[31m✗ \033[0m' echo -ne '\033[31m✗ \033[0m'
echo "${potential_test}" echo "${potential_test}"
cat $stdout_file # cat $stdout_file
fi fi
rm $stdout_file rm $stdout_file
fi fi