From 3224b7908325361843b14f509deb27e423fd7ec7 Mon Sep 17 00:00:00 2001 From: Lev Kujawski Date: Thu, 11 Feb 2021 17:00:49 -0700 Subject: [PATCH] Forestall spurious test failures by skipping unavailable locales src/cmd/ksh93/tests/bracket.sh: - Read the list of installed locales to ensure the locale to be tested actually exists on the system under test. - Produce a warning diagnostic for skipped locales. - Additionally test the en_US.ISO8859-1 and en_US.UTF-8 locales. Co-authored-by: Martijn Dekker --- src/cmd/ksh93/tests/bracket.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/cmd/ksh93/tests/bracket.sh b/src/cmd/ksh93/tests/bracket.sh index 324dc0879..884337800 100755 --- a/src/cmd/ksh93/tests/bracket.sh +++ b/src/cmd/ksh93/tests/bracket.sh @@ -264,8 +264,13 @@ test '(' = ')' && err_exit '"test ( = )" should not be true' [[ $($SHELL -c 'case F in ~(Eilr)[a-z0-9#]) print ok;;esac' 2> /dev/null) == ok ]] || err_exit '~(Eilr) not working in case command' [[ $($SHELL -c "case Q in ~(Fi)q | \$'\E') print ok;;esac" 2> /dev/null) == ok ]] || err_exit '~(Fi)q | \E not working in case command' -for l in C en_US.ISO8859-15 -do [[ $($SHELL -c "LC_COLLATE=$l" 2>&1) ]] && continue +locales=$'\n'$(command -p locale -a 2>/dev/null)$'\n' +for l in C en_US.ISO8859-1 en_US.ISO8859-15 en_US.UTF-8 +do if [[ ! $locales == *$'\n'"${l}"$'\n'* ]] || + [[ $("$SHELL" -c "LC_COLLATE=${l}" 2>&1) ]] + then print -u2 "\t${Command}[$LINENO]: warning: cannot test unavailable locale: ${l}" + continue + fi export LC_COLLATE=$l set -- \ 'A' 0 1 1 0 1 1 1 0 0 1 0 0 \