Browse Source

command error

main
pvincent 11 hours ago
parent
commit
98deda9e6c
  1. 7
      bin/miaou-bash
  2. 1
      test/miaou-bash.test.bash
  3. 5
      test/stub/extra/library.bash
  4. 5
      test/stub/scenario.bash

7
bin/miaou-bash

@ -162,7 +162,6 @@ function on_exit {
fi fi
else else
failure_payload="${last_error}" failure_payload="${last_error}"
miaou_debug "UNDEFINED last error=${last_error}"
regex="╟─⟶" regex="╟─⟶"
if [[ "$last_error" =~ $regex ]]; then if [[ "$last_error" =~ $regex ]]; then
last_trim=false # keep the last error for next stacktrace last_trim=false # keep the last error for next stacktrace
@ -174,11 +173,7 @@ function on_exit {
stack_functions[0]="${stack_functions[0]} (hint: prefer source than subshell)" stack_functions[0]="${stack_functions[0]} (hint: prefer source than subshell)"
[[ "${code}" == 128 ]] && failure_type='SUBSHELL_SOURCE_NOT_FOUND' [[ "${code}" == 128 ]] && failure_type='SUBSHELL_SOURCE_NOT_FOUND'
else else
failure_type='UNDEFINED'
regex='^subshell term:'
if [[ "$last_error" =~ $regex ]]; then
failure_type='SUBSHELL_TERM2'
fi
failure_type='COMMAND_ERROR'
fi fi
fi fi

1
test/miaou-bash.test.bash

@ -70,6 +70,7 @@ fail_type exit EXIT
fail_type source_not_found SOURCE_NOT_FOUND fail_type source_not_found SOURCE_NOT_FOUND
fail_type file_not_found FILE_NOT_FOUND fail_type file_not_found FILE_NOT_FOUND
fail_type subshell_error COMMAND_NOT_FOUND '(hint: prefer source than subshell)' fail_type subshell_error COMMAND_NOT_FOUND '(hint: prefer source than subshell)'
fail_type command_error COMMAND_ERROR
failed=$((TEST_COUNT - SUCCESS_COUNT)) failed=$((TEST_COUNT - SUCCESS_COUNT))

5
test/stub/extra/library.bash

@ -11,11 +11,12 @@ function blabla {
function suite { function suite {
command_not_found command_not_found
echo $nope
grep nope nope
exit
exit 10 # youpi exit 10 # youpi
echo $nope
return 7 return 7
return return
exit
} }
blabla blabla

5
test/stub/scenario.bash

@ -94,6 +94,11 @@ function do_subshell_error {
"$BASEDIR/extra/library.bash" "$BASEDIR/extra/library.bash"
} }
function do_command_error {
>&2 echo nope is not defined!
grep nope nope
}
# FUNCTIONS # FUNCTIONS
function call_function_which_will_exit { function call_function_which_will_exit {

Loading…
Cancel
Save