[PATCH 2/4] test-lib.sh: add test_utf8() function
- From
- Yann Droneaud <yann@droneaud.fr>
- Date
- Jan 6, 2011, 14:22 UTC
- Message-ID
- <8559d90bff6fca1c18f1cbf3530f2f4cc695f9f4.1294312018.git.yann@droneaud.fr>
- In-Reply-To
- <cover.1294312018.git.yann@droneaud.fr>
test_utf8() checks for en_US.UTF-8 locale availability using lib-locale.pl. The function returns 1 if a locale was not found, otherwise it returns 0, set prereq UTF8 and export GIT_LC_UTF8 with the locale name.
If a test needs to use an en_US.UTF-8 locale, it has to call test_utf8() first. Then it can do tests based on prereq UTF8 availability and use LC_ALL=$GIT_LC_UTF8.
Signed-off-by: Yann Droneaud <yann@droneaud.fr> --- t/test-lib.sh | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/t/test-lib.sh b/t/test-lib.sh index cb1ca97..3e92360 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -1066,6 +1066,20 @@ case $(uname -s) in ;; esac +# check UTF-8 locale availability +test_utf8 () { + if test_have_prereq PERL ; then + # output an en_US.UTF-8 locale compatible name + GIT_LC_UTF8=`$PERL_PATH $GIT_BUILD_DIR/t/lib-locale.pl` + fi + if test -z "$GIT_LC_UTF8" ; then + return 1 + else + test_set_prereq UTF8 + return 0 + fi +} + test -z "$NO_PERL" && test_set_prereq PERL test -z "$NO_PYTHON" && test_set_prereq PYTHON
-- 1.7.3.4