4 Commits

Author SHA1 Message Date
Thomas Levine
1941bf716a not working 2016-01-25 14:41:21 +00:00
Thomas Levine
9f175f19b3 first pass implementation of exit on fail 2016-01-25 14:35:54 +00:00
Thomas Levine
9043430750 document unimplemented -e flag 2016-01-25 14:20:40 +00:00
Thomas Levine
f2d63b2953 Test die on fail. 2016-01-25 14:14:13 +00:00
6 changed files with 30 additions and 1 deletions

View File

View File

@@ -0,0 +1 @@
false

View File

@@ -0,0 +1 @@
false

View File

@@ -0,0 +1 @@
false

11
tests/Die on fail. Executable file
View File

@@ -0,0 +1,11 @@
tmp=$(mktemp)
../urchin -e -f ./.die-on-fail > $tmp
result=$?
grep '1 should run.' $tmp
grep '2 should run.' $tmp
grep -v '3 should not run.' $tmp
grep -v '4 should not run.' $tmp
rm $tmp
exit $result

17
urchin
View File

@@ -47,6 +47,13 @@ recurse() {
# $2 instead of $indent_level so it doesn't clash
recurse "${test}" $(( $2 + 1 )) "$shell_for_sh_tests"
exit_code=$?
if $exit_on_fail && test $exit_code -ne 0; then
[ -f teardown ] && [ -x teardown ] && ./teardown >> "$stdout_file"
[ -f teardown_dir ] && [ -x teardown_dir ] && ./teardown_dir >> "$stdout_file"
return 1
fi
[ -f teardown ] && [ -x teardown ] && ./teardown >> "$stdout_file"
done
@@ -67,7 +74,6 @@ recurse() {
fi
exit_code="$?"
[ -f teardown ] && [ -x teardown ] && ./teardown >> "$stdout_file"
indent $indent_level
@@ -86,6 +92,10 @@ recurse() {
cat "$stdout_file"
printf '\033[0m'
fi
if $exit_on_fail && test 0 -ne $exit_code; then
return 1
fi
fi
[ $indent_level -eq 0 ] && rm "$stdout_file"
}
@@ -105,6 +115,9 @@ $USAGE
-s <shell> Invoke test scripts that either have no shebang line at all or
have shebang line "#!/bin/sh" with the specified shell.
-e Stop running if any single test fails. This is helpful if you want
to use Urchin to run things other than tests, such as a set of
configuration scripts.
-f Force running even if the test directory's name does not
contain the word "test".
-h This help.
@@ -170,9 +183,11 @@ urchin_molly_guard() {
shell_for_sh_tests=
force=false
exit_on_fail=false
while [ $# -gt 0 ]
do
case "$1" in
-e) exit_on_fail=true;;
-f) force=true;;
-s)
shift