tap indentation comments for directories

This commit is contained in:
Thomas Levine 2016-01-27 10:14:21 +00:00
parent 9d10e12633
commit 0f1c2848b4

113
urchin
View File

@ -30,15 +30,16 @@ recurse() {
if [ -d "$potential_test" ] if [ -d "$potential_test" ]
then then
(
if $tap_format; then
indent $indent_level | sed 's/ /#/g'
echo "# ${potential_test}"
else
indent $indent_level
echo " ${potential_test}"
fi
if $tap_format; then
indent $indent_level | sed 's/ /#/g'
echo "# Begin ${potential_test}"
else
indent $indent_level
echo " ${potential_test}"
fi
(
cd -- "$potential_test" cd -- "$potential_test"
[ -f setup_dir ] && [ -x setup_dir ] && ./setup_dir >> "$stdout_file" [ -f setup_dir ] && [ -x setup_dir ] && ./setup_dir >> "$stdout_file"
@ -57,50 +58,77 @@ recurse() {
[ -f teardown ] && [ -x teardown ] && ./teardown >> "$stdout_file" [ -f teardown ] && [ -x teardown ] && ./teardown >> "$stdout_file"
done done
[ -f teardown_dir ] && [ -x teardown_dir ] && ./teardown_dir >> "$stdout_file" [ -f teardown_dir ] && [ -x teardown_dir ] && ./teardown_dir >> "$stdout_file"
if ! $tap_format; then echo; fi
) )
elif [ -x "$potential_test" ] if $tap_format; then
then indent $indent_level | sed 's/ /#/g'
echo "# End ${potential_test}"
[ -f setup ] && [ -x setup ] && ./setup >> "$stdout_file"
# Run the test
if [ -n "$shell_for_sh_tests" ] && has_sh_or_no_shebang_line ./"$potential_test"
then
TEST_SHELL="$TEST_SHELL" "$shell_for_sh_tests" ./"$potential_test" > "$stdout_file" 2>&1
else else
TEST_SHELL="$TEST_SHELL" ./"$potential_test" > "$stdout_file" 2>&1 echo
fi fi
exit_code="$?" else
if [ -x "$potential_test" ]
then
[ -f setup ] && [ -x setup ] && ./setup >> "$stdout_file"
# Run the test
if [ -n "$shell_for_sh_tests" ] && has_sh_or_no_shebang_line ./"$potential_test"
then
TEST_SHELL="$TEST_SHELL" "$shell_for_sh_tests" ./"$potential_test" > "$stdout_file" 2>&1
else
TEST_SHELL="$TEST_SHELL" ./"$potential_test" > "$stdout_file" 2>&1
fi
exit_code="$?"
[ -f teardown ] && [ -x teardown ] && ./teardown >> "$stdout_file" [ -f teardown ] && [ -x teardown ] && ./teardown >> "$stdout_file"
if [ $exit_code -eq 0 ]; then
result=success
else
result=fail
fi
else
result=skip
fi
if $tap_format; then if $tap_format; then
if [ $exit_code -eq 0 ]; then n=$(grep -ce '^\(success\|fail\|skip\)' "$logfile")
result=ok
if [ "$result" == fail ]; then
not='not '
else else
result=not\ ok not=''
fi fi
n=$(grep -ce '^\(?:not \)\?ok' "$logfile") if [ "$result" == skip ]; then
echo "${result} $((n + 1)) - ${potential_test}" | tee --append "$logfile" skip='# SKIP '
else
skip=''
fi
echo "${not}ok $((n + 1)) - ${skip}${potential_test}"
echo "${result} ${potential_test}" >> "$logfile"
else else
indent $indent_level indent $indent_level
if [ $exit_code -eq 0 ] case "$result" in
then success)
# On success, print a green '✓' # On success, print a green '✓'
printf '\033[32m✓ \033[0m' printf '\033[32m✓ \033[0m'
printf '%s\n' "${potential_test}" printf '%s\n' "${potential_test}"
printf '%s\n' "${potential_test} passed" >> "$logfile" printf '%s\n' "${potential_test} passed" >> "$logfile"
else ;;
# On fail, print a red '✗' fail)
printf '\033[31m✗ \033[0m' # On fail, print a red '✗'
printf '%s\n' "${potential_test}" printf '\033[31m✗ \033[0m'
printf '%s\n' "${potential_test} failed" >> "$logfile" printf '%s\n' "${potential_test}"
printf '\033[31m' # Print output captured from failed test in red. printf '%s\n' "${potential_test} failed" >> "$logfile"
sed 's/^/# /' "$stdout_file" printf '\033[31m' # Print output captured from failed test in red.
printf '\033[0m' sed 's/^/# /' "$stdout_file"
fi printf '\033[0m'
;;
skip)
printf ' %s\n' "${potential_test}"
printf '%s\n' "${potential_test} skipped" >> "$logfile"
;;
esac
fi fi
fi fi
[ $indent_level -eq 0 ] && rm "$stdout_file" [ $indent_level -eq 0 ] && rm "$stdout_file"
@ -144,6 +172,9 @@ plural () {
} }
urchin_go() { urchin_go() {
if "$tap_format"; then
printf \#\
fi
echo Running tests at $(date +%Y-%m-%dT%H:%M:%S) | tee "$logfile" echo Running tests at $(date +%Y-%m-%dT%H:%M:%S) | tee "$logfile"
start=$(date +%s) start=$(date +%s)