tests: use test_i18n* functions to suppress false positives
authorVasco Almeida <vascomalmeida@sapo.pt>
Fri, 17 Jun 2016 20:21:07 +0000 (20:21 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 17 Jun 2016 22:45:48 +0000 (15:45 -0700)
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>
21 files changed:
t/t0008-ignores.sh
t/t1300-repo-config.sh
t/t1307-config-blob.sh
t/t1308-config-set.sh
t/t1400-update-ref.sh
t/t2010-checkout-ambiguous.sh
t/t2018-checkout-branch.sh
t/t3200-branch.sh
t/t3201-branch-contains.sh
t/t3320-notes-merge-worktrees.sh
t/t5505-remote.sh
t/t5510-fetch.sh
t/t5523-push-upstream.sh
t/t5536-fetch-conflicts.sh
t/t6301-for-each-ref-errors.sh
t/t7063-status-untracked-cache.sh
t/t7102-reset.sh
t/t7400-submodule-basic.sh
t/t7403-submodule-sync.sh
t/t7406-submodule-update.sh
t/t7508-status.sh
index 89544dd8332793af7c792a45e6566f207ef57e38..43aa2bd8f8682eae6c984505e12852ec5856ea59 100755 (executable)
@@ -34,7 +34,7 @@ expect_from_stdin () {
 test_stderr () {
        expected="$1"
        expect_in stderr "$1" &&
-       test_cmp "$HOME/expected-stderr" "$HOME/stderr"
+       test_i18ncmp "$HOME/expected-stderr" "$HOME/stderr"
 }
 
 broken_c_unquote () {
@@ -47,7 +47,7 @@ broken_c_unquote_verbose () {
 
 stderr_contains () {
        regexp="$1"
-       if grep "$regexp" "$HOME/stderr"
+       if test_i18ngrep "$regexp" "$HOME/stderr"
        then
                return 0
        else
index d934a2441724332d9e8cebd7679788ee3a660fce..923bfc5a2606588f30bebbcfd4c34788976c354c 100755 (executable)
@@ -886,7 +886,7 @@ test_expect_success !MINGW 'get --path copes with unset $HOME' '
                git config --get --path path.normal >>result &&
                git config --get --path path.trailingtilde >>result
        ) &&
-       grep "[Ff]ailed to expand.*~/" msg &&
+       test_i18ngrep "[Ff]ailed to expand.*~/" msg &&
        test_cmp expect result
 '
 
@@ -1126,7 +1126,7 @@ test_expect_success 'barf on syntax error' '
        key garbage
        EOF
        test_must_fail git config --get section.key >actual 2>error &&
-       grep " line 3 " error
+       test_i18ngrep " line 3 " error
 '
 
 test_expect_success 'barf on incomplete section header' '
@@ -1136,7 +1136,7 @@ test_expect_success 'barf on incomplete section header' '
        key = value
        EOF
        test_must_fail git config --get section.key >actual 2>error &&
-       grep " line 2 " error
+       test_i18ngrep " line 2 " error
 '
 
 test_expect_success 'barf on incomplete string' '
@@ -1146,7 +1146,7 @@ test_expect_success 'barf on incomplete string' '
        key = "value string
        EOF
        test_must_fail git config --get section.key >actual 2>error &&
-       grep " line 3 " error
+       test_i18ngrep " line 3 " error
 '
 
 test_expect_success 'urlmatch' '
index 3c6791e6be705bc823ff180cd481fef3dc939734..eed31ffa30eebaa994b2fee569eb753e2a6a1477 100755 (executable)
@@ -61,10 +61,7 @@ test_expect_success 'parse errors in blobs are properly attributed' '
        git commit -m broken &&
 
        test_must_fail git config --blob=HEAD:config some.value 2>err &&
-
-       # just grep for our token as the exact error message is likely to
-       # change or be internationalized
-       grep "HEAD:config" err
+       test_i18ngrep "HEAD:config" err
 '
 
 test_expect_success 'can parse blob ending with CR' '
index 005d66dbef6c361363752b37087bbbc6a3098833..cd6206351f94ab37b756fbb10a9b5d5fd3373a16 100755 (executable)
@@ -197,14 +197,14 @@ test_expect_success 'proper error on error in default config files' '
        echo "[" >>.git/config &&
        echo "fatal: bad config line 34 in file .git/config" >expect &&
        test_expect_code 128 test-config get_value foo.bar 2>actual &&
-       test_cmp expect actual
+       test_i18ncmp expect actual
 '
 
 test_expect_success 'proper error on error in custom config files' '
        echo "[" >>syntax-error &&
        echo "fatal: bad config line 1 in file syntax-error" >expect &&
        test_expect_code 128 test-config configset_get_value foo.bar syntax-error 2>actual &&
-       test_cmp expect actual
+       test_i18ncmp expect actual
 '
 
 test_expect_success 'check line errors for malformed values' '
index af1b20dd5c6763e58eccd3f93722987f5f9ce233..75fa6548c4baeae4192402817ee2264d2f3cb5a9 100755 (executable)
@@ -361,7 +361,7 @@ test_expect_success 'stdin test setup' '
 
 test_expect_success '-z fails without --stdin' '
        test_must_fail git update-ref -z $m $m $m 2>err &&
-       grep "usage: git update-ref" err
+       test_i18ngrep "usage: git update-ref" err
 '
 
 test_expect_success 'stdin works with no input' '
index 87bdf9c96bfacf4ac921ad9b195db46d9c3b079a..e76e84afbba58f94c600586388f8793b6b6eae84 100755 (executable)
@@ -49,7 +49,7 @@ test_expect_success 'disambiguate checking out from a tree-ish' '
 
 test_expect_success 'accurate error message with more than one ref' '
        test_must_fail git checkout HEAD master -- 2>actual &&
-       grep 2 actual &&
+       test_i18ngrep 2 actual &&
        test_i18ngrep "one reference expected, 2 given" actual
 '
 
index 2741262369e40a05cdc6732e4c9e6f04acb63bba..2131fb2a5682c50faf64e6066f03080702168b94 100755 (executable)
@@ -124,7 +124,7 @@ test_expect_success 'checkout -b to @{-1} fails with the right branch name' '
        git checkout branch2 &&
        echo  >expect "fatal: A branch named '\''branch1'\'' already exists." &&
        test_must_fail git checkout -b @{-1} 2>actual &&
-       test_cmp expect actual
+       test_i18ncmp expect actual
 '
 
 test_expect_success 'checkout -B to an existing branch resets branch to HEAD' '
index f3e3b6cf2eabf0d57f64d794dba9a6195e8da246..ac9c76479933f6f1c750aa4a6f544a8b5a343439 100755 (executable)
@@ -550,7 +550,7 @@ If you wanted to make '"'master'"' track '"'origin/master'"', do this:
     git branch -d origin/master
     git branch --set-upstream-to origin/master
 EOF
-       test_cmp expected actual
+       test_i18ncmp expected actual
 '
 
 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
        cat >expected <<EOF &&
 The --set-upstream flag is deprecated and will be removed. Consider using --track or --set-upstream-to
 EOF
-       test_cmp expected actual
+       test_i18ncmp expected actual
 '
 
 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
        cat >expected <<EOF &&
 The --set-upstream flag is deprecated and will be removed. Consider using --track or --set-upstream-to
 EOF
-       test_cmp expected actual
+       test_i18ncmp expected actual
 '
 
 test_expect_success '--set-upstream-to notices an error to set branch as own upstream' '
index 912a6635a808cbb6ae78dec545441d363bdeb0d0..7f3ec47241cd6af7a1c107cba114decaa87df108 100755 (executable)
@@ -156,7 +156,7 @@ test_expect_success 'branch --merged with --verbose' '
        * topic  2c939f4 [ahead 1] foo
          zzz    c77a0a9 second on master
        EOF
-       test_cmp expect actual
+       test_i18ncmp expect actual
 '
 
 test_done
index 1f71d589f5f2fc6ed690bce7202bece04d8b0279..522157b76461cfd781cb69dc1ce8bddb2a03517e 100755 (executable)
@@ -52,7 +52,7 @@ test_expect_success 'merge z into y while mid-merge in another workdir fails' '
                cd worktree &&
                git config core.notesRef refs/notes/y &&
                test_must_fail git notes merge z 2>err &&
-               grep "A notes merge into refs/notes/y is already in-progress at" err
+               test_i18ngrep "A notes merge into refs/notes/y is already in-progress at" err
        ) &&
        test_path_is_missing .git/worktrees/worktree/NOTES_MERGE_REF
 '
index dd2e6ce34e7dff0e59e917fd4e3aefa01181778c..8198d8eb05c5366c7d61a12351c333902a2265b6 100755 (executable)
@@ -1182,7 +1182,7 @@ test_expect_success 'extra args: setup' '
 test_extra_arg () {
        test_expect_success "extra args: $*" "
                test_must_fail git remote $* bogus_extra_arg 2>actual &&
-               grep '^usage:' actual
+               test_i18ngrep '^usage:' actual
        "
 }
 
index 454d896390c03667442ce12925066b14593b3cd1..88076da1e64b16eb3b1f956c14ba7717d183ae1e 100755 (executable)
@@ -644,7 +644,7 @@ test_expect_success 'fetch --prune prints the remotes url' '
                git fetch --prune origin 2>&1 | head -n1 >../actual
        ) &&
        echo "From ${D}/." >expect &&
-       test_cmp expect actual
+       test_i18ncmp expect actual
 '
 
 test_expect_success 'branchname D/F conflict resolved by --prune' '
index 3683df13a6ae2208212bd3606187f9876e0562b5..4a7b98b4788b93bd216643ef90a764e144abf3da 100755 (executable)
@@ -75,7 +75,7 @@ test_expect_success TTY 'progress messages go to tty' '
        ensure_fresh_upstream &&
 
        test_terminal git push -u upstream master >out 2>err &&
-       grep "Writing objects" err
+       test_i18ngrep "Writing objects" err
 '
 
 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)' '
 
        # force progress messages to stderr, even though it is non-tty
        git push -u --progress upstream master >out 2>err &&
-       grep "Writing objects" err
+       test_i18ngrep "Writing objects" err
 '
 
 test_expect_success TTY 'push -q suppresses progress' '
index 6c5d3a4ce0877b11bc7db530522447a65098979d..2e42cf331648a8ba57b3806443e70b94b09eb382 100755 (executable)
@@ -22,8 +22,8 @@ verify_stderr () {
        cat >expected &&
        # We're not interested in the error
        # "fatal: The remote end hung up unexpectedly":
-       grep -E '^(fatal|warning):' <error | grep -v 'hung up' >actual | sort &&
-       test_cmp expected actual
+       test_i18ngrep -E '^(fatal|warning):' <error | grep -v 'hung up' >actual | sort &&
+       test_i18ncmp expected actual
 }
 
 test_expect_success 'setup' '
index cdb67a03b712cbd2cf187e91f7d69a3f717847bf..c734ce2388a79d15692875eae81e323c63ad2300 100755 (executable)
@@ -20,8 +20,8 @@ test_expect_success 'Broken refs are reported correctly' '
        test_when_finished "rm -f .git/$r" &&
        echo "warning: ignoring broken ref $r" >broken-err &&
        git for-each-ref >out 2>err &&
-       test_cmp full-list out &&
-       test_cmp broken-err err
+       test_i18ncmp full-list out &&
+       test_i18ncmp broken-err err
 '
 
 test_expect_success 'NULL_SHA1 refs are reported correctly' '
@@ -31,10 +31,10 @@ test_expect_success 'NULL_SHA1 refs are reported correctly' '
        echo "warning: ignoring broken ref $r" >zeros-err &&
        git for-each-ref >out 2>err &&
        test_cmp full-list out &&
-       test_cmp zeros-err err &&
+       test_i18ncmp zeros-err err &&
        git for-each-ref --format="%(objectname) %(refname)" >brief-out 2>brief-err &&
        test_cmp brief-list brief-out &&
-       test_cmp zeros-err brief-err
+       test_i18ncmp zeros-err brief-err
 '
 
 test_expect_success 'Missing objects are reported correctly' '
@@ -43,7 +43,7 @@ test_expect_success 'Missing objects are reported correctly' '
        test_when_finished "rm -f .git/$r" &&
        echo "fatal: missing object $MISSING for $r" >missing-err &&
        test_must_fail git for-each-ref 2>err &&
-       test_cmp missing-err err &&
+       test_i18ncmp missing-err err &&
        (
                cat brief-list &&
                echo "$MISSING $r"
index a971884cfd8f03de29c978734812ab295fcbb08f..38b3890532ddfdef1f110e37aefe404596752703 100755 (executable)
@@ -643,7 +643,7 @@ test_expect_success 'test ident field is working' '
        cp -R done dthree dtwo four three ../other_worktree &&
        GIT_WORK_TREE=../other_worktree git status 2>../err &&
        echo "warning: Untracked cache is disabled on this system or location." >../expect &&
-       test_cmp ../expect ../err
+       test_i18ncmp ../expect ../err
 '
 
 test_done
index 98bcfe21aa3b6088a228593c627821a7f2740407..86f23be34aa69a9a345f95554f8a32d6ac45af5d 100755 (executable)
@@ -66,14 +66,14 @@ test_expect_success 'reset --hard message' '
        hex=$(git log -1 --format="%h") &&
        git reset --hard > .actual &&
        echo HEAD is now at $hex $(commit_msg) > .expected &&
-       test_cmp .expected .actual
+       test_i18ncmp .expected .actual
 '
 
 test_expect_success 'reset --hard message (ISO8859-1 logoutputencoding)' '
        hex=$(git log -1 --format="%h") &&
        git -c "i18n.logOutputEncoding=$test_encoding" reset --hard > .actual &&
        echo HEAD is now at $hex $(commit_msg $test_encoding) > .expected &&
-       test_cmp .expected .actual
+       test_i18ncmp .expected .actual
 '
 
 >.diff_expect
index 3570f7bb8c8955a1bf519eda3278392d249e6fd1..b77cce8e4066ac7f46ba1a02eab7215a4cdeaaae 100755 (executable)
@@ -942,7 +942,7 @@ test_expect_success 'submodule deinit from subdirectory' '
                cd sub &&
                git submodule deinit ../init >../output
        ) &&
-       grep "\\.\\./init" output &&
+       test_i18ngrep "\\.\\./init" output &&
        test -z "$(git config --get-regexp "submodule\.example\.")" &&
        test -n "$(git config --get-regexp "submodule\.example2\.")" &&
        test -f example2/.git &&
index 79bc135bf69ea5813f0a372db6bbefa0f9a92753..b8690b193224b003c032937f8186a298222b4e23 100755 (executable)
@@ -157,7 +157,7 @@ test_expect_success '"git submodule sync" should update submodule URLs - subdire
                cd sub &&
                git submodule sync >../../output
        ) &&
-       grep "\\.\\./submodule" output &&
+       test_i18ngrep "\\.\\./submodule" output &&
        test -d "$(
                cd super-clone/submodule &&
                git config remote.origin.url
@@ -188,7 +188,7 @@ test_expect_success '"git submodule sync --recursive" should update all submodul
                cd sub &&
                git submodule sync --recursive >../../output
        ) &&
-       grep "\\.\\./submodule/sub-submodule" output &&
+       test_i18ngrep "\\.\\./submodule/sub-submodule" output &&
        test -d "$(
                cd super-clone/submodule &&
                git config remote.origin.url
index 5f278799d5a0ceed90b9297ace552b653026e596..88e9750abb2f2c0346385439e305dd07ec795a41 100755 (executable)
@@ -136,8 +136,8 @@ test_expect_success 'submodule update --init --recursive from subdirectory' '
         cd tmp &&
         git submodule update --init --recursive ../super >../../actual 2>../../actual2
        ) &&
-       test_cmp expect actual &&
-       test_cmp expect2 actual2
+       test_i18ncmp expect actual &&
+       test_i18ncmp expect2 actual2
 '
 
 apos="'";
@@ -370,7 +370,7 @@ test_expect_success 'submodule update - command in .git/config catches failure'
        (cd super &&
         test_must_fail git submodule update submodule 2>../actual
        ) &&
-       test_cmp actual expect
+       test_i18ncmp actual expect
 '
 
 cat << EOF >expect
@@ -388,7 +388,7 @@ test_expect_success 'submodule update - command in .git/config catches failure -
         mkdir tmp && cd tmp &&
         test_must_fail git submodule update ../submodule 2>../../actual
        ) &&
-       test_cmp actual expect
+       test_i18ncmp actual expect
 '
 
 cat << EOF >expect
@@ -408,7 +408,7 @@ test_expect_success 'recursive submodule update - command in .git/config catches
         mkdir -p tmp && cd tmp &&
         test_must_fail git submodule update --recursive ../super 2>../../actual
        ) &&
-       test_cmp actual expect
+       test_i18ncmp actual expect
 '
 
 test_expect_success 'submodule init does not copy command into .git/config' '
index c3ed7cb51c9a73b5bb6152b56824e6c6b8347d2c..b3bdd162aaaf0fed0be9f62feab6aeb4b7019dbe 100755 (executable)
@@ -1377,7 +1377,7 @@ EOF
        git config --add -f .gitmodules submodule.subname.ignore all &&
        git config --add -f .gitmodules submodule.subname.path sm &&
        git status > output &&
-       test_cmp expect output &&
+       test_i18ncmp expect output &&
        git config -f .gitmodules  --remove-section submodule.subname
 '
 
@@ -1387,7 +1387,7 @@ test_expect_success '.git/config ignore=all suppresses unstaged submodule summar
        git config --add submodule.subname.ignore all &&
        git config --add submodule.subname.path sm &&
        git status > output &&
-       test_cmp expect output &&
+       test_i18ncmp expect output &&
        git config --remove-section submodule.subname &&
        git config -f .gitmodules  --remove-section submodule.subname
 '