Code

gettext tests: add GETTEXT_POISON support for shell scripts
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Tue, 7 Sep 2010 15:25:05 +0000 (15:25 +0000)
committerÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Sat, 30 Oct 2010 07:58:15 +0000 (07:58 +0000)
Expand the existing GETTEXT_POISON=YesPlease support to support shell
scripts. Analogous the existing C support this is needed to test that
changes to the output of the shell scripts don't break the plumbing
output.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
git-sh-i18n.sh
t/t0201-gettext-fallbacks.sh
t/test-lib.sh

index 698a000fe5347c73cecd2de5d786dcaf1ef22cc5..b8b645a64e58ee9e11a850a383a9ace65cb4ca85 100644 (file)
@@ -28,44 +28,61 @@ else
 fi
 export TEXTDOMAINDIR
 
-if test -z "$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS" && type gettext.sh >/dev/null 2>&1
+if test -z "$GIT_INTERNAL_GETTEXT_GETTEXT_POISON"
 then
-       # This is GNU libintl's gettext.sh, we don't need to do anything
-       # else than setting up the environment and loading gettext.sh
-       GIT_INTERNAL_GETTEXT_SH_SCHEME=gnu
-       export GIT_INTERNAL_GETTEXT_SH_SCHEME
+       if test -z "$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS" && type gettext.sh >/dev/null 2>&1
+       then
+               # This is GNU libintl's gettext.sh, we don't need to do anything
+               # else than setting up the environment and loading gettext.sh
+               GIT_INTERNAL_GETTEXT_SH_SCHEME=gnu
+               export GIT_INTERNAL_GETTEXT_SH_SCHEME
 
-       # Try to use libintl's gettext.sh, or fall back to English if we
-       # can't.
-       . gettext.sh
-elif test -z "$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS" && test "$(gettext -h 2>&1)" = "-h"
-then
-       # We don't have gettext.sh, but there's a gettext binary in our
-       # path. This is probably Solaris or something like it which has a
-       # gettext implementation that isn't GNU libintl.
-       GIT_INTERNAL_GETTEXT_SH_SCHEME=solaris
-       export GIT_INTERNAL_GETTEXT_SH_SCHEME
+               # Try to use libintl's gettext.sh, or fall back to English if we
+               # can't.
+               . gettext.sh
+       elif test -z "$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS" && test "$(gettext -h 2>&1)" = "-h"
+       then
+               # We don't have gettext.sh, but there's a gettext binary in our
+               # path. This is probably Solaris or something like it which has a
+               # gettext implementation that isn't GNU libintl.
+               GIT_INTERNAL_GETTEXT_SH_SCHEME=solaris
+               export GIT_INTERNAL_GETTEXT_SH_SCHEME
 
-       # Solaris has a gettext(1) but no eval_gettext(1)
-       eval_gettext () {
-               gettext_out=$(gettext "$1")
-               gettext_eval="printf '%s' \"$gettext_out\""
-               printf "%s" "`eval \"$gettext_eval\"`"
-       }
+               # Solaris has a gettext(1) but no eval_gettext(1)
+               eval_gettext () {
+                       gettext_out=$(gettext "$1")
+                       gettext_eval="printf '%s' \"$gettext_out\""
+                       printf "%s" "`eval \"$gettext_eval\"`"
+               }
+       else
+               # Since gettext.sh isn't available we'll have to define our own
+               # dummy pass-through functions.
+
+               # Tell our tests that we don't have the real gettext.sh
+               GIT_INTERNAL_GETTEXT_SH_SCHEME=fallthrough
+               export GIT_INTERNAL_GETTEXT_SH_SCHEME
+
+               gettext () {
+                       printf "%s" "$1"
+               }
+
+               eval_gettext () {
+                       gettext_eval="printf '%s' \"$1\""
+                       printf "%s" "`eval \"$gettext_eval\"`"
+               }
+       fi
 else
-       # Since gettext.sh isn't available we'll have to define our own
-       # dummy pass-through functions.
+       # Emit garbage under GETTEXT_POISON=YesPlease. Unlike the C tests
+       # this relies on an environment variable
 
-       # Tell our tests that we don't have the real gettext.sh
-       GIT_INTERNAL_GETTEXT_SH_SCHEME=fallthrough
+       GIT_INTERNAL_GETTEXT_SH_SCHEME=poison
        export GIT_INTERNAL_GETTEXT_SH_SCHEME
 
        gettext () {
-               printf "%s" "$1"
+               printf "%s" "# GETTEXT POISON #"
        }
 
        eval_gettext () {
-               gettext_eval="printf '%s' \"$1\""
-               printf "%s" "`eval \"$gettext_eval\"`"
+               printf "%s" "# GETTEXT POISON #"
        }
 fi
index 47ce4f6b6e170d090052f5c6c857a2142f072cce..7a85d9b28ceaba1f86512c4286d34a3c4a1ee364 100755 (executable)
@@ -10,19 +10,19 @@ export GIT_INTERNAL_GETTEXT_TEST_FALLBACKS
 
 . ./lib-gettext.sh
 
-test_expect_success "sanity: \$GIT_INTERNAL_GETTEXT_SH_SCHEME is set (to $GIT_INTERNAL_GETTEXT_SH_SCHEME)" '
+test_expect_success NO_GETTEXT_POISON "sanity: \$GIT_INTERNAL_GETTEXT_SH_SCHEME is set (to $GIT_INTERNAL_GETTEXT_SH_SCHEME)" '
     test -n "$GIT_INTERNAL_GETTEXT_SH_SCHEME"
 '
 
-test_expect_success 'sanity: $GIT_INTERNAL_GETTEXT_TEST_FALLBACKS is set' '
+test_expect_success NO_GETTEXT_POISON 'sanity: $GIT_INTERNAL_GETTEXT_TEST_FALLBACKS is set' '
     test -n "$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS"
 '
 
-test_expect_success 'sanity: $GIT_INTERNAL_GETTEXT_SH_SCHEME" is fallthrough' '
+test_expect_success NO_GETTEXT_POISON 'sanity: $GIT_INTERNAL_GETTEXT_SH_SCHEME" is fallthrough' '
     test "$GIT_INTERNAL_GETTEXT_SH_SCHEME" = "fallthrough"
 '
 
-test_expect_success 'gettext: our gettext() fallback has pass-through semantics' '
+test_expect_success NO_GETTEXT_POISON 'gettext: our gettext() fallback has pass-through semantics' '
     printf "test" >expect &&
     gettext "test" >actual &&
     test_cmp expect actual &&
@@ -31,7 +31,7 @@ test_expect_success 'gettext: our gettext() fallback has pass-through semantics'
     test_cmp expect actual
 '
 
-test_expect_success 'eval_gettext: our eval_gettext() fallback has pass-through semantics' '
+test_expect_success NO_GETTEXT_POISON 'eval_gettext: our eval_gettext() fallback has pass-through semantics' '
     printf "test" >expect &&
     eval_gettext "test" >actual &&
     test_cmp expect actual &&
@@ -40,7 +40,7 @@ test_expect_success 'eval_gettext: our eval_gettext() fallback has pass-through
     test_cmp expect actual
 '
 
-test_expect_success 'eval_gettext: our eval_gettext() fallback can interpolate variables' '
+test_expect_success NO_GETTEXT_POISON 'eval_gettext: our eval_gettext() fallback can interpolate variables' '
     printf "test YesPlease" >expect &&
     eval_gettext "test \$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS" >actual &&
     test_cmp expect actual
index 29bdf882a309b6696ffecab6b3e68ecc9a7f070e..c243f0d18f334779a47093acabab793791f8403d 100644 (file)
@@ -984,7 +984,13 @@ esac
 test -z "$NO_PERL" && test_set_prereq PERL
 test -z "$NO_PYTHON" && test_set_prereq PYTHON
 test -z "$NO_GETTEXT" && test_set_prereq GETTEXT
-test -z "$GETTEXT_POISON" && test_set_prereq NO_GETTEXT_POISON
+if test -z "$GETTEXT_POISON"
+then
+       test_set_prereq NO_GETTEXT_POISON
+else
+       GIT_INTERNAL_GETTEXT_GETTEXT_POISON=YesPlease
+       export GIT_INTERNAL_GETTEXT_GETTEXT_POISON
+fi
 
 # test whether the filesystem supports symbolic links
 ln -s x y 2>/dev/null && test -h y 2>/dev/null && test_set_prereq SYMLINKS