Browse Source

before fix empty failure_type on scenario return

main
pvincent 2 days ago
parent
commit
9817730d7f
  1. 16
      bin/miaou-bash
  2. 2
      test/miaou-bash.test.bash

16
bin/miaou-bash

@ -48,18 +48,16 @@ function on_return {
function on_exit {
code=${1:-0}
if [[ $code -gt 0 ]]; then
stack_lines=("${BASH_LINENO[@]}")
stack_functions=("${FUNCNAME[@]}")
stack_sources=("${BASH_SOURCE[@]}")
# >/dev/tty echo "stack_functionsA ${#stack_functions[@]} ${stack_functions[@]}"
unset 'stack_lines[-1]'
unset 'stack_lines[-1]'
unset 'stack_functions[0]'
unset 'stack_functions[-1]'
# >/dev/tty echo "stack_functionsB ${#stack_functions[@]} ${stack_functions[@]}"
[[ "${#stack_functions[@]}" -gt 0 ]] && stack_functions[-1]='<main>'
unset 'stack_sources[0]'
@ -76,11 +74,8 @@ function on_exit {
stack_functions=("${stack_functions[@]}")
stack_sources=("${stack_sources[@]}")
failure_traces=()
failure_payload=''
if [[ $code -gt 0 ]]; then
last_error=$(tail -n1 "$MIAOU_BASH_ERROR")
last_source=${stack_sources[0]}
last_source=${last_source//./"\."} # replace '.' with '\.'
@ -165,7 +160,7 @@ function on_exit {
fi
fi
else
# failure_type='UNDEFINED'
failure_type='UNDEFINED'
miaou_debug "last error=${last_error}"
failure_payload="${last_error}"
regex="^ .*:[0-9]* .*\$"
@ -185,10 +180,6 @@ function on_exit {
fi
fi
for i in "${!stack_functions[@]}"; do
stack_detail=$(printf "\t%40s\t%s\n" "${stack_sources[$i]}:${stack_lines[$i]}" "${stack_functions[$i]}")
failure_traces+=("$stack_detail")
done
dump_failure
else
dump_success
@ -267,9 +258,6 @@ function dump_failure {
miaou_debug '---stacktrace---'
>&4 ansi_traces stack_sources stack_lines stack_functions
# for i in "${failure_traces[@]}"; do
# >&4 echo -e "$i"
# done
miaou_debug '---end of stacktrace---'
cleanup
}

2
test/miaou-bash.test.bash

@ -55,7 +55,7 @@ fail_type return RETURN
failed=$((TEST_COUNT - SUCCESS_COUNT))
if [[ $failed -gt 0 ]]; then
ratio=$((100 * SUCCESS_COUNT / TEST_COUNT))
echo "${ratio}% passed, $failed test have failed!"
echo "${ratio}% passed, $SUCCESS_COUNT succeeded, $failed failed!"
exit 1
else
echo 100% passed!

Loading…
Cancel
Save