Compare commits
7 Commits
master
...
exit-on-fa
Author | SHA1 | Date | |
---|---|---|---|
|
1941bf716a | ||
|
9f175f19b3 | ||
|
9043430750 | ||
|
f2d63b2953 | ||
|
d01e993041 | ||
|
b5c6464eab | ||
|
329fc27929 |
@ -6,7 +6,7 @@ for shell in dash bash ksh zsh; do
|
|||||||
if which $shell > /dev/null 2> /dev/null; then
|
if which $shell > /dev/null 2> /dev/null; then
|
||||||
echo
|
echo
|
||||||
echo Running urchin tests in $shell
|
echo Running urchin tests in $shell
|
||||||
$shell urchin tests | tail -n 3
|
$shell urchin -s $shell tests | tail -n 3
|
||||||
else
|
else
|
||||||
echo
|
echo
|
||||||
echo Skipping $shell because it is not in the PATH
|
echo Skipping $shell because it is not in the PATH
|
||||||
|
0
tests/.die-on-fail/1 should run.
Executable file
0
tests/.die-on-fail/1 should run.
Executable file
1
tests/.die-on-fail/2 should run.
Executable file
1
tests/.die-on-fail/2 should run.
Executable file
@ -0,0 +1 @@
|
|||||||
|
false
|
1
tests/.die-on-fail/3 should not run.
Executable file
1
tests/.die-on-fail/3 should not run.
Executable file
@ -0,0 +1 @@
|
|||||||
|
false
|
1
tests/.die-on-fail/4 should not run.
Executable file
1
tests/.die-on-fail/4 should not run.
Executable file
@ -0,0 +1 @@
|
|||||||
|
false
|
11
tests/Die on fail.
Executable file
11
tests/Die on fail.
Executable 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
|
@ -1,3 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
test c = $(../urchin -x .print-arg-3 a 'b b b b' c d e)
|
|
26
urchin
26
urchin
@ -47,6 +47,13 @@ recurse() {
|
|||||||
|
|
||||||
# $2 instead of $indent_level so it doesn't clash
|
# $2 instead of $indent_level so it doesn't clash
|
||||||
recurse "${test}" $(( $2 + 1 )) "$shell_for_sh_tests"
|
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"
|
[ -f teardown ] && [ -x teardown ] && ./teardown >> "$stdout_file"
|
||||||
done
|
done
|
||||||
@ -67,7 +74,6 @@ recurse() {
|
|||||||
fi
|
fi
|
||||||
exit_code="$?"
|
exit_code="$?"
|
||||||
|
|
||||||
|
|
||||||
[ -f teardown ] && [ -x teardown ] && ./teardown >> "$stdout_file"
|
[ -f teardown ] && [ -x teardown ] && ./teardown >> "$stdout_file"
|
||||||
|
|
||||||
indent $indent_level
|
indent $indent_level
|
||||||
@ -86,6 +92,10 @@ recurse() {
|
|||||||
cat "$stdout_file"
|
cat "$stdout_file"
|
||||||
printf '\033[0m'
|
printf '\033[0m'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if $exit_on_fail && test 0 -ne $exit_code; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
[ $indent_level -eq 0 ] && rm "$stdout_file"
|
[ $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
|
-s <shell> Invoke test scripts that either have no shebang line at all or
|
||||||
have shebang line "#!/bin/sh" with the specified shell.
|
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
|
-f Force running even if the test directory's name does not
|
||||||
contain the word "test".
|
contain the word "test".
|
||||||
-h This help.
|
-h This help.
|
||||||
@ -112,10 +125,6 @@ $USAGE
|
|||||||
Go to https://github.com/tlevine/urchin for documentation on writing tests.
|
Go to https://github.com/tlevine/urchin for documentation on writing tests.
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
# [Experimental -x option left undocumented for now.]
|
|
||||||
# -x [Experimental; not meant for direct invocation, but for use in
|
|
||||||
# the shebang line of test scripts]
|
|
||||||
# Run with "\$TEST_SHELL", falling back on /bin/sh.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
plural () {
|
plural () {
|
||||||
@ -174,20 +183,17 @@ urchin_molly_guard() {
|
|||||||
|
|
||||||
shell_for_sh_tests=
|
shell_for_sh_tests=
|
||||||
force=false
|
force=false
|
||||||
|
exit_on_fail=false
|
||||||
while [ $# -gt 0 ]
|
while [ $# -gt 0 ]
|
||||||
do
|
do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
-e) exit_on_fail=true;;
|
||||||
-f) force=true;;
|
-f) force=true;;
|
||||||
-s)
|
-s)
|
||||||
shift
|
shift
|
||||||
shell_for_sh_tests=$1
|
shell_for_sh_tests=$1
|
||||||
which "$shell_for_sh_tests" >/dev/null || { echo "Cannot find specified shell: '$shell_for_sh_tests'" >&2; urchin_help >&2; exit 2; }
|
which "$shell_for_sh_tests" >/dev/null || { echo "Cannot find specified shell: '$shell_for_sh_tests'" >&2; urchin_help >&2; exit 2; }
|
||||||
;;
|
;;
|
||||||
-x) # [EXPERIMENTAL; UNDOCUMENTED FOR NOW] `urchin -x <test-script>` in a test script's shebang line is equivalent to invoking that script with `"$TEST_SHELL" <test-script>`
|
|
||||||
shift
|
|
||||||
urchinsh=${TEST_SHELL:-/bin/sh}
|
|
||||||
"$urchinsh" "$@"
|
|
||||||
exit $?;;
|
|
||||||
-h|--help) urchin_help
|
-h|--help) urchin_help
|
||||||
exit 0;;
|
exit 0;;
|
||||||
-*) urchin_help >&2
|
-*) urchin_help >&2
|
||||||
|
Loading…
Reference in New Issue
Block a user