|
|
@ -25,24 +25,36 @@ function fail_type { |
|
|
local i line first error_start_above regex hint_message |
|
|
local i line first error_start_above regex hint_message |
|
|
hint_message="${3:-}" |
|
|
hint_message="${3:-}" |
|
|
mapfile -t stderr <<<"$(./test/stub/scenario.bash "$1" 2>&1 >/dev/null)" |
|
|
mapfile -t stderr <<<"$(./test/stub/scenario.bash "$1" 2>&1 >/dev/null)" |
|
|
echo "stderr countains ${#stderr[@]}" |
|
|
|
|
|
|
|
|
# echo "stderr countains ${#stderr[@]}" |
|
|
error_start_above=false |
|
|
error_start_above=false |
|
|
|
|
|
success=false |
|
|
regex="║[[:blank:]]+([A-Z|_]+)" |
|
|
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="${line:1:1}" |
|
|
[[ $first == ╔ ]] && error_start_above=true && continue |
|
|
[[ $first == ╔ ]] && error_start_above=true && continue |
|
|
if [[ "$error_start_above" == true ]]; then |
|
|
if [[ "$error_start_above" == true ]]; then |
|
|
if [[ $line =~ $regex ]] && [[ ${BASH_REMATCH[1]} == "$2" ]]; then |
|
|
|
|
|
((SUCCESS_COUNT++)) |
|
|
|
|
|
return 0 |
|
|
|
|
|
else |
|
|
|
|
|
|
|
|
[[ $line =~ $regex ]] && [[ ${BASH_REMATCH[1]} == "$2" ]] && success=true |
|
|
break |
|
|
break |
|
|
fi |
|
|
fi |
|
|
|
|
|
done |
|
|
|
|
|
|
|
|
|
|
|
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 |
|
|
fi |
|
|
done |
|
|
done |
|
|
[[ -n "${hint_message}" ]] && echo "hint message to find out..." |
|
|
|
|
|
|
|
|
fi |
|
|
|
|
|
if [[ $success == true ]]; then |
|
|
|
|
|
((SUCCESS_COUNT++)) |
|
|
|
|
|
else |
|
|
echo "error in: $1" && return 1 |
|
|
echo "error in: $1" && return 1 |
|
|
|
|
|
fi |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
# main |
|
|
# main |
|
|
|