Skip to content

Commit 127df8c

Browse files
committed
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 <[email protected]>
1 parent c36f941 commit 127df8c

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

t/t0001-init.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ test_expect_success 'GIT_DIR & GIT_WORK_TREE (2)' '
180180
fi
181181
'
182182

183-
test_expect_success C_LOCALE_OUTPUT 'reinit' '
183+
test_expect_success 'reinit' '
184184
185185
(
186186
sane_unset GIT_CONFIG GIT_WORK_TREE GIT_CONFIG &&
@@ -190,11 +190,11 @@ test_expect_success C_LOCALE_OUTPUT 'reinit' '
190190
git init >out1 2>err1 &&
191191
git init >out2 2>err2
192192
) &&
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 &&
195195
>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
198198
'
199199

200200
test_expect_success 'init with --template' '

t/test-lib.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,24 @@ test_i18ncmp () {
10851085
test -n "$GETTEXT_POISON" || test_cmp "$@"
10861086
}
10871087

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+
10881106
# test whether the filesystem supports symbolic links
10891107
ln -s x y 2>/dev/null && test -h y 2>/dev/null && test_set_prereq SYMLINKS
10901108
rm -f y

0 commit comments

Comments
 (0)