Skip to content

Commit bdac578

Browse files
committed
Merge branch 'nd/i18n-poison-test-updates'
Update tests that can be broken with gettext-poison builds. * nd/i18n-poison-test-updates: Fix tests under GETTEXT_POISON on parseopt Fix tests under GETTEXT_POISON on git-remote Fix tests under GETTEXT_POISON on pack-object Fix tests under GETTEXT_POISON on git-apply Fix tests under GETTEXT_POISON on diffstat Fix tests under GETTEXT_POISON on git-stash Fix tests under GETTEXT_POISON on relative dates
2 parents 3fc0e4c + 9a00138 commit bdac578

23 files changed

+83
-53
lines changed

t/t0006-date.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ check_show() {
1111
echo "$t -> $2" >expect
1212
test_expect_${3:-success} "relative date ($2)" "
1313
test-date show $t >actual &&
14-
test_cmp expect actual
14+
test_i18ncmp expect actual
1515
"
1616
}
1717

t/t0040-parse-options.sh

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ EOF
5151
test_expect_success 'test help' '
5252
test_must_fail test-parse-options -h > output 2> output.err &&
5353
test ! -s output.err &&
54-
test_cmp expect output
54+
test_i18ncmp expect output
5555
'
5656

5757
mv expect expect.err
@@ -79,6 +79,17 @@ check() {
7979
test_cmp expect output
8080
}
8181

82+
check_i18n() {
83+
what="$1" &&
84+
shift &&
85+
expect="$1" &&
86+
shift &&
87+
sed "s/^$what .*/$what $expect/" <expect.template >expect &&
88+
test-parse-options $* >output 2>output.err &&
89+
test ! -s output.err &&
90+
test_i18ncmp expect output
91+
}
92+
8293
check_unknown() {
8394
case "$1" in
8495
--*)
@@ -92,6 +103,19 @@ check_unknown() {
92103
test_cmp expect output.err
93104
}
94105

106+
check_unknown_i18n() {
107+
case "$1" in
108+
--*)
109+
echo error: unknown option \`${1#--}\' >expect ;;
110+
-*)
111+
echo error: unknown switch \`${1#-}\' >expect ;;
112+
esac &&
113+
cat expect.err >>expect &&
114+
test_must_fail test-parse-options $* >output 2>output.err &&
115+
test ! -s output &&
116+
test_i18ncmp expect output.err
117+
}
118+
95119
test_expect_success 'OPT_BOOL() #1' 'check boolean: 1 --yes'
96120
test_expect_success 'OPT_BOOL() #2' 'check boolean: 1 --no-doubt'
97121
test_expect_success 'OPT_BOOL() #3' 'check boolean: 1 -D'
@@ -104,8 +128,8 @@ test_expect_success 'OPT_BOOL() is idempotent #2' 'check boolean: 1 -DB'
104128
test_expect_success 'OPT_BOOL() negation #1' 'check boolean: 0 -D --no-yes'
105129
test_expect_success 'OPT_BOOL() negation #2' 'check boolean: 0 -D --no-no-doubt'
106130

107-
test_expect_success 'OPT_BOOL() no negation #1' 'check_unknown --fear'
108-
test_expect_success 'OPT_BOOL() no negation #2' 'check_unknown --no-no-fear'
131+
test_expect_success 'OPT_BOOL() no negation #1' 'check_unknown_i18n --fear'
132+
test_expect_success 'OPT_BOOL() no negation #2' 'check_unknown_i18n --no-no-fear'
109133

110134
test_expect_success 'OPT_BOOL() positivation' 'check boolean: 0 -D --doubt'
111135

@@ -310,8 +334,8 @@ EOF
310334

311335
test_expect_success 'OPT_CALLBACK() and callback errors work' '
312336
test_must_fail test-parse-options --no-length > output 2> output.err &&
313-
test_cmp expect output &&
314-
test_cmp expect.err output.err
337+
test_i18ncmp expect output &&
338+
test_i18ncmp expect.err output.err
315339
'
316340

317341
cat > expect <<EOF

t/t1300-repo-config.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ test_expect_success 'get bool variable with empty value' \
391391

392392
test_expect_success 'no arguments, but no crash' '
393393
test_must_fail git config >output 2>&1 &&
394-
grep usage output
394+
test_i18ngrep usage output
395395
'
396396

397397
cat > .git/config << EOF

t/t1502-rev-parse-parseopt.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ EOF
4141

4242
test_expect_success 'test --parseopt help output' '
4343
test_expect_code 129 git rev-parse --parseopt -- -h > output < optionspec &&
44-
test_cmp expect output
44+
test_i18ncmp expect output
4545
'
4646

4747
cat > expect <<EOF

t/t2006-checkout-index-basic.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ test_description='basic checkout-index tests
77

88
test_expect_success 'checkout-index --gobbledegook' '
99
test_expect_code 129 git checkout-index --gobbledegook 2>err &&
10-
grep "[Uu]sage" err
10+
test_i18ngrep "[Uu]sage" err
1111
'
1212

1313
test_expect_success 'checkout-index -h in broken repository' '
@@ -18,7 +18,7 @@ test_expect_success 'checkout-index -h in broken repository' '
1818
>.git/index &&
1919
test_expect_code 129 git checkout-index -h >usage 2>&1
2020
) &&
21-
grep "[Uu]sage" broken/usage
21+
test_i18ngrep "[Uu]sage" broken/usage
2222
'
2323

2424
test_done

t/t2107-update-index-basic.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ test_expect_success 'update-index --nonsense fails' '
1515

1616
test_expect_success 'update-index --nonsense dumps usage' '
1717
test_expect_code 129 git update-index --nonsense 2>err &&
18-
grep "[Uu]sage: git update-index" err
18+
test_i18ngrep "[Uu]sage: git update-index" err
1919
'
2020

2121
test_expect_success 'update-index -h with corrupt index' '
@@ -26,7 +26,7 @@ test_expect_success 'update-index -h with corrupt index' '
2626
>.git/index &&
2727
test_expect_code 129 git update-index -h >usage 2>&1
2828
) &&
29-
grep "[Uu]sage: git update-index" broken/usage
29+
test_i18ngrep "[Uu]sage: git update-index" broken/usage
3030
'
3131

3232
test_expect_success '--cacheinfo does not accept blob null sha1' '

t/t3004-ls-files-basic.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ test_expect_success 'ls-files with nonexistent path' '
2222

2323
test_expect_success 'ls-files with nonsense option' '
2424
test_expect_code 129 git ls-files --nonsense 2>actual &&
25-
grep "[Uu]sage: git ls-files" actual
25+
test_i18ngrep "[Uu]sage: git ls-files" actual
2626
'
2727

2828
test_expect_success 'ls-files -h in corrupt repository' '
@@ -33,7 +33,7 @@ test_expect_success 'ls-files -h in corrupt repository' '
3333
>.git/index &&
3434
test_expect_code 129 git ls-files -h >usage 2>&1
3535
) &&
36-
grep "[Uu]sage: git ls-files " broken/usage
36+
test_i18ngrep "[Uu]sage: git ls-files " broken/usage
3737
'
3838

3939
test_done

t/t3200-branch.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ test_expect_success 'branch -h in broken repository' '
3131
>.git/refs/heads/master &&
3232
test_expect_code 129 git branch -h >usage 2>&1
3333
) &&
34-
grep "[Uu]sage" broken/usage
34+
test_i18ngrep "[Uu]sage" broken/usage
3535
'
3636

3737
test_expect_success \
@@ -74,7 +74,7 @@ test_expect_success \
7474
test_expect_success \
7575
'git branch -m dumps usage' \
7676
'test_expect_code 129 git branch -m 2>err &&
77-
grep "[Uu]sage: git branch" err'
77+
test_i18ngrep "[Uu]sage: git branch" err'
7878

7979
test_expect_success \
8080
'git branch -m m m/m should work' \

t/t3501-revert-cherry-pick.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ test_expect_success 'cherry-pick --nonsense' '
4747
git diff --exit-code HEAD &&
4848
test_must_fail git cherry-pick --nonsense 2>msg &&
4949
git diff --exit-code HEAD "$pos" &&
50-
grep '[Uu]sage:' msg
50+
test_i18ngrep '[Uu]sage:' msg
5151
'
5252

5353
test_expect_success 'revert --nonsense' '
@@ -56,7 +56,7 @@ test_expect_success 'revert --nonsense' '
5656
git diff --exit-code HEAD &&
5757
test_must_fail git revert --nonsense 2>msg &&
5858
git diff --exit-code HEAD "$pos" &&
59-
grep '[Uu]sage:' msg
59+
test_i18ngrep '[Uu]sage:' msg
6060
'
6161

6262
test_expect_success 'cherry-pick after renaming branch' '

t/t3903-stash.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ test_expect_success 'stash apply shows status same as git status (relative to cu
610610
git stash apply
611611
) |
612612
sed -e 1,2d >actual && # drop "Saved..." and "HEAD is now..."
613-
test_cmp expect actual
613+
test_i18ncmp expect actual
614614
'
615615

616616
cat > expect << EOF

0 commit comments

Comments
 (0)