100% passed + optional bypassed
This commit is contained in:
+45
-28
@@ -61,18 +61,29 @@ function assert_grep {
|
|||||||
|
|
||||||
function fail_type {
|
function fail_type {
|
||||||
((test_count++))
|
((test_count++))
|
||||||
local success regex hint_message cmd
|
local success regex hint_message cmd lang_options
|
||||||
success=false
|
success=false
|
||||||
hint_message="${3:-}"
|
hint_message="${3:-}"
|
||||||
|
lang_options=()
|
||||||
[[ -v TEST_LANG ]] && cmd="LANG=$TEST_LANG " || cmd=''
|
|
||||||
cmd="$MIAOU_BASH_DIR/test/stub/scenario.bash $1"
|
cmd="$MIAOU_BASH_DIR/test/stub/scenario.bash $1"
|
||||||
|
|
||||||
if [[ -v TEST_LANG ]]; then
|
if [[ -v TEST_LANG ]]; then
|
||||||
LANG="$TEST_LANG" $cmd >/dev/null 2>"$TMP_ERR" 3>"$TMP_MIAOU"
|
local locale_found=false
|
||||||
else
|
for gen_locale in "${GEN_LOCALES[@]}"; do
|
||||||
$cmd >/dev/null 2>"$TMP_ERR" 3>"$TMP_MIAOU"
|
if [[ "$gen_locale" == "$TEST_LANG" ]]; then
|
||||||
|
locale_found=true
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if ! $locale_found; then
|
||||||
|
((test_bypassed++))
|
||||||
|
BYPASSED_LOCALES["$TEST_LANG"]=true
|
||||||
|
echo -n b
|
||||||
|
return
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
eval "${lang_options[*]} $cmd" >/dev/null 2>"$TMP_ERR" 3>"$TMP_MIAOU"
|
||||||
mapfile -t stderr <"$TMP_ERR"
|
mapfile -t stderr <"$TMP_ERR"
|
||||||
|
|
||||||
last_error="${stderr[-1]}"
|
last_error="${stderr[-1]}"
|
||||||
@@ -88,11 +99,7 @@ function fail_type {
|
|||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
echo -n F
|
echo -n F
|
||||||
if [[ -v TEST_LANG ]]; then
|
failures+=("${lang_options[*]} $cmd")
|
||||||
failures+=("LANG=$TEST_LANG $cmd")
|
|
||||||
else
|
|
||||||
failures+=("$cmd")
|
|
||||||
fi
|
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,7 +201,12 @@ set -uo pipefail
|
|||||||
[[ ! -v MIAOU_BASH_DIR ]] && >&2 echo MIAOU_BASH_DIR missing && builtin exit 1
|
[[ ! -v MIAOU_BASH_DIR ]] && >&2 echo MIAOU_BASH_DIR missing && builtin exit 1
|
||||||
|
|
||||||
test_count=0
|
test_count=0
|
||||||
|
test_bypassed=0
|
||||||
failures=()
|
failures=()
|
||||||
|
declare -A BYPASSED_LOCALES=()
|
||||||
|
|
||||||
|
mapfile -t GEN_LOCALES < <(locale -a)
|
||||||
|
|
||||||
mkdir -p "$TMP_DIRECTORY"
|
mkdir -p "$TMP_DIRECTORY"
|
||||||
TIMEFORMAT=$'\nelapsed: %Rs'
|
TIMEFORMAT=$'\nelapsed: %Rs'
|
||||||
|
|
||||||
@@ -208,25 +220,25 @@ time {
|
|||||||
assert pipe1
|
assert pipe1
|
||||||
assert pipe2
|
assert pipe2
|
||||||
|
|
||||||
TEST_LANG=en_US.UTF-8 fail_type unbound_variable UNBOUND_VARIABLE
|
TEST_LANG=en_US.utf8 fail_type unbound_variable UNBOUND_VARIABLE
|
||||||
TEST_LANG=es_ES.UTF-8 fail_type unbound_variable UNBOUND_VARIABLE
|
TEST_LANG=es_ES.utf8 fail_type unbound_variable UNBOUND_VARIABLE
|
||||||
TEST_LANG=fr_FR.UTF-8 fail_type unbound_variable UNBOUND_VARIABLE
|
TEST_LANG=fr_FR.utf8 fail_type unbound_variable UNBOUND_VARIABLE
|
||||||
|
|
||||||
TEST_LANG=en_US.UTF-8 fail_type unbound_associative UNBOUND_VARIABLE
|
TEST_LANG=en_US.utf8 fail_type unbound_associative UNBOUND_VARIABLE
|
||||||
TEST_LANG=es_ES.UTF-8 fail_type unbound_associative UNBOUND_VARIABLE
|
TEST_LANG=es_ES.utf8 fail_type unbound_associative UNBOUND_VARIABLE
|
||||||
TEST_LANG=fr_FR.UTF-8 fail_type unbound_associative UNBOUND_VARIABLE
|
TEST_LANG=fr_FR.utf8 fail_type unbound_associative UNBOUND_VARIABLE
|
||||||
|
|
||||||
TEST_LANG=en_US.UTF-8 fail_type command_not_found COMMAND_NOT_FOUND
|
TEST_LANG=en_US.utf8 fail_type command_not_found COMMAND_NOT_FOUND
|
||||||
TEST_LANG=es_ES.UTF-8 fail_type command_not_found COMMAND_NOT_FOUND
|
TEST_LANG=es_ES.utf8 fail_type command_not_found COMMAND_NOT_FOUND
|
||||||
TEST_LANG=fr_FR.UTF-8 fail_type command_not_found COMMAND_NOT_FOUND
|
TEST_LANG=fr_FR.utf8 fail_type command_not_found COMMAND_NOT_FOUND
|
||||||
|
|
||||||
TEST_LANG=en_US.UTF-8 fail_type source_not_found SOURCE_NOT_FOUND
|
TEST_LANG=en_US.utf8 fail_type source_not_found SOURCE_NOT_FOUND
|
||||||
TEST_LANG=es_ES.UTF-8 fail_type source_not_found SOURCE_NOT_FOUND
|
TEST_LANG=es_ES.utf8 fail_type source_not_found SOURCE_NOT_FOUND
|
||||||
TEST_LANG=fr_FR.UTF-8 fail_type source_not_found SOURCE_NOT_FOUND
|
TEST_LANG=fr_FR.utf8 fail_type source_not_found SOURCE_NOT_FOUND
|
||||||
|
|
||||||
TEST_LANG=en_US.UTF-8 fail_type file_not_found FILE_NOT_FOUND
|
TEST_LANG=en_US.utf8 fail_type file_not_found FILE_NOT_FOUND
|
||||||
TEST_LANG=es_ES.UTF-8 fail_type file_not_found FILE_NOT_FOUND
|
TEST_LANG=es_ES.utf8 fail_type file_not_found FILE_NOT_FOUND
|
||||||
TEST_LANG=fr_FR.UTF-8 fail_type file_not_found FILE_NOT_FOUND
|
TEST_LANG=fr_FR.utf8 fail_type file_not_found FILE_NOT_FOUND
|
||||||
|
|
||||||
fail_type command_error COMMAND_ERROR
|
fail_type command_error COMMAND_ERROR
|
||||||
fail_type subshell_term SUBSHELL_ERROR
|
fail_type subshell_term SUBSHELL_ERROR
|
||||||
@@ -251,14 +263,19 @@ time {
|
|||||||
failed=${#failures[@]}
|
failed=${#failures[@]}
|
||||||
success=$((test_count - failed))
|
success=$((test_count - failed))
|
||||||
|
|
||||||
|
optional_bypassed=()
|
||||||
|
if [[ ${#BYPASSED_LOCALES[@]} -gt 0 ]]; then
|
||||||
|
optional_bypassed=(", $test_bypassed bypassed (missing locales: ${!BYPASSED_LOCALES[*]})")
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ $failed -gt 0 ]]; then
|
if [[ $failed -gt 0 ]]; then
|
||||||
ratio=$((100 * success / test_count))
|
ratio=$((100 * success / test_count))
|
||||||
echo "${ratio}% passed, ${test_count} tests, ${failed} failed!"
|
echo "${ratio}% passed, ${test_count} tests, ${failed} failed!${optional_bypassed[*]}"
|
||||||
echo failures:
|
echo failures:
|
||||||
for failure in "${failures[@]}"; do
|
for failure in "${failures[@]}"; do
|
||||||
echo -e "\t- $failure"
|
echo -e "\t- $failure"
|
||||||
done
|
done
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
echo "100% passed, ${test_count} tests"
|
echo "100% passed, ${test_count} tests${optional_bypassed[*]}"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user