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>
Jiang Xin committed
Aug 27, 2012 at 13:36 UTC
9a0013819ea541cfa1102292d1fdceb30352c2c3
11 files changed
+46
-22
t/t0040-parse-options.sh
+29
-5
@@ -51,7 +51,7 @@ EOF
51
test_expect_success 'test help' '
52
test_must_fail test-parse-options -h > output 2> output.err &&
53
test ! -s output.err &&
54
- test_cmp expect output
54
+ test_i18ncmp expect output
55
'
56
57
mv expect expect.err
@@ -79,6 +79,17 @@ check() {
79
test_cmp expect output
80
}
81
82
+check_i18n() {
83
+ what="$1" &&
84
+ shift &&
85
+ expect="$1" &&
86
+ shift &&
87
+ sed "s/^$what .*/$what $expect/" <expect.template >expect &&
88
+ test-parse-options $* >output 2>output.err &&
89
+ test ! -s output.err &&
90
+ test_i18ncmp expect output
91
+}
92
+
93
check_unknown() {
94
case "$1" in
95
--*)
@@ -92,6 +103,19 @@ check_unknown() {
103
test_cmp expect output.err
104
}
105
106
+check_unknown_i18n() {
107
+ case "$1" in
108
+ --*)
109
+ echo error: unknown option \`${1#--}\' >expect ;;
110
+ -*)
111
+ echo error: unknown switch \`${1#-}\' >expect ;;
112
+ esac &&
113
+ cat expect.err >>expect &&
114
+ test_must_fail test-parse-options $* >output 2>output.err &&
115
+ test ! -s output &&
116
+ test_i18ncmp expect output.err
117
+}
118
+
119
test_expect_success 'OPT_BOOL() #1' 'check boolean: 1 --yes'
120
test_expect_success 'OPT_BOOL() #2' 'check boolean: 1 --no-doubt'
121
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'
128
test_expect_success 'OPT_BOOL() negation #1' 'check boolean: 0 -D --no-yes'
129
test_expect_success 'OPT_BOOL() negation #2' 'check boolean: 0 -D --no-no-doubt'
130
107
-test_expect_success 'OPT_BOOL() no negation #1' 'check_unknown --fear'
108
-test_expect_success 'OPT_BOOL() no negation #2' 'check_unknown --no-no-fear'
131
+test_expect_success 'OPT_BOOL() no negation #1' 'check_unknown_i18n --fear'
132
+test_expect_success 'OPT_BOOL() no negation #2' 'check_unknown_i18n --no-no-fear'
133
134
test_expect_success 'OPT_BOOL() positivation' 'check boolean: 0 -D --doubt'
135
@@ -310,8 +334,8 @@ EOF
334
335
test_expect_success 'OPT_CALLBACK() and callback errors work' '
336
test_must_fail test-parse-options --no-length > output 2> output.err &&
313
- test_cmp expect output &&
314
- test_cmp expect.err output.err
337
+ test_i18ncmp expect output &&
338
+ test_i18ncmp expect.err output.err
339
'
340
341
cat > expect <<EOF
t/t1300-repo-config.sh
+1
-1
@@ -391,7 +391,7 @@ test_expect_success 'get bool variable with empty value' \
391
392
test_expect_success 'no arguments, but no crash' '
393
test_must_fail git config >output 2>&1 &&
394
- grep usage output
394
+ test_i18ngrep usage output
395
'
396
397
cat > .git/config << EOF
t/t1502-rev-parse-parseopt.sh
+1
-1
@@ -41,7 +41,7 @@ EOF
41
42
test_expect_success 'test --parseopt help output' '
43
test_expect_code 129 git rev-parse --parseopt -- -h > output < optionspec &&
44
- test_cmp expect output
44
+ test_i18ncmp expect output
45
'
46
47
cat > expect <<EOF
t/t2006-checkout-index-basic.sh
+2
-2
@@ -7,7 +7,7 @@ test_description='basic checkout-index tests
7
8
test_expect_success 'checkout-index --gobbledegook' '
9
test_expect_code 129 git checkout-index --gobbledegook 2>err &&
10
- grep "[Uu]sage" err
10
+ test_i18ngrep "[Uu]sage" err
11
'
12
13
test_expect_success 'checkout-index -h in broken repository' '
@@ -18,7 +18,7 @@ test_expect_success 'checkout-index -h in broken repository' '
18
>.git/index &&
19
test_expect_code 129 git checkout-index -h >usage 2>&1
20
) &&
21
- grep "[Uu]sage" broken/usage
21
+ test_i18ngrep "[Uu]sage" broken/usage
22
'
23
24
test_done
t/t2107-update-index-basic.sh
+2
-2
@@ -15,7 +15,7 @@ test_expect_success 'update-index --nonsense fails' '
15
16
test_expect_success 'update-index --nonsense dumps usage' '
17
test_expect_code 129 git update-index --nonsense 2>err &&
18
- grep "[Uu]sage: git update-index" err
18
+ test_i18ngrep "[Uu]sage: git update-index" err
19
'
20
21
test_expect_success 'update-index -h with corrupt index' '
@@ -26,7 +26,7 @@ test_expect_success 'update-index -h with corrupt index' '
26
>.git/index &&
27
test_expect_code 129 git update-index -h >usage 2>&1
28
) &&
29
- grep "[Uu]sage: git update-index" broken/usage
29
+ test_i18ngrep "[Uu]sage: git update-index" broken/usage
30
'
31
32
test_done
t/t3004-ls-files-basic.sh
+2
-2
@@ -22,7 +22,7 @@ test_expect_success 'ls-files with nonexistent path' '
22
23
test_expect_success 'ls-files with nonsense option' '
24
test_expect_code 129 git ls-files --nonsense 2>actual &&
25
- grep "[Uu]sage: git ls-files" actual
25
+ test_i18ngrep "[Uu]sage: git ls-files" actual
26
'
27
28
test_expect_success 'ls-files -h in corrupt repository' '
@@ -33,7 +33,7 @@ test_expect_success 'ls-files -h in corrupt repository' '
33
>.git/index &&
34
test_expect_code 129 git ls-files -h >usage 2>&1
35
) &&
36
- grep "[Uu]sage: git ls-files " broken/usage
36
+ test_i18ngrep "[Uu]sage: git ls-files " broken/usage
37
'
38
39
test_done
t/t3200-branch.sh
+2
-2
@@ -31,7 +31,7 @@ test_expect_success 'branch -h in broken repository' '
31
>.git/refs/heads/master &&
32
test_expect_code 129 git branch -h >usage 2>&1
33
) &&
34
- grep "[Uu]sage" broken/usage
34
+ test_i18ngrep "[Uu]sage" broken/usage
35
'
36
37
test_expect_success \
@@ -74,7 +74,7 @@ test_expect_success \
74
test_expect_success \
75
'git branch -m dumps usage' \
76
'test_expect_code 129 git branch -m 2>err &&
77
- grep "[Uu]sage: git branch" err'
77
+ test_i18ngrep "[Uu]sage: git branch" err'
78
79
test_expect_success \
80
'git branch -m m m/m should work' \
t/t3501-revert-cherry-pick.sh
+2
-2
@@ -47,7 +47,7 @@ test_expect_success 'cherry-pick --nonsense' '
47
git diff --exit-code HEAD &&
48
test_must_fail git cherry-pick --nonsense 2>msg &&
49
git diff --exit-code HEAD "$pos" &&
50
- grep '[Uu]sage:' msg
50
+ test_i18ngrep '[Uu]sage:' msg
51
'
52
53
test_expect_success 'revert --nonsense' '
@@ -56,7 +56,7 @@ test_expect_success 'revert --nonsense' '
56
git diff --exit-code HEAD &&
57
test_must_fail git revert --nonsense 2>msg &&
58
git diff --exit-code HEAD "$pos" &&
59
- grep '[Uu]sage:' msg
59
+ test_i18ngrep '[Uu]sage:' msg
60
'
61
62
test_expect_success 'cherry-pick after renaming branch' '
t/t4200-rerere.sh
+2
-2
@@ -382,13 +382,13 @@ test_expect_success 'rerere --no-no-rerere-autoupdate' '
382
git update-index --index-info <failedmerge &&
383
cp file3.conflict file3 &&
384
test_must_fail git rerere --no-no-rerere-autoupdate 2>err &&
385
- grep [Uu]sage err &&
385
+ test_i18ngrep [Uu]sage err &&
386
test_must_fail git update-index --refresh
387
'
388
389
test_expect_success 'rerere -h' '
390
test_must_fail git rerere -h >help &&
391
- grep [Uu]sage help
391
+ test_i18ngrep [Uu]sage help
392
'
393
394
test_done
t/t6500-gc.sh
+2
-2
@@ -11,7 +11,7 @@ test_expect_success 'gc empty repository' '
11
12
test_expect_success 'gc --gobbledegook' '
13
test_expect_code 129 git gc --nonsense 2>err &&
14
- grep "[Uu]sage: git gc" err
14
+ test_i18ngrep "[Uu]sage: git gc" err
15
'
16
17
test_expect_success 'gc -h with invalid configuration' '
@@ -22,7 +22,7 @@ test_expect_success 'gc -h with invalid configuration' '
22
echo "[gc] pruneexpire = CORRUPT" >>.git/config &&
23
test_expect_code 129 git gc -h >usage 2>&1
24
) &&
25
- grep "[Uu]sage" broken/usage
25
+ test_i18ngrep "[Uu]sage" broken/usage
26
'
27
28
test_done
t/t7600-merge.sh
+1
-1
@@ -157,7 +157,7 @@ test_expect_success 'merge -h with invalid index' '
157
>.git/index &&
158
test_expect_code 129 git merge -h 2>usage
159
) &&
160
- grep "[Uu]sage: git merge" broken/usage
160
+ test_i18ngrep "[Uu]sage: git merge" broken/usage
161
'
162
163
test_expect_success 'reject non-strategy with a git-merge-foo name' '