100% tests

This commit is contained in:
pvincent
2026-09-01 15:26:50 +04:00
parent 48e3e11695
commit 8e01117112
3 changed files with 23 additions and 14 deletions
+11 -2
View File
@@ -104,6 +104,7 @@ function fail_type {
for gen_locale in "${GEN_LOCALES[@]}"; do
if [[ "$gen_locale" == "$TEST_LANG" ]]; then
locale_found=true
lang_options+=("LANG=$TEST_LANG")
break
fi
done
@@ -136,18 +137,25 @@ function fail_type {
}
function fail_stderr_grep {
declare -a lang_options=()
if [[ -v TEST_LANG ]]; then
lang_options+=("LANG=$TEST_LANG")
fi
((test_count++))
cmd="$MIAOU_BASH_DIR/test/stub/scenario.bash $1"
stderr_line="$2"
if ! $cmd 2>"$TMP_ERR" && grep -q "$stderr_line" "$TMP_ERR"; then
if ! eval "${lang_options[*]} $cmd" 2>"$TMP_ERR" 3>/dev/null && grep -q "$stderr_line" "$TMP_ERR"; then
print_passed
return
fi
print_failed
failures+=("$cmd 2>&1 | grep -q \"$stderr_line\"")
# failures+=("$cmd 2>&1 | grep -q \"$stderr_line\"")
failures+=("${lang_options[*]} $cmd 2>&1 3>/dev/null | grep -q \"$stderr_line\"")
return 1
}
function fail_stderr_count {
@@ -289,6 +297,7 @@ time {
fail_stderr_grep two_options 'ERROR: too many args 2, either single option or SCRIPT + args accepted!'
fail_stderr_grep script_not_found "ERROR: script 'doesnt_exist' not found!"
fail_stderr_grep no_script 'ERROR: script expected!'
TEST_LANG=zh_CN.UTF-8 fail_stderr_grep file_not_found FILE_NOT_FOUND
assert_locales_equally_populated en es fr
}