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 <vascomalmeida@sapo.pt> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Vasco Almeida committed Jun 17, 2016 at 20:21 UTC 1edbaac3bbe1a55cf3450ae7a350b50826d5d283
21 files changed +41 -44
t/t0008-ignores.sh
+2 -2
@@ -34,7 +34,7 @@ expect_from_stdin () {
34 test_stderr () {
35 expected="$1"
36 expect_in stderr "$1" &&
37 - test_cmp "$HOME/expected-stderr" "$HOME/stderr"
37 + test_i18ncmp "$HOME/expected-stderr" "$HOME/stderr"
38 }
39
40 broken_c_unquote () {
@@ -47,7 +47,7 @@ broken_c_unquote_verbose () {
47
48 stderr_contains () {
49 regexp="$1"
50 - if grep "$regexp" "$HOME/stderr"
50 + if test_i18ngrep "$regexp" "$HOME/stderr"
51 then
52 return 0
53 else
t/t1300-repo-config.sh
+4 -4
@@ -886,7 +886,7 @@ test_expect_success !MINGW 'get --path copes with unset $HOME' '
886 git config --get --path path.normal >>result &&
887 git config --get --path path.trailingtilde >>result
888 ) &&
889 - grep "[Ff]ailed to expand.*~/" msg &&
889 + test_i18ngrep "[Ff]ailed to expand.*~/" msg &&
890 test_cmp expect result
891 '
892
@@ -1126,7 +1126,7 @@ test_expect_success 'barf on syntax error' '
1126 key garbage
1127 EOF
1128 test_must_fail git config --get section.key >actual 2>error &&
1129 - grep " line 3 " error
1129 + test_i18ngrep " line 3 " error
1130 '
1131
1132 test_expect_success 'barf on incomplete section header' '
@@ -1136,7 +1136,7 @@ test_expect_success 'barf on incomplete section header' '
1136 key = value
1137 EOF
1138 test_must_fail git config --get section.key >actual 2>error &&
1139 - grep " line 2 " error
1139 + test_i18ngrep " line 2 " error
1140 '
1141
1142 test_expect_success 'barf on incomplete string' '
@@ -1146,7 +1146,7 @@ test_expect_success 'barf on incomplete string' '
1146 key = "value string
1147 EOF
1148 test_must_fail git config --get section.key >actual 2>error &&
1149 - grep " line 3 " error
1149 + test_i18ngrep " line 3 " error
1150 '
1151
1152 test_expect_success 'urlmatch' '
t/t1307-config-blob.sh
+1 -4
@@ -61,10 +61,7 @@ test_expect_success 'parse errors in blobs are properly attributed' '
61 git commit -m broken &&
62
63 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
65 '
66
67 test_expect_success 'can parse blob ending with CR' '
t/t1308-config-set.sh
+2 -2
@@ -197,14 +197,14 @@ test_expect_success 'proper error on error in default config files' '
197 echo "[" >>.git/config &&
198 echo "fatal: bad config line 34 in file .git/config" >expect &&
199 test_expect_code 128 test-config get_value foo.bar 2>actual &&
200 - test_cmp expect actual
200 + test_i18ncmp expect actual
201 '
202
203 test_expect_success 'proper error on error in custom config files' '
204 echo "[" >>syntax-error &&
205 echo "fatal: bad config line 1 in file syntax-error" >expect &&
206 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
208 '
209
210 test_expect_success 'check line errors for malformed values' '
t/t1400-update-ref.sh
+1 -1
@@ -361,7 +361,7 @@ test_expect_success 'stdin test setup' '
361
362 test_expect_success '-z fails without --stdin' '
363 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
365 '
366
367 test_expect_success 'stdin works with no input' '
t/t2010-checkout-ambiguous.sh
+1 -1
@@ -49,7 +49,7 @@ test_expect_success 'disambiguate checking out from a tree-ish' '
49
50 test_expect_success 'accurate error message with more than one ref' '
51 test_must_fail git checkout HEAD master -- 2>actual &&
52 - grep 2 actual &&
52 + test_i18ngrep 2 actual &&
53 test_i18ngrep "one reference expected, 2 given" actual
54 '
55
t/t2018-checkout-branch.sh
+1 -1
@@ -124,7 +124,7 @@ test_expect_success 'checkout -b to @{-1} fails with the right branch name' '
124 git checkout branch2 &&
125 echo >expect "fatal: A branch named '\''branch1'\'' already exists." &&
126 test_must_fail git checkout -b @{-1} 2>actual &&
127 - test_cmp expect actual
127 + test_i18ncmp expect actual
128 '
129
130 test_expect_success 'checkout -B to an existing branch resets branch to HEAD' '
t/t3200-branch.sh
+3 -3
@@ -550,7 +550,7 @@ If you wanted to make '"'master'"' track '"'origin/master'"', do this:
550 git branch -d origin/master
551 git branch --set-upstream-to origin/master
552 EOF
553 - test_cmp expected actual
553 + test_i18ncmp expected actual
554 '
555
556 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
559 cat >expected <<EOF &&
560 The --set-upstream flag is deprecated and will be removed. Consider using --track or --set-upstream-to
561 EOF
562 - test_cmp expected actual
562 + test_i18ncmp expected actual
563 '
564
565 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
568 cat >expected <<EOF &&
569 The --set-upstream flag is deprecated and will be removed. Consider using --track or --set-upstream-to
570 EOF
571 - test_cmp expected actual
571 + test_i18ncmp expected actual
572 '
573
574 test_expect_success '--set-upstream-to notices an error to set branch as own upstream' '
t/t3201-branch-contains.sh
+1 -1
@@ -156,7 +156,7 @@ test_expect_success 'branch --merged with --verbose' '
156 * topic 2c939f4 [ahead 1] foo
157 zzz c77a0a9 second on master
158 EOF
159 - test_cmp expect actual
159 + test_i18ncmp expect actual
160 '
161
162 test_done
t/t3320-notes-merge-worktrees.sh
+1 -1
@@ -52,7 +52,7 @@ test_expect_success 'merge z into y while mid-merge in another workdir fails' '
52 cd worktree &&
53 git config core.notesRef refs/notes/y &&
54 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
56 ) &&
57 test_path_is_missing .git/worktrees/worktree/NOTES_MERGE_REF
58 '
t/t5505-remote.sh
+1 -1
@@ -1182,7 +1182,7 @@ test_expect_success 'extra args: setup' '
1182 test_extra_arg () {
1183 test_expect_success "extra args: $*" "
1184 test_must_fail git remote $* bogus_extra_arg 2>actual &&
1185 - grep '^usage:' actual
1185 + test_i18ngrep '^usage:' actual
1186 "
1187 }
1188
t/t5510-fetch.sh
+1 -1
@@ -644,7 +644,7 @@ test_expect_success 'fetch --prune prints the remotes url' '
644 git fetch --prune origin 2>&1 | head -n1 >../actual
645 ) &&
646 echo "From ${D}/." >expect &&
647 - test_cmp expect actual
647 + test_i18ncmp expect actual
648 '
649
650 test_expect_success 'branchname D/F conflict resolved by --prune' '
t/t5523-push-upstream.sh
+2 -2
@@ -75,7 +75,7 @@ test_expect_success TTY 'progress messages go to tty' '
75 ensure_fresh_upstream &&
76
77 test_terminal git push -u upstream master >out 2>err &&
78 - grep "Writing objects" err
78 + test_i18ngrep "Writing objects" err
79 '
80
81 test_expect_success 'progress messages do not go to non-tty' '
@@ -91,7 +91,7 @@ test_expect_success 'progress messages go to non-tty (forced)' '
91
92 # force progress messages to stderr, even though it is non-tty
93 git push -u --progress upstream master >out 2>err &&
94 - grep "Writing objects" err
94 + test_i18ngrep "Writing objects" err
95 '
96
97 test_expect_success TTY 'push -q suppresses progress' '
t/t5536-fetch-conflicts.sh
+2 -2
@@ -22,8 +22,8 @@ verify_stderr () {
22 cat >expected &&
23 # We're not interested in the error
24 # "fatal: The remote end hung up unexpectedly":
25 - grep -E '^(fatal|warning):' <error | grep -v 'hung up' >actual | sort &&
26 - test_cmp expected actual
25 + test_i18ngrep -E '^(fatal|warning):' <error | grep -v 'hung up' >actual | sort &&
26 + test_i18ncmp expected actual
27 }
28
29 test_expect_success 'setup' '
t/t6301-for-each-ref-errors.sh
+5 -5
@@ -20,8 +20,8 @@ test_expect_success 'Broken refs are reported correctly' '
20 test_when_finished "rm -f .git/$r" &&
21 echo "warning: ignoring broken ref $r" >broken-err &&
22 git for-each-ref >out 2>err &&
23 - test_cmp full-list out &&
24 - test_cmp broken-err err
23 + test_i18ncmp full-list out &&
24 + test_i18ncmp broken-err err
25 '
26
27 test_expect_success 'NULL_SHA1 refs are reported correctly' '
@@ -31,10 +31,10 @@ test_expect_success 'NULL_SHA1 refs are reported correctly' '
31 echo "warning: ignoring broken ref $r" >zeros-err &&
32 git for-each-ref >out 2>err &&
33 test_cmp full-list out &&
34 - test_cmp zeros-err err &&
34 + test_i18ncmp zeros-err err &&
35 git for-each-ref --format="%(objectname) %(refname)" >brief-out 2>brief-err &&
36 test_cmp brief-list brief-out &&
37 - test_cmp zeros-err brief-err
37 + test_i18ncmp zeros-err brief-err
38 '
39
40 test_expect_success 'Missing objects are reported correctly' '
@@ -43,7 +43,7 @@ test_expect_success 'Missing objects are reported correctly' '
43 test_when_finished "rm -f .git/$r" &&
44 echo "fatal: missing object $MISSING for $r" >missing-err &&
45 test_must_fail git for-each-ref 2>err &&
46 - test_cmp missing-err err &&
46 + test_i18ncmp missing-err err &&
47 (
48 cat brief-list &&
49 echo "$MISSING $r"
t/t7063-status-untracked-cache.sh
+1 -1
@@ -643,7 +643,7 @@ test_expect_success 'test ident field is working' '
643 cp -R done dthree dtwo four three ../other_worktree &&
644 GIT_WORK_TREE=../other_worktree git status 2>../err &&
645 echo "warning: Untracked cache is disabled on this system or location." >../expect &&
646 - test_cmp ../expect ../err
646 + test_i18ncmp ../expect ../err
647 '
648
649 test_done
t/t7102-reset.sh
+2 -2
@@ -66,14 +66,14 @@ test_expect_success 'reset --hard message' '
66 hex=$(git log -1 --format="%h") &&
67 git reset --hard > .actual &&
68 echo HEAD is now at $hex $(commit_msg) > .expected &&
69 - test_cmp .expected .actual
69 + test_i18ncmp .expected .actual
70 '
71
72 test_expect_success 'reset --hard message (ISO8859-1 logoutputencoding)' '
73 hex=$(git log -1 --format="%h") &&
74 git -c "i18n.logOutputEncoding=$test_encoding" reset --hard > .actual &&
75 echo HEAD is now at $hex $(commit_msg $test_encoding) > .expected &&
76 - test_cmp .expected .actual
76 + test_i18ncmp .expected .actual
77 '
78
79 >.diff_expect
t/t7400-submodule-basic.sh
+1 -1
@@ -942,7 +942,7 @@ test_expect_success 'submodule deinit from subdirectory' '
942 cd sub &&
943 git submodule deinit ../init >../output
944 ) &&
945 - grep "\\.\\./init" output &&
945 + test_i18ngrep "\\.\\./init" output &&
946 test -z "$(git config --get-regexp "submodule\.example\.")" &&
947 test -n "$(git config --get-regexp "submodule\.example2\.")" &&
948 test -f example2/.git &&
t/t7403-submodule-sync.sh
+2 -2
@@ -157,7 +157,7 @@ test_expect_success '"git submodule sync" should update submodule URLs - subdire
157 cd sub &&
158 git submodule sync >../../output
159 ) &&
160 - grep "\\.\\./submodule" output &&
160 + test_i18ngrep "\\.\\./submodule" output &&
161 test -d "$(
162 cd super-clone/submodule &&
163 git config remote.origin.url
@@ -188,7 +188,7 @@ test_expect_success '"git submodule sync --recursive" should update all submodul
188 cd sub &&
189 git submodule sync --recursive >../../output
190 ) &&
191 - grep "\\.\\./submodule/sub-submodule" output &&
191 + test_i18ngrep "\\.\\./submodule/sub-submodule" output &&
192 test -d "$(
193 cd super-clone/submodule &&
194 git config remote.origin.url
t/t7406-submodule-update.sh
+5 -5
@@ -136,8 +136,8 @@ test_expect_success 'submodule update --init --recursive from subdirectory' '
136 cd tmp &&
137 git submodule update --init --recursive ../super >../../actual 2>../../actual2
138 ) &&
139 - test_cmp expect actual &&
140 - test_cmp expect2 actual2
139 + test_i18ncmp expect actual &&
140 + test_i18ncmp expect2 actual2
141 '
142
143 apos="'";
@@ -370,7 +370,7 @@ test_expect_success 'submodule update - command in .git/config catches failure'
370 (cd super &&
371 test_must_fail git submodule update submodule 2>../actual
372 ) &&
373 - test_cmp actual expect
373 + test_i18ncmp actual expect
374 '
375
376 cat << EOF >expect
@@ -388,7 +388,7 @@ test_expect_success 'submodule update - command in .git/config catches failure -
388 mkdir tmp && cd tmp &&
389 test_must_fail git submodule update ../submodule 2>../../actual
390 ) &&
391 - test_cmp actual expect
391 + test_i18ncmp actual expect
392 '
393
394 cat << EOF >expect
@@ -408,7 +408,7 @@ test_expect_success 'recursive submodule update - command in .git/config catches
408 mkdir -p tmp && cd tmp &&
409 test_must_fail git submodule update --recursive ../super 2>../../actual
410 ) &&
411 - test_cmp actual expect
411 + test_i18ncmp actual expect
412 '
413
414 test_expect_success 'submodule init does not copy command into .git/config' '
t/t7508-status.sh
+2 -2
@@ -1377,7 +1377,7 @@ EOF
1377 git config --add -f .gitmodules submodule.subname.ignore all &&
1378 git config --add -f .gitmodules submodule.subname.path sm &&
1379 git status > output &&
1380 - test_cmp expect output &&
1380 + test_i18ncmp expect output &&
1381 git config -f .gitmodules --remove-section submodule.subname
1382 '
1383
@@ -1387,7 +1387,7 @@ test_expect_success '.git/config ignore=all suppresses unstaged submodule summar
1387 git config --add submodule.subname.ignore all &&
1388 git config --add submodule.subname.path sm &&
1389 git status > output &&
1390 - test_cmp expect output &&
1390 + test_i18ncmp expect output &&
1391 git config --remove-section submodule.subname &&
1392 git config -f .gitmodules --remove-section submodule.subname
1393 '