@matheusbsbs / matheus-bagliano / commits / 127df8c6cf
Fork 0

i18n: do not overuse C_LOCALE_OUTPUT (grep)

Instead of skipping the whole test, introduce test_i18ngrep wrapper that pretends a successful result under GETTEXT_POISON build. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Apr 12, 2011 at 15:57 UTC 127df8c6cfd42ea666df9221d208b33b712d9994
2 files changed +23 -5
t/t0001-init.sh
+5 -5
@@ -180,7 +180,7 @@ test_expect_success 'GIT_DIR & GIT_WORK_TREE (2)' '
180 fi
181 '
182
183 -test_expect_success C_LOCALE_OUTPUT 'reinit' '
183 +test_expect_success 'reinit' '
184
185 (
186 sane_unset GIT_CONFIG GIT_WORK_TREE GIT_CONFIG &&
@@ -190,11 +190,11 @@ test_expect_success C_LOCALE_OUTPUT 'reinit' '
190 git init >out1 2>err1 &&
191 git init >out2 2>err2
192 ) &&
193 - grep "Initialized empty" again/out1 &&
194 - grep "Reinitialized existing" again/out2 &&
193 + test_i18ngrep "Initialized empty" again/out1 &&
194 + test_i18ngrep "Reinitialized existing" again/out2 &&
195 >again/empty &&
196 - test_cmp again/empty again/err1 &&
197 - test_cmp again/empty again/err2
196 + test_i18ncmp again/empty again/err1 &&
197 + test_i18ncmp again/empty again/err2
198 '
199
200 test_expect_success 'init with --template' '
t/test-lib.sh
+18
@@ -1085,6 +1085,24 @@ test_i18ncmp () {
1085 test -n "$GETTEXT_POISON" || test_cmp "$@"
1086 }
1087
1088 +# Use this instead of "grep expected-string actual" to see if the
1089 +# output from a git command that can be translated either contains an
1090 +# expected string, or does not contain an unwanted one. When running
1091 +# under GETTEXT_POISON this pretends that the command produced expected
1092 +# results.
1093 +test_i18ngrep () {
1094 + if test -n "$GETTEXT_POISON"
1095 + then
1096 + : # pretend success
1097 + elif test "x!" = "x$1"
1098 + then
1099 + shift
1100 + ! grep "$@"
1101 + else
1102 + grep "$@"
1103 + fi
1104 +}
1105 +
1106 # test whether the filesystem supports symbolic links
1107 ln -s x y 2>/dev/null && test -h y 2>/dev/null && test_set_prereq SYMLINKS
1108 rm -f y