start writing non-tap cases
This commit is contained in:
parent
c817355e94
commit
92cb735bb7
51
urchin
51
urchin
@ -76,21 +76,25 @@ recurse() {
|
||||
|
||||
[ -f teardown ] && [ -x teardown ] && ./teardown >> "$stdout_file"
|
||||
|
||||
indent $indent_level
|
||||
if [ $exit_code -eq 0 ]
|
||||
then
|
||||
# On success, print a green '✓'
|
||||
printf '\033[32m✓ \033[0m'
|
||||
printf '%s\n' "${potential_test}"
|
||||
printf '%s\n' "${potential_test} passed" >> "$logfile"
|
||||
if $tap_format; then
|
||||
sleep 0s
|
||||
else
|
||||
# On fail, print a red '✗'
|
||||
printf '\033[31m✗ \033[0m'
|
||||
printf '%s\n' "${potential_test}"
|
||||
printf '%s\n' "${potential_test} failed" >> "$logfile"
|
||||
printf '\033[31m' # Print output captured from failed test in red.
|
||||
cat "$stdout_file"
|
||||
printf '\033[0m'
|
||||
indent $indent_level
|
||||
if [ $exit_code -eq 0 ]
|
||||
then
|
||||
# On success, print a green '✓'
|
||||
printf '\033[32m✓ \033[0m'
|
||||
printf '%s\n' "${potential_test}"
|
||||
printf '%s\n' "${potential_test} passed" >> "$logfile"
|
||||
else
|
||||
# On fail, print a red '✗'
|
||||
printf '\033[31m✗ \033[0m'
|
||||
printf '%s\n' "${potential_test}"
|
||||
printf '%s\n' "${potential_test} failed" >> "$logfile"
|
||||
printf '\033[31m' # Print output captured from failed test in red.
|
||||
cat "$stdout_file"
|
||||
printf '\033[0m'
|
||||
fi
|
||||
fi
|
||||
|
||||
if $exit_on_fail && test 0 -ne $exit_code; then
|
||||
@ -120,6 +124,7 @@ $USAGE
|
||||
configuration scripts.
|
||||
-f Force running even if the test directory's name does not
|
||||
contain the word "test".
|
||||
-t Format output in Test Anything Protocol (TAP)
|
||||
-h This help.
|
||||
|
||||
Go to https://github.com/tlevine/urchin for documentation on writing tests.
|
||||
@ -160,12 +165,16 @@ urchin_go() {
|
||||
|
||||
finish=$(date +%s)
|
||||
elapsed=$(($finish - $start))
|
||||
echo "Done, took $elapsed $(plural second $elapsed)."
|
||||
set -- $(grep -e 'passed$' "$logfile"|wc -l) $(grep -e 'failed$' "$logfile"|wc -l)
|
||||
printf '%s\n' "$1 $(plural test "$1") passed."
|
||||
[ $2 -gt 0 ] && printf '\033[31m' || printf '\033[32m' # If tests failed, print the message in red, otherwise in green.
|
||||
printf '%s\n' "$2 $(plural test "$2") failed."
|
||||
printf '\033[m'
|
||||
if $tap_format; then
|
||||
sleep 0s
|
||||
else
|
||||
echo "Done, took $elapsed $(plural second $elapsed)."
|
||||
set -- $(grep -e 'passed$' "$logfile"|wc -l) $(grep -e 'failed$' "$logfile"|wc -l)
|
||||
printf '%s\n' "$1 $(plural test "$1") passed."
|
||||
[ $2 -gt 0 ] && printf '\033[31m' || printf '\033[32m' # If tests failed, print the message in red, otherwise in green.
|
||||
printf '%s\n' "$2 $(plural test "$2") failed."
|
||||
printf '\033[m'
|
||||
fi
|
||||
return "$2"
|
||||
}
|
||||
|
||||
@ -184,6 +193,7 @@ urchin_molly_guard() {
|
||||
shell_for_sh_tests=
|
||||
force=false
|
||||
exit_on_fail=false
|
||||
tap_format=false
|
||||
while [ $# -gt 0 ]
|
||||
do
|
||||
case "$1" in
|
||||
@ -194,6 +204,7 @@ do
|
||||
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; }
|
||||
;;
|
||||
-t) tap_format=true;;
|
||||
-h|--help) urchin_help
|
||||
exit 0;;
|
||||
-*) urchin_help >&2
|
||||
|
Loading…
Reference in New Issue
Block a user