From 1d607663051534855c0a648702d153db01e2ff34 Mon Sep 17 00:00:00 2001 From: pvincent Date: Sat, 25 Jul 2026 14:22:53 +0400 Subject: [PATCH] 100% passed --- test/miaou-bash.test.bash | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/test/miaou-bash.test.bash b/test/miaou-bash.test.bash index f9711f2..57ce1de 100755 --- a/test/miaou-bash.test.bash +++ b/test/miaou-bash.test.bash @@ -25,24 +25,36 @@ function fail_type { local i line first error_start_above regex hint_message hint_message="${3:-}" mapfile -t stderr <<<"$(./test/stub/scenario.bash "$1" 2>&1 >/dev/null)" - echo "stderr countains ${#stderr[@]}" + # echo "stderr countains ${#stderr[@]}" error_start_above=false + success=false regex="║[[:blank:]]+([A-Z|_]+)" - for i in "${stderr[@]}"; do - line=$(strip_ansi "$i") + for i in "${!stderr[@]}"; do + line=$(strip_ansi "${stderr[$i]}") first="${line:1:1}" [[ $first == ╔ ]] && error_start_above=true && continue if [[ "$error_start_above" == true ]]; then - if [[ $line =~ $regex ]] && [[ ${BASH_REMATCH[1]} == "$2" ]]; then - ((SUCCESS_COUNT++)) - return 0 - else - break - fi + [[ $line =~ $regex ]] && [[ ${BASH_REMATCH[1]} == "$2" ]] && success=true + break fi done - [[ -n "${hint_message}" ]] && echo "hint message to find out..." - echo "error in: $1" && return 1 + + if [[ $success == true && -n "${hint_message}" ]]; then + success=false + regex="╟─⟶.*(\(.*\))$" + for j in $(seq "$((i + 1))" "$((${#stderr[@]} - 1))"); do + line=$(strip_ansi "${stderr[$j]}") + if [[ $line =~ $regex ]]; then + [[ "${BASH_REMATCH[1]}" == "${hint_message}" ]] && success=true + break + fi + done + fi + if [[ $success == true ]]; then + ((SUCCESS_COUNT++)) + else + echo "error in: $1" && return 1 + fi } # main