2>_stderr
This commit is contained in:
@@ -41,6 +41,7 @@ function assert_grep {
|
||||
failures+=("$cmd $safe_args")
|
||||
return 1
|
||||
}
|
||||
|
||||
function fail_type {
|
||||
((test_count++))
|
||||
local success regex hint_message
|
||||
@@ -68,7 +69,24 @@ function fail_type {
|
||||
failures+=("$cmd")
|
||||
return 1
|
||||
}
|
||||
function fail_stderr_count {
|
||||
((test_count++))
|
||||
local regex count="$2"
|
||||
|
||||
cmd="./test/stub/scenario.bash $1"
|
||||
# mapfile -t stderr <<<"$(miaou-bash ./test/stub/scenario.bash "$1" 2>&1 >/dev/null 3>/dev/null)"
|
||||
if ! $cmd >/dev/null 2>_stderr 3>/dev/null; then
|
||||
mapfile -t stderr <_stderr
|
||||
if [[ "${#stderr[@]}" == "$count" ]]; then
|
||||
echo -n .
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
echo -n F
|
||||
failures+=("$cmd 2>_stderr")
|
||||
return 1
|
||||
}
|
||||
# main
|
||||
|
||||
set -uo pipefail
|
||||
@@ -95,6 +113,9 @@ time {
|
||||
fail_type source_not_found SOURCE_NOT_FOUND
|
||||
fail_type file_not_found FILE_NOT_FOUND
|
||||
fail_type child_error CHILD_ERROR 'prefer source than child process'
|
||||
|
||||
fail_stderr_count unbound_variable 1
|
||||
fail_stderr_count child_error 4
|
||||
}
|
||||
failed=${#failures[@]}
|
||||
success=$((test_count - failed))
|
||||
|
||||
Reference in New Issue
Block a user