diff --git a/readme.md b/readme.md index 0957969..f042fb3 100644 --- a/readme.md +++ b/readme.md @@ -30,6 +30,7 @@ and directories have special meanings. tests/ setup + setup_dir bar/ setup test_that_something_works @@ -46,11 +47,11 @@ and directories have special meanings. teardown Directories are processed in a depth-first order. When a particular directory -is processed, `setup` is sourced before everything else in the directory, including -subdirectories. Export variables from the setup function to make them available -to other files in the same directory. +is processed, `setup_dir` is run before everything else in the directory, including +subdirectories. `teardown_dir` is run after everything else in the 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 ignored. Thus, fixtures and libraries can be included sloppily within the test diff --git a/urchin b/urchin index 9e6371f..4448923 100755 --- a/urchin +++ b/urchin @@ -12,7 +12,7 @@ recurse() { then ( cd "$potential_test" - [ -f setup_dir ] && . ./setup_dir + [ -f setup_dir ] && [ -x setup_dir ] && . ./setup_dir for test in * do recurse "${test}" done @@ -23,10 +23,12 @@ recurse() { #stdout_file=$(mktemp) stdout_file=/tmp/urchin_stdout + [ -f setup ] && [ -x setup ] && . ./setup &>> $stdout_file + # Run the test - [ -f setup ] && . ./setup &>> $stdout_file ./"$potential_test" &>> $stdout_file exit_code="$?" + [ -f teardown ] && [ -x teardown ] && ./teardown &>> $stdout_file if [ "$exit_code" = '0' ] @@ -38,7 +40,7 @@ recurse() { # On fail, print a red '✗' echo -ne '\033[31m✗ \033[0m' echo "${potential_test}" - cat $stdout_file +# cat $stdout_file fi rm $stdout_file fi