Fix tests under GETTEXT_POISON on parseopt
Use the i18n-specific test functions in test scripts for parseopt tests. This issue was was introduced in v1.7.10.1-488-g54e6d: 54e6d i18n: parseopt: lookup help and argument translations when showing usage and been broken under GETTEXT_POISON=YesPlease since. Signed-off-by: Jiang Xin <worldhello.net@gmail.com> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
f7dc6a9643
commit
9a0013819e
@ -51,7 +51,7 @@ EOF
|
||||
test_expect_success 'test help' '
|
||||
test_must_fail test-parse-options -h > output 2> output.err &&
|
||||
test ! -s output.err &&
|
||||
test_cmp expect output
|
||||
test_i18ncmp expect output
|
||||
'
|
||||
|
||||
mv expect expect.err
|
||||
@ -79,6 +79,17 @@ check() {
|
||||
test_cmp expect output
|
||||
}
|
||||
|
||||
check_i18n() {
|
||||
what="$1" &&
|
||||
shift &&
|
||||
expect="$1" &&
|
||||
shift &&
|
||||
sed "s/^$what .*/$what $expect/" <expect.template >expect &&
|
||||
test-parse-options $* >output 2>output.err &&
|
||||
test ! -s output.err &&
|
||||
test_i18ncmp expect output
|
||||
}
|
||||
|
||||
check_unknown() {
|
||||
case "$1" in
|
||||
--*)
|
||||
@ -92,6 +103,19 @@ check_unknown() {
|
||||
test_cmp expect output.err
|
||||
}
|
||||
|
||||
check_unknown_i18n() {
|
||||
case "$1" in
|
||||
--*)
|
||||
echo error: unknown option \`${1#--}\' >expect ;;
|
||||
-*)
|
||||
echo error: unknown switch \`${1#-}\' >expect ;;
|
||||
esac &&
|
||||
cat expect.err >>expect &&
|
||||
test_must_fail test-parse-options $* >output 2>output.err &&
|
||||
test ! -s output &&
|
||||
test_i18ncmp expect output.err
|
||||
}
|
||||
|
||||
test_expect_success 'OPT_BOOL() #1' 'check boolean: 1 --yes'
|
||||
test_expect_success 'OPT_BOOL() #2' 'check boolean: 1 --no-doubt'
|
||||
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'
|
||||
test_expect_success 'OPT_BOOL() negation #1' 'check boolean: 0 -D --no-yes'
|
||||
test_expect_success 'OPT_BOOL() negation #2' 'check boolean: 0 -D --no-no-doubt'
|
||||
|
||||
test_expect_success 'OPT_BOOL() no negation #1' 'check_unknown --fear'
|
||||
test_expect_success 'OPT_BOOL() no negation #2' 'check_unknown --no-no-fear'
|
||||
test_expect_success 'OPT_BOOL() no negation #1' 'check_unknown_i18n --fear'
|
||||
test_expect_success 'OPT_BOOL() no negation #2' 'check_unknown_i18n --no-no-fear'
|
||||
|
||||
test_expect_success 'OPT_BOOL() positivation' 'check boolean: 0 -D --doubt'
|
||||
|
||||
@ -310,8 +334,8 @@ EOF
|
||||
|
||||
test_expect_success 'OPT_CALLBACK() and callback errors work' '
|
||||
test_must_fail test-parse-options --no-length > output 2> output.err &&
|
||||
test_cmp expect output &&
|
||||
test_cmp expect.err output.err
|
||||
test_i18ncmp expect output &&
|
||||
test_i18ncmp expect.err output.err
|
||||
'
|
||||
|
||||
cat > expect <<EOF
|
||||
|
@ -391,7 +391,7 @@ test_expect_success 'get bool variable with empty value' \
|
||||
|
||||
test_expect_success 'no arguments, but no crash' '
|
||||
test_must_fail git config >output 2>&1 &&
|
||||
grep usage output
|
||||
test_i18ngrep usage output
|
||||
'
|
||||
|
||||
cat > .git/config << EOF
|
||||
|
@ -41,7 +41,7 @@ EOF
|
||||
|
||||
test_expect_success 'test --parseopt help output' '
|
||||
test_expect_code 129 git rev-parse --parseopt -- -h > output < optionspec &&
|
||||
test_cmp expect output
|
||||
test_i18ncmp expect output
|
||||
'
|
||||
|
||||
cat > expect <<EOF
|
||||
|
@ -7,7 +7,7 @@ test_description='basic checkout-index tests
|
||||
|
||||
test_expect_success 'checkout-index --gobbledegook' '
|
||||
test_expect_code 129 git checkout-index --gobbledegook 2>err &&
|
||||
grep "[Uu]sage" err
|
||||
test_i18ngrep "[Uu]sage" err
|
||||
'
|
||||
|
||||
test_expect_success 'checkout-index -h in broken repository' '
|
||||
@ -18,7 +18,7 @@ test_expect_success 'checkout-index -h in broken repository' '
|
||||
>.git/index &&
|
||||
test_expect_code 129 git checkout-index -h >usage 2>&1
|
||||
) &&
|
||||
grep "[Uu]sage" broken/usage
|
||||
test_i18ngrep "[Uu]sage" broken/usage
|
||||
'
|
||||
|
||||
test_done
|
||||
|
@ -15,7 +15,7 @@ test_expect_success 'update-index --nonsense fails' '
|
||||
|
||||
test_expect_success 'update-index --nonsense dumps usage' '
|
||||
test_expect_code 129 git update-index --nonsense 2>err &&
|
||||
grep "[Uu]sage: git update-index" err
|
||||
test_i18ngrep "[Uu]sage: git update-index" err
|
||||
'
|
||||
|
||||
test_expect_success 'update-index -h with corrupt index' '
|
||||
@ -26,7 +26,7 @@ test_expect_success 'update-index -h with corrupt index' '
|
||||
>.git/index &&
|
||||
test_expect_code 129 git update-index -h >usage 2>&1
|
||||
) &&
|
||||
grep "[Uu]sage: git update-index" broken/usage
|
||||
test_i18ngrep "[Uu]sage: git update-index" broken/usage
|
||||
'
|
||||
|
||||
test_done
|
||||
|
@ -22,7 +22,7 @@ test_expect_success 'ls-files with nonexistent path' '
|
||||
|
||||
test_expect_success 'ls-files with nonsense option' '
|
||||
test_expect_code 129 git ls-files --nonsense 2>actual &&
|
||||
grep "[Uu]sage: git ls-files" actual
|
||||
test_i18ngrep "[Uu]sage: git ls-files" actual
|
||||
'
|
||||
|
||||
test_expect_success 'ls-files -h in corrupt repository' '
|
||||
@ -33,7 +33,7 @@ test_expect_success 'ls-files -h in corrupt repository' '
|
||||
>.git/index &&
|
||||
test_expect_code 129 git ls-files -h >usage 2>&1
|
||||
) &&
|
||||
grep "[Uu]sage: git ls-files " broken/usage
|
||||
test_i18ngrep "[Uu]sage: git ls-files " broken/usage
|
||||
'
|
||||
|
||||
test_done
|
||||
|
@ -31,7 +31,7 @@ test_expect_success 'branch -h in broken repository' '
|
||||
>.git/refs/heads/master &&
|
||||
test_expect_code 129 git branch -h >usage 2>&1
|
||||
) &&
|
||||
grep "[Uu]sage" broken/usage
|
||||
test_i18ngrep "[Uu]sage" broken/usage
|
||||
'
|
||||
|
||||
test_expect_success \
|
||||
@ -74,7 +74,7 @@ test_expect_success \
|
||||
test_expect_success \
|
||||
'git branch -m dumps usage' \
|
||||
'test_expect_code 129 git branch -m 2>err &&
|
||||
grep "[Uu]sage: git branch" err'
|
||||
test_i18ngrep "[Uu]sage: git branch" err'
|
||||
|
||||
test_expect_success \
|
||||
'git branch -m m m/m should work' \
|
||||
|
@ -47,7 +47,7 @@ test_expect_success 'cherry-pick --nonsense' '
|
||||
git diff --exit-code HEAD &&
|
||||
test_must_fail git cherry-pick --nonsense 2>msg &&
|
||||
git diff --exit-code HEAD "$pos" &&
|
||||
grep '[Uu]sage:' msg
|
||||
test_i18ngrep '[Uu]sage:' msg
|
||||
'
|
||||
|
||||
test_expect_success 'revert --nonsense' '
|
||||
@ -56,7 +56,7 @@ test_expect_success 'revert --nonsense' '
|
||||
git diff --exit-code HEAD &&
|
||||
test_must_fail git revert --nonsense 2>msg &&
|
||||
git diff --exit-code HEAD "$pos" &&
|
||||
grep '[Uu]sage:' msg
|
||||
test_i18ngrep '[Uu]sage:' msg
|
||||
'
|
||||
|
||||
test_expect_success 'cherry-pick after renaming branch' '
|
||||
|
@ -382,13 +382,13 @@ test_expect_success 'rerere --no-no-rerere-autoupdate' '
|
||||
git update-index --index-info <failedmerge &&
|
||||
cp file3.conflict file3 &&
|
||||
test_must_fail git rerere --no-no-rerere-autoupdate 2>err &&
|
||||
grep [Uu]sage err &&
|
||||
test_i18ngrep [Uu]sage err &&
|
||||
test_must_fail git update-index --refresh
|
||||
'
|
||||
|
||||
test_expect_success 'rerere -h' '
|
||||
test_must_fail git rerere -h >help &&
|
||||
grep [Uu]sage help
|
||||
test_i18ngrep [Uu]sage help
|
||||
'
|
||||
|
||||
test_done
|
||||
|
@ -11,7 +11,7 @@ test_expect_success 'gc empty repository' '
|
||||
|
||||
test_expect_success 'gc --gobbledegook' '
|
||||
test_expect_code 129 git gc --nonsense 2>err &&
|
||||
grep "[Uu]sage: git gc" err
|
||||
test_i18ngrep "[Uu]sage: git gc" err
|
||||
'
|
||||
|
||||
test_expect_success 'gc -h with invalid configuration' '
|
||||
@ -22,7 +22,7 @@ test_expect_success 'gc -h with invalid configuration' '
|
||||
echo "[gc] pruneexpire = CORRUPT" >>.git/config &&
|
||||
test_expect_code 129 git gc -h >usage 2>&1
|
||||
) &&
|
||||
grep "[Uu]sage" broken/usage
|
||||
test_i18ngrep "[Uu]sage" broken/usage
|
||||
'
|
||||
|
||||
test_done
|
||||
|
@ -157,7 +157,7 @@ test_expect_success 'merge -h with invalid index' '
|
||||
>.git/index &&
|
||||
test_expect_code 129 git merge -h 2>usage
|
||||
) &&
|
||||
grep "[Uu]sage: git merge" broken/usage
|
||||
test_i18ngrep "[Uu]sage: git merge" broken/usage
|
||||
'
|
||||
|
||||
test_expect_success 'reject non-strategy with a git-merge-foo name' '
|
||||
|
Loading…
Reference in New Issue
Block a user