]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Fix tests under GETTEXT_POISON on parseopt
authorJiang Xin <worldhello.net@gmail.com>
Mon, 27 Aug 2012 05:36:55 +0000 (13:36 +0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 27 Aug 2012 16:26:30 +0000 (09:26 -0700)
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>
t/t0040-parse-options.sh
t/t1300-repo-config.sh
t/t1502-rev-parse-parseopt.sh
t/t2006-checkout-index-basic.sh
t/t2107-update-index-basic.sh
t/t3004-ls-files-basic.sh
t/t3200-branch.sh
t/t3501-revert-cherry-pick.sh
t/t4200-rerere.sh
t/t6500-gc.sh
t/t7600-merge.sh

index e3f354a45e382dbaa9de4557aa9310fa21eb626b..244a43c9201a3d81d0931f5f127bd2dcfd068eba 100755 (executable)
@@ -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
index a477453e2ef8ffedafb2dd05e00f507cd112bc97..e127f35db9d12dba84cbf0503628ab5d9a3fc24f 100755 (executable)
@@ -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
index 1efd7f76ddea8dbd788032c5a9076270d1159825..13c88c9aae7f7177cbff278cf5e587f86acb11e7 100755 (executable)
@@ -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
index b8559838b176ec8fa3c1d4acb71ae42ac71056c6..57cbdfe9bce93ddd33df08fec506be93e362db58 100755 (executable)
@@ -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
index 809fafe208cbf68121295922a4c230b2a5e1aee3..17d69403ee711c5672506af77e4c3489f1f13055 100755 (executable)
@@ -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
index 490e052875806849e9cbaa54958f1d8d02f5e8f2..8d9bc3c2af6ad84c006010ee7be65146107c2259 100755 (executable)
@@ -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
index a17f8b2a407c2de2bf81d8a858957da409f1c980..1ffce2173e4cc2d75d0fb33fc847c383cc5fa530 100755 (executable)
@@ -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' \
index 595d2ff990ad3305f47977431c0b7d102ca3866b..34c86e5de69468fe7618383e556d1711cc49b0bb 100755 (executable)
@@ -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' '
index 3ab670d36aea890e07827b14486e4c49de83bdb5..7f6666fcd3ffd6dfe53ed72cedcbabfe5a626ed8 100755 (executable)
@@ -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
index 82f363993712d2c0de44de6285f956b46e1ceaf2..b1a63655f98dfc8d19c1a80f86652654cd9cade6 100755 (executable)
@@ -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
index 9e27bbf902e275671cb80310630a8bedcaab353c..5e19598fe72787e17d521980a3edfacb1dfa2024 100755 (executable)
@@ -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' '