| From 3d48021fb0892721fab8359b49470e521aaed493 Mon Sep 17 00:00:00 2001 |
| From: Alex Kiernan <alex.kiernan@gmail.com> |
| Date: Thu, 31 Oct 2019 11:28:07 +0000 |
| Subject: [PATCH 2/3] tests/core: Assume C.UTF-8 if locale isn't found |
| |
| When building with musl there's no locale command, also its default |
| locale is C.UTF-8, so just get C.UTF-8 if we can't find locale. |
| |
| Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com> |
| Upstream-Status: Accepted [v2019.6] |
| --- |
| tests/libtest-core.sh | 12 +++++++++--- |
| 1 file changed, 9 insertions(+), 3 deletions(-) |
| |
| diff --git a/tests/libtest-core.sh b/tests/libtest-core.sh |
| index bc191332c916..46aafab03cc8 100644 |
| --- a/tests/libtest-core.sh |
| +++ b/tests/libtest-core.sh |
| @@ -37,9 +37,15 @@ assert_not_reached () { |
| # Some tests look for specific English strings. Use a UTF-8 version |
| # of the C (POSIX) locale if we have one, or fall back to en_US.UTF-8 |
| # (https://sourceware.org/glibc/wiki/Proposals/C.UTF-8) |
| -export LC_ALL=$(locale -a | grep -Ee '\.(UTF-8|utf8)' | grep -iEe '^(C|en_US)' | head -1 || true) |
| -if [ -z "${LC_ALL}" ]; then fatal "Can't find suitable UTF-8 locale"; fi |
| - |
| +# |
| +# If we can't find the locale command assume we have support for C.UTF-8 |
| +# (e.g. musl based systems) |
| +if type -p locale >/dev/null; then |
| + export LC_ALL=$(locale -a | grep -Ee '\.(UTF-8|utf8)' | grep -iEe '^(C|en_US)' | head -1 || true) |
| + if [ -z "${LC_ALL}" ]; then fatal "Can't find suitable UTF-8 locale"; fi |
| +else |
| + export LC_ALL=C.UTF-8 |
| +fi |
| # A GNU extension, used whenever LC_ALL is not C |
| unset LANGUAGE |
| |
| -- |
| 2.17.1 |
| |