git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH/RFC v4 6/7] gettext: Sanity tests for Git's Gettext support

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Jun 2, 2010, 01:06 UTC
Message-ID
<1275440764-26153-7-git-send-email-avarab@gmail.com>
In-Reply-To
<AANLkTimhxqGRPjYz-k5f-LTIk6KajEwUuGJWt-dAKZQT@mail.gmail.com>
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
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 40 of 56 in “Add internationalization support to Git”
  1. 0/5 Add internationalization support to GitÆvar Arnfjörð Bjarmason, May 29, 2010
  2. 1/5 Add infrastructure for translating Git with gettextÆvar Arnfjörð Bjarmason, May 29, 2010
  3. 2/5 gitignore: Ignore files generated by gettextÆvar Arnfjörð Bjarmason, May 29, 2010
  4. 3/5 Makefile: Remove Gettext files on make cleanÆvar Arnfjörð Bjarmason, May 29, 2010
  5. 4/5 gettext: Add a skeleton po/is.poÆvar Arnfjörð Bjarmason, May 29, 2010
  6. 5/5 Add infrastructure to make shellscripts translatableÆvar Arnfjörð Bjarmason, May 29, 2010
  7. Jonathan NiederMay 30, 2010
  8. Ævar Arnfjörð BjarmasonMay 30, 2010
  9. Jonathan NiederMay 30, 2010
  10. Ævar Arnfjörð BjarmasonMay 31, 2010
  11. 0/6 Add internationalization support to GitÆvar Arnfjörð Bjarmason, May 30, 2010
  12. 1/6 Add infrastructure for translating Git with gettextÆvar Arnfjörð Bjarmason, May 30, 2010
  13. Jakub NarebskiJun 1, 2010
  14. autoconf: Check if <libintl.h> exists and set NO_GETTEXTÆvar Arnfjörð Bjarmason, Jun 1, 2010
  15. Jakub NarebskiJun 1, 2010
  16. 2/6 gitignore: Ignore files generated by gettextÆvar Arnfjörð Bjarmason, May 30, 2010
  17. 3/6 Makefile: Remove Gettext files on make cleanÆvar Arnfjörð Bjarmason, May 30, 2010
  18. 4/6 gettext: Add a Gettext interface for shell scriptsÆvar Arnfjörð Bjarmason, May 30, 2010
  19. 5/6 gettext: Add a Gettext interface for PerlÆvar Arnfjörð Bjarmason, May 30, 2010
  20. Jakub NarebskiJun 1, 2010
  21. Ævar Arnfjörð BjarmasonJun 1, 2010
  22. Jakub NarebskiJun 2, 2010
  23. 6/6 gettext: Add a skeleton po/is.poÆvar Arnfjörð Bjarmason, May 30, 2010
  24. Jonathan NiederMay 30, 2010
  25. Jonathan NiederMay 30, 2010
  26. Ævar Arnfjörð BjarmasonMay 31, 2010
  27. 0/7 Add internationalization support to GitÆvar Arnfjörð Bjarmason, Jun 1, 2010
  28. Ævar Arnfjörð BjarmasonJun 2, 2010
  29. 0/7 Add internationalization support to GitÆvar Arnfjörð Bjarmason, Jun 2, 2010
  30. 1/7 Add infrastructure for translating Git with gettextÆvar Arnfjörð Bjarmason, Jun 2, 2010
  31. Peter KreftingJun 2, 2010
  32. Ævar Arnfjörð BjarmasonJun 2, 2010
  33. Peter KreftingJun 2, 2010
  34. Ævar Arnfjörð BjarmasonJun 2, 2010
  35. Peter KreftingJun 2, 2010
  36. 2/7 gettext: Add a Gettext interface for shell scriptsÆvar Arnfjörð Bjarmason, Jun 2, 2010
  37. 3/7 gettext: Add a Gettext interface for PerlÆvar Arnfjörð Bjarmason, Jun 2, 2010
  38. 4/7 Makefile: Don't install Gettext .mo files if NO_GETTEXTÆvar Arnfjörð Bjarmason, Jun 2, 2010
  39. 5/7 Makefile: Override --keyword= for all languagesÆvar Arnfjörð Bjarmason, Jun 2, 2010
  40. 6/7 gettext: Sanity tests for Git's Gettext supportÆvar Arnfjörð Bjarmason, Jun 2, 2010
  41. 7/7 gettext: Add a skeleton po/is.poÆvar Arnfjörð Bjarmason, Jun 2, 2010
  42. Johannes SixtJun 2, 2010
  43. 0/2 Add infrastructure for translating Git with gettextÆvar Arnfjörð Bjarmason, Jun 2, 2010
  44. 1/2 Add infrastructure for translating Git with gettextÆvar Arnfjörð Bjarmason, Jun 2, 2010
  45. 2/2 Add initial C, Shell and Perl gettext translationsÆvar Arnfjörð Bjarmason, Jun 2, 2010
  46. 1/7 Add infrastructure for translating Git with gettextÆvar Arnfjörð Bjarmason, Jun 1, 2010
  47. 2/7 gettext: Add a Gettext interface for shell scriptsÆvar Arnfjörð Bjarmason, Jun 1, 2010
  48. Johannes SixtJun 2, 2010
  49. Ævar Arnfjörð BjarmasonJun 2, 2010
  50. Johannes SixtJun 2, 2010
  51. 3/7 gettext: Add a Gettext interface for PerlÆvar Arnfjörð Bjarmason, Jun 1, 2010
  52. 4/7 Makefile: Don't install Gettext .mo files if NO_GETTEXTÆvar Arnfjörð Bjarmason, Jun 1, 2010
  53. 5/7 Makefile: Override --keyword= for all languagesÆvar Arnfjörð Bjarmason, Jun 1, 2010
  54. 6/7 gettext: Basic sanity tests for Git's Gettext supportÆvar Arnfjörð Bjarmason, Jun 1, 2010
  55. Johannes SixtJun 2, 2010
  56. 7/7 gettext: Add a skeleton po/is.poÆvar Arnfjörð Bjarmason, Jun 1, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.