2>_stderr

This commit is contained in:
pvincent
2026-08-04 09:56:42 +04:00
parent 6998964f30
commit 9f4d99d42d
4 changed files with 51 additions and 10 deletions
+21
View File
@@ -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))
-1
View File
@@ -1,5 +1,4 @@
#!/usr/bin/env miaou-bash
#!/usr/bin/env bash
function onemore {
echo onemore loaded
+3 -1
View File
@@ -71,7 +71,7 @@ function do_false {
function do_success {
echo "count args: $#"
[[ true==true ]] && echo true
[[ true != 'false' ]] && echo true
! false && echo unfalse
return
}
@@ -89,6 +89,8 @@ function do_success_with_args {
function do_unbound_variable {
a=5
echo -n "content: "
# >&2 echo err1
# echo "content: "
echo -n "a=${a} b=${b}"
}