Browse Source

not yet done with subshell error

main
pvincent 15 hours ago
parent
commit
cfab4506ab
  1. 10
      bin/miaou-bash
  2. 3
      test/miaou-bash.test.bash
  3. 12
      test/stub/scenario.bash

10
bin/miaou-bash

@ -161,10 +161,9 @@ function on_exit {
fi fi
fi fi
else else
failure_type='UNDEFINED'
miaou_debug "last error=${last_error}"
failure_payload="${last_error}" failure_payload="${last_error}"
regex="^ .*:[0-9]* .*\$"
miaou_debug "UNDEFINED last error=${last_error}"
regex="╟─⟶"
if [[ "$last_error" =~ $regex ]]; then if [[ "$last_error" =~ $regex ]]; then
if [[ "${code}" == 128 ]]; then if [[ "${code}" == 128 ]]; then
failure_type='SUBSHELL_SOURCE_NOT_FOUND' failure_type='SUBSHELL_SOURCE_NOT_FOUND'
@ -174,6 +173,7 @@ function on_exit {
stack_functions[0]="${stack_functions[0]} (hint: prefer source than subshell:3)" stack_functions[0]="${stack_functions[0]} (hint: prefer source than subshell:3)"
fi fi
else else
failure_type='UNDEFINED'
regex='^subshell term:' regex='^subshell term:'
if [[ "$last_error" =~ $regex ]]; then if [[ "$last_error" =~ $regex ]]; then
failure_type='SUBSHELL_TERM2' failure_type='SUBSHELL_TERM2'
@ -229,7 +229,7 @@ function ansi_traces {
declare -n functions=$3 declare -n functions=$3
optional=false optional=false
for i in "${!sources[@]}"; do for i in "${!sources[@]}"; do
FG=RED style_ansi " ╟─⟶"
FG=RED style_ansi " ╟─⟶ "
location=$(printf "%40s" "${sources[$i]}:${lines[$i]}") location=$(printf "%40s" "${sources[$i]}:${lines[$i]}")
is_true "$optional" && is_true "$optional" &&
location=$(FG=GRAY STYLE=ITALIC style_ansi "$location") || location=$(FG=GRAY STYLE=ITALIC style_ansi "$location") ||
@ -297,7 +297,7 @@ BASH_ARGV0="$1" && shift # to pretend script runs by itself
# magic FD + delayed tee => /dev/fd/3 means delayed stderr, /dev/fd/4 remains original stderr # magic FD + delayed tee => /dev/fd/3 means delayed stderr, /dev/fd/4 remains original stderr
exec 3> >(tee "$MIAOU_BASH_ERROR" >/dev/null) 4>/dev/stderr exec 3> >(tee "$MIAOU_BASH_ERROR" >/dev/null) 4>/dev/stderr
miaou_debug '---stdout---'
miaou_debug "---stdout--$$ $BASHPID $PPID--"
# shellcheck source=/dev/null # shellcheck source=/dev/null
source "$BASH_ARGV0" 2>&3 source "$BASH_ARGV0" 2>&3
dump_success dump_success

3
test/miaou-bash.test.bash

@ -55,8 +55,11 @@ fail_type command_not_found COMMAND_NOT_FOUND
fail_type exit EXIT 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_source_not_found SUBSHELL_SOURCE_NOT_FOUND
fail_type subshell_error SUBSHELL_ERROR
failed=$((TEST_COUNT - SUCCESS_COUNT)) failed=$((TEST_COUNT - SUCCESS_COUNT))
if [[ $failed -gt 0 ]]; then if [[ $failed -gt 0 ]]; then
ratio=$((100 * SUCCESS_COUNT / TEST_COUNT)) ratio=$((100 * SUCCESS_COUNT / TEST_COUNT))
echo "${ratio}% passed, $SUCCESS_COUNT succeeded, $failed failed!" echo "${ratio}% passed, $SUCCESS_COUNT succeeded, $failed failed!"

12
test/stub/scenario.bash

@ -86,6 +86,18 @@ function do_source_not_found {
function do_file_not_found { function do_file_not_found {
./lib/fake/nope.bash ./lib/fake/nope.bash
} }
function do_subshell_source_not_found {
output=$(miaou_debug "---subshell1--$$ $BASHPID $PPID--")
output=$(miaou_debug "---subshell2--$$ $BASHPID $PPID--")
: "$output"
"${MIAOU_BASH_DIR}/test/stub/extra/library.bash"
}
function do_subshell_error {
:
}
# FUNCTIONS # FUNCTIONS
function call_function_which_will_exit { function call_function_which_will_exit {

Loading…
Cancel
Save