Browse Source

miaou-test eval cmd

main
pvincent 1 week ago
parent
commit
c598bf99c6
  1. 17
      test/miaou-bash.test.bash

17
test/miaou-bash.test.bash

@ -27,8 +27,7 @@ function assert_grep {
((test_count++))
local script="$1" content="$2" extra_args=()
[[ $# -gt 3 ]] && shift 3 && extra_args=("$@")
if miaou-bash ./test/stub/scenario.bash "$script" "${extra_args[@]}" >_stdout 2>/dev/null 3>/dev/null; then
if ./test/stub/scenario.bash "$script" "${extra_args[@]}" >_stdout 2>/dev/null 3>/dev/null; then
if grep -q "$content" _stdout; then
echo -n .
return
@ -44,9 +43,9 @@ function fail_type {
success=false
hint_message="${3:-}"
cmd="./test/stub/scenario.bash $1"
# mapfile -t stderr <<<"$(miaou-bash ./test/stub/scenario.bash "$1" 2>&1 >/dev/null 3>/dev/null)"
miaou-bash ./test/stub/scenario.bash $1 >/dev/null 2>_stderr 3>_miaou
eval "$cmd" >/dev/null 2>_stderr 3>_miaou
mapfile -t stderr <_stderr
last_error="${stderr[-1]}"
@ -59,11 +58,11 @@ function fail_type {
if [[ $success == true ]]; then
echo -n .
else
echo -n F
failures+=("$1")
return 1
return
fi
echo -n F
failures+=("$cmd")
return 1
}
# main
@ -101,7 +100,7 @@ if [[ $failed -gt 0 ]]; then
echo "${ratio}% passed, ${test_count} tests, ${failed} failed!"
echo failures:
for failure in "${failures[@]}"; do
echo -e "\t- $failure => replay: ./test/stub/scenario.bash $failure"
echo -e "\t- $failure"
done
exit 1
else

Loading…
Cancel
Save