100% passed
This commit is contained in:
+23
-11
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user