100% tests passed

This commit is contained in:
pvincent
2026-08-27 10:40:46 +04:00
parent 639b7d967e
commit 0cb5f5501d
5 changed files with 83 additions and 43 deletions
+36 -19
View File
@@ -61,13 +61,18 @@ function assert_grep {
function fail_type {
((test_count++))
local success regex hint_message
local success regex hint_message cmd
success=false
hint_message="${3:-}"
[[ -v TEST_LANG ]] && cmd="LANG=$TEST_LANG " || cmd=''
cmd="$MIAOU_BASH_DIR/test/stub/scenario.bash $1"
# mapfile -t stderr <<<"$(miaou-bash ./test/stub/scenario.bash "$1" 2>&1 >/dev/null 3>/dev/null)"
$cmd >/dev/null 2>"$TMP_ERR" 3>"$TMP_MIAOU"
if [[ -v TEST_LANG ]]; then
LANG="$TEST_LANG" $cmd >/dev/null 2>"$TMP_ERR" 3>"$TMP_MIAOU"
else
$cmd >/dev/null 2>"$TMP_ERR" 3>"$TMP_MIAOU"
fi
mapfile -t stderr <"$TMP_ERR"
last_error="${stderr[-1]}"
@@ -83,7 +88,11 @@ function fail_type {
return
fi
echo -n F
failures+=("$cmd")
if [[ -v TEST_LANG ]]; then
failures+=("LANG=$TEST_LANG $cmd")
else
failures+=("$cmd")
fi
return 1
}
@@ -199,17 +208,32 @@ time {
assert pipe1
assert pipe2
fail_type subshell_term SUBSHELL_ERROR
fail_type unbound_variable UNBOUND_VARIABLE
fail_type unbound_associative UNBOUND_VARIABLE
fail_type false FALSE
fail_type last_false COMMAND_ERROR
TEST_LANG=en_US.UTF-8 fail_type unbound_variable UNBOUND_VARIABLE
TEST_LANG=es_ES.UTF-8 fail_type unbound_variable UNBOUND_VARIABLE
TEST_LANG=fr_FR.UTF-8 fail_type unbound_variable UNBOUND_VARIABLE
TEST_LANG=en_US.UTF-8 fail_type unbound_associative UNBOUND_VARIABLE
TEST_LANG=es_ES.UTF-8 fail_type unbound_associative UNBOUND_VARIABLE
TEST_LANG=fr_FR.UTF-8 fail_type unbound_associative UNBOUND_VARIABLE
TEST_LANG=en_US.UTF-8 fail_type command_not_found COMMAND_NOT_FOUND
TEST_LANG=es_ES.UTF-8 fail_type command_not_found COMMAND_NOT_FOUND
TEST_LANG=fr_FR.UTF-8 fail_type command_not_found COMMAND_NOT_FOUND
TEST_LANG=en_US.UTF-8 fail_type source_not_found SOURCE_NOT_FOUND
TEST_LANG=es_ES.UTF-8 fail_type source_not_found SOURCE_NOT_FOUND
TEST_LANG=fr_FR.UTF-8 fail_type source_not_found SOURCE_NOT_FOUND
TEST_LANG=en_US.UTF-8 fail_type file_not_found FILE_NOT_FOUND
TEST_LANG=es_ES.UTF-8 fail_type file_not_found FILE_NOT_FOUND
TEST_LANG=fr_FR.UTF-8 fail_type file_not_found FILE_NOT_FOUND
fail_type command_error COMMAND_ERROR
fail_type subshell_term SUBSHELL_ERROR
fail_type false FALSE
fail_type last_false COMMAND_ERROR
fail_type subshell_term SUBSHELL_ERROR
fail_type exit EXIT
fail_type command_not_found COMMAND_NOT_FOUND
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
@@ -223,13 +247,6 @@ time {
fail_stderr_grep no_script 'ERROR: script expected!'
assert_locales_equally_populated en es fr
# TODO: I18n tests for:
# /opt/miaou-bash/test/stub/scenario.bash unbound_variable
# /opt/miaou-bash/test/stub/scenario.bash unbound_associative
# /opt/miaou-bash/test/stub/scenario.bash command_not_found
# /opt/miaou-bash/test/stub/scenario.bash source_not_found
# /opt/miaou-bash/test/stub/scenario.bash file_not_found
}
failed=${#failures[@]}
success=$((test_count - failed))