mirror of
https://github.com/git/git
synced 2024-08-25 10:45:59 +00:00
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>
This commit is contained in:
parent
ab33a76ec5
commit
1edbaac3bb
|
@ -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
|
||||
|
|
|
@ -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' '
|
||||
|
|
|
@ -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' '
|
||||
|
|
|
@ -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' '
|
||||
|
|
|
@ -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' '
|
||||
|
|
|
@ -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
|
||||
'
|
||||
|
||||
|
|
|
@ -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' '
|
||||
|
|
|
@ -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' '
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
'
|
||||
|
|
|
@ -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
|
||||
"
|
||||
}
|
||||
|
||||
|
|
|
@ -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' '
|
||||
|
|
|
@ -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' '
|
||||
|
|
|
@ -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' '
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 &&
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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' '
|
||||
|
|
|
@ -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
|
||||
'
|
||||
|
|
Loading…
Reference in a new issue