[PATCH/RFC v4 6/7] gettext: Sanity tests for Git's Gettext support
These tests check if Git's C, Shell and Perl wrappers for Gettext are
working.
---
t/t0200-gettext.sh | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 73 insertions(+), 0 deletions(-)
create mode 100755 t/t0200-gettext.sh
diff --git a/t/t0200-gettext.sh b/t/t0200-gettext.sh
new file mode 100755
index 0000000..ff2f9f9
--- /dev/null
+++ b/t/t0200-gettext.sh
@@ -0,0 +1,73 @@
+#!/bin/sh
+D=`pwd`
+export GIT_TEXTDOMAINDIR=$D/../share/locale
+
+test_description='Gettext support for Git'
+. ./test-lib.sh
+. ../../git-sh-setup
+
+test_expect_success 'sanity: $TEXTDOMAIN is git' '
+ test $TEXTDOMAIN = "git"
+'
+
+test_expect_success 'sanity: $TEXTDOMAINDIR exists' '
+ test -d $TEXTDOMAINDIR &&
+ test $TEXTDOMAINDIR = $GIT_TEXTDOMAINDIR
+'
+
+test_expect_success 'sanity: Icelandic locale was compiled' '
+ test -f $TEXTDOMAINDIR/is/LC_MESSAGES/git.mo
+'
+
+test_expect_success 'sanity: gettext("") metadata is OK' '
+ LC_ALL=is_IS.UTF-8 gettext "" > expect &&
+ grep "Project-Id-Version: Git" expect &&
+ grep "Git Mailing List <git@vger.kernel.org>" expect &&
+ grep "Content-Type: text/plain; charset=UTF-8" expect &&
+ grep "Content-Transfer-Encoding: 8bit" expect
+'
+
+test_expect_success 'sanity: gettext(unknown) is passed through' '
+ printf "This is not a translation string" > expect
+ gettext "This is not a translation string" > actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'sanity: C program git-status reads our message catalog ' '
+ > foo &&
+ test_commit foo "a message"
+ git checkout -b topic/gettext-testing &&
+ git status | grep topic/gettext-testing > expect
+ echo "# On branch topic/gettext-testing" > actual
+ test_cmp expect actual &&
+ LC_ALL=is_IS.UTF-8 git status | grep topic/gettext-testing > expect
+ echo "# Ã greininni topic/gettext-testing" > actual
+ test_cmp expect actual
+'
+
+test_expect_success 'sanity: Perl program Git::I18N reads our message catalog ' '
+ echo "On branch " > expect &&
+ perl -I"$D/../perl" -MGit::I18N -le "print gettext(q[On branch ])" > actual &&
+ test_cmp expect actual &&
+
+ echo "Ã greininni " > expect &&
+ LC_ALL=is_IS.UTF-8 perl -I"$D/../perl" -MGit::I18N -le "print gettext(q[On branch ])" > actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'Setup another Git repository for testing' '
+ mkdir parent &&
+ (cd parent && git init &&
+ echo one >file && git add file &&
+ git commit -m one)
+'
+
+test_expect_success 'sanity: Shell program git-pull reads our message catalog' '
+ cd parent &&
+ (git pull --tags "../" >out 2>err || :) &&
+ grep "Fetching tags only" err &&
+ (LC_ALL=is_IS.UTF-8 git pull --tags "../" >out 2>err || :) &&
+ grep "Næ aðeins Ã" err
+'
+
+test_done
--
1.7.1.251.gec7f5.dirty