Skip to content

Commit 1edbaac

Browse files
vascoolgitster
authored andcommitted
tests: use test_i18n* functions to suppress false positives
The test functions test_i18ncmp and test_i18ngrep pretend success if run under GETTEXT_POISON. By using those functions to test output which is correctly marked as translatable, enables one to detect if the strings newly marked for translation are from plumbing output. If they are indeed from plumbing, the test would fail, and the string should be unmarked, since it is not seen by users. Thus, it is productive to not have false positives when running the test under GETTEXT_POISON. This commit replaces normal test functions by their i18n aware variants in use-cases know to be correctly marked for translation, suppressing false positives. Signed-off-by: Vasco Almeida <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ab33a76 commit 1edbaac

21 files changed

+41
-44
lines changed

t/t0008-ignores.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ expect_from_stdin () {
3434
test_stderr () {
3535
expected="$1"
3636
expect_in stderr "$1" &&
37-
test_cmp "$HOME/expected-stderr" "$HOME/stderr"
37+
test_i18ncmp "$HOME/expected-stderr" "$HOME/stderr"
3838
}
3939

4040
broken_c_unquote () {
@@ -47,7 +47,7 @@ broken_c_unquote_verbose () {
4747

4848
stderr_contains () {
4949
regexp="$1"
50-
if grep "$regexp" "$HOME/stderr"
50+
if test_i18ngrep "$regexp" "$HOME/stderr"
5151
then
5252
return 0
5353
else

t/t1300-repo-config.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ test_expect_success !MINGW 'get --path copes with unset $HOME' '
886886
git config --get --path path.normal >>result &&
887887
git config --get --path path.trailingtilde >>result
888888
) &&
889-
grep "[Ff]ailed to expand.*~/" msg &&
889+
test_i18ngrep "[Ff]ailed to expand.*~/" msg &&
890890
test_cmp expect result
891891
'
892892

@@ -1126,7 +1126,7 @@ test_expect_success 'barf on syntax error' '
11261126
key garbage
11271127
EOF
11281128
test_must_fail git config --get section.key >actual 2>error &&
1129-
grep " line 3 " error
1129+
test_i18ngrep " line 3 " error
11301130
'
11311131

11321132
test_expect_success 'barf on incomplete section header' '
@@ -1136,7 +1136,7 @@ test_expect_success 'barf on incomplete section header' '
11361136
key = value
11371137
EOF
11381138
test_must_fail git config --get section.key >actual 2>error &&
1139-
grep " line 2 " error
1139+
test_i18ngrep " line 2 " error
11401140
'
11411141

11421142
test_expect_success 'barf on incomplete string' '
@@ -1146,7 +1146,7 @@ test_expect_success 'barf on incomplete string' '
11461146
key = "value string
11471147
EOF
11481148
test_must_fail git config --get section.key >actual 2>error &&
1149-
grep " line 3 " error
1149+
test_i18ngrep " line 3 " error
11501150
'
11511151

11521152
test_expect_success 'urlmatch' '

t/t1307-config-blob.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,7 @@ test_expect_success 'parse errors in blobs are properly attributed' '
6161
git commit -m broken &&
6262
6363
test_must_fail git config --blob=HEAD:config some.value 2>err &&
64-
65-
# just grep for our token as the exact error message is likely to
66-
# change or be internationalized
67-
grep "HEAD:config" err
64+
test_i18ngrep "HEAD:config" err
6865
'
6966

7067
test_expect_success 'can parse blob ending with CR' '

t/t1308-config-set.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,14 +197,14 @@ test_expect_success 'proper error on error in default config files' '
197197
echo "[" >>.git/config &&
198198
echo "fatal: bad config line 34 in file .git/config" >expect &&
199199
test_expect_code 128 test-config get_value foo.bar 2>actual &&
200-
test_cmp expect actual
200+
test_i18ncmp expect actual
201201
'
202202

203203
test_expect_success 'proper error on error in custom config files' '
204204
echo "[" >>syntax-error &&
205205
echo "fatal: bad config line 1 in file syntax-error" >expect &&
206206
test_expect_code 128 test-config configset_get_value foo.bar syntax-error 2>actual &&
207-
test_cmp expect actual
207+
test_i18ncmp expect actual
208208
'
209209

210210
test_expect_success 'check line errors for malformed values' '

t/t1400-update-ref.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ test_expect_success 'stdin test setup' '
361361

362362
test_expect_success '-z fails without --stdin' '
363363
test_must_fail git update-ref -z $m $m $m 2>err &&
364-
grep "usage: git update-ref" err
364+
test_i18ngrep "usage: git update-ref" err
365365
'
366366

367367
test_expect_success 'stdin works with no input' '

t/t2010-checkout-ambiguous.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ test_expect_success 'disambiguate checking out from a tree-ish' '
4949

5050
test_expect_success 'accurate error message with more than one ref' '
5151
test_must_fail git checkout HEAD master -- 2>actual &&
52-
grep 2 actual &&
52+
test_i18ngrep 2 actual &&
5353
test_i18ngrep "one reference expected, 2 given" actual
5454
'
5555

t/t2018-checkout-branch.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ test_expect_success 'checkout -b to @{-1} fails with the right branch name' '
124124
git checkout branch2 &&
125125
echo >expect "fatal: A branch named '\''branch1'\'' already exists." &&
126126
test_must_fail git checkout -b @{-1} 2>actual &&
127-
test_cmp expect actual
127+
test_i18ncmp expect actual
128128
'
129129

130130
test_expect_success 'checkout -B to an existing branch resets branch to HEAD' '

t/t3200-branch.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ If you wanted to make '"'master'"' track '"'origin/master'"', do this:
550550
git branch -d origin/master
551551
git branch --set-upstream-to origin/master
552552
EOF
553-
test_cmp expected actual
553+
test_i18ncmp expected actual
554554
'
555555

556556
test_expect_success '--set-upstream with two args only shows the deprecation message' '
@@ -559,7 +559,7 @@ test_expect_success '--set-upstream with two args only shows the deprecation mes
559559
cat >expected <<EOF &&
560560
The --set-upstream flag is deprecated and will be removed. Consider using --track or --set-upstream-to
561561
EOF
562-
test_cmp expected actual
562+
test_i18ncmp expected actual
563563
'
564564

565565
test_expect_success '--set-upstream with one arg only shows the deprecation message if the branch existed' '
@@ -568,7 +568,7 @@ test_expect_success '--set-upstream with one arg only shows the deprecation mess
568568
cat >expected <<EOF &&
569569
The --set-upstream flag is deprecated and will be removed. Consider using --track or --set-upstream-to
570570
EOF
571-
test_cmp expected actual
571+
test_i18ncmp expected actual
572572
'
573573

574574
test_expect_success '--set-upstream-to notices an error to set branch as own upstream' '

t/t3201-branch-contains.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ test_expect_success 'branch --merged with --verbose' '
156156
* topic 2c939f4 [ahead 1] foo
157157
zzz c77a0a9 second on master
158158
EOF
159-
test_cmp expect actual
159+
test_i18ncmp expect actual
160160
'
161161

162162
test_done

t/t3320-notes-merge-worktrees.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ test_expect_success 'merge z into y while mid-merge in another workdir fails' '
5252
cd worktree &&
5353
git config core.notesRef refs/notes/y &&
5454
test_must_fail git notes merge z 2>err &&
55-
grep "A notes merge into refs/notes/y is already in-progress at" err
55+
test_i18ngrep "A notes merge into refs/notes/y is already in-progress at" err
5656
) &&
5757
test_path_is_missing .git/worktrees/worktree/NOTES_MERGE_REF
5858
'

0 commit comments

Comments
 (0)