t: use test_expect_code instead of hand-rolled comparison

This makes our output in the event of a failure slightly nicer, and it means that we do not break the &&-chain. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Mar 20, 2015 at 06:11 UTC c21fc9d0ab217d6e3cf01ee895e827b72d8207b6
3 files changed +38 -44
t/t0040-parse-options.sh
+4 -8
@@ -172,12 +172,9 @@ test_expect_success 'long options' '
172 '
173
174 test_expect_success 'missing required value' '
175 - test-parse-options -s;
176 - test $? = 129 &&
177 - test-parse-options --string;
178 - test $? = 129 &&
179 - test-parse-options --file;
180 - test $? = 129
175 + test_expect_code 129 test-parse-options -s &&
176 + test_expect_code 129 test-parse-options --string &&
177 + test_expect_code 129 test-parse-options --file
178 '
179
180 cat > expect << EOF
@@ -227,8 +224,7 @@ test_expect_success 'unambiguously abbreviated option with "="' '
224 '
225
226 test_expect_success 'ambiguously abbreviated option' '
230 - test-parse-options --strin 123;
231 - test $? = 129
227 + test_expect_code 129 test-parse-options --strin 123
228 '
229
230 cat > expect << EOF
t/t4035-diff-quiet.sh
+32 -34
@@ -29,67 +29,65 @@ test_expect_success 'setup' '
29 '
30
31 test_expect_success 'git diff-tree HEAD^ HEAD' '
32 - git diff-tree --quiet HEAD^ HEAD >cnt
33 - test $? = 1 && test_line_count = 0 cnt
32 + test_expect_code 1 git diff-tree --quiet HEAD^ HEAD >cnt &&
33 + test_line_count = 0 cnt
34 '
35 test_expect_success 'git diff-tree HEAD^ HEAD -- a' '
36 - git diff-tree --quiet HEAD^ HEAD -- a >cnt
37 - test $? = 0 && test_line_count = 0 cnt
36 + test_expect_code 0 git diff-tree --quiet HEAD^ HEAD -- a >cnt &&
37 + test_line_count = 0 cnt
38 '
39 test_expect_success 'git diff-tree HEAD^ HEAD -- b' '
40 - git diff-tree --quiet HEAD^ HEAD -- b >cnt
41 - test $? = 1 && test_line_count = 0 cnt
40 + test_expect_code 1 git diff-tree --quiet HEAD^ HEAD -- b >cnt &&
41 + test_line_count = 0 cnt
42 '
43 # this diff outputs one line: sha1 of the given head
44 test_expect_success 'echo HEAD | git diff-tree --stdin' '
45 - echo $(git rev-parse HEAD) | git diff-tree --quiet --stdin >cnt
46 - test $? = 1 && test_line_count = 1 cnt
45 + echo $(git rev-parse HEAD) |
46 + test_expect_code 1 git diff-tree --quiet --stdin >cnt &&
47 + test_line_count = 1 cnt
48 '
49 test_expect_success 'git diff-tree HEAD HEAD' '
49 - git diff-tree --quiet HEAD HEAD >cnt
50 - test $? = 0 && test_line_count = 0 cnt
50 + test_expect_code 0 git diff-tree --quiet HEAD HEAD >cnt &&
51 + test_line_count = 0 cnt
52 '
53 test_expect_success 'git diff-files' '
53 - git diff-files --quiet >cnt
54 - test $? = 0 && test_line_count = 0 cnt
54 + test_expect_code 0 git diff-files --quiet >cnt &&
55 + test_line_count = 0 cnt
56 '
57 test_expect_success 'git diff-index --cached HEAD' '
57 - git diff-index --quiet --cached HEAD >cnt
58 - test $? = 0 && test_line_count = 0 cnt
58 + test_expect_code 0 git diff-index --quiet --cached HEAD >cnt &&
59 + test_line_count = 0 cnt
60 '
61 test_expect_success 'git diff-index --cached HEAD^' '
61 - git diff-index --quiet --cached HEAD^ >cnt
62 - test $? = 1 && test_line_count = 0 cnt
62 + test_expect_code 1 git diff-index --quiet --cached HEAD^ >cnt &&
63 + test_line_count = 0 cnt
64 '
65 test_expect_success 'git diff-index --cached HEAD^' '
66 echo text >>b &&
67 echo 3 >c &&
67 - git add . && {
68 - git diff-index --quiet --cached HEAD^ >cnt
69 - test $? = 1 && test_line_count = 0 cnt
70 - }
68 + git add . &&
69 + test_expect_code 1 git diff-index --quiet --cached HEAD^ >cnt &&
70 + test_line_count = 0 cnt
71 '
72 test_expect_success 'git diff-tree -Stext HEAD^ HEAD -- b' '
73 - git commit -m "text in b" && {
74 - git diff-tree --quiet -Stext HEAD^ HEAD -- b >cnt
75 - test $? = 1 && test_line_count = 0 cnt
76 - }
73 + git commit -m "text in b" &&
74 + test_expect_code 1 git diff-tree --quiet -Stext HEAD^ HEAD -- b >cnt &&
75 + test_line_count = 0 cnt
76 '
77 test_expect_success 'git diff-tree -Snot-found HEAD^ HEAD -- b' '
79 - git diff-tree --quiet -Snot-found HEAD^ HEAD -- b >cnt
80 - test $? = 0 && test_line_count = 0 cnt
78 + test_expect_code 0 git diff-tree --quiet -Snot-found HEAD^ HEAD -- b >cnt &&
79 + test_line_count = 0 cnt
80 '
81 test_expect_success 'git diff-files' '
83 - echo 3 >>c && {
84 - git diff-files --quiet >cnt
85 - test $? = 1 && test_line_count = 0 cnt
86 - }
82 + echo 3 >>c &&
83 + test_expect_code 1 git diff-files --quiet >cnt &&
84 + test_line_count = 0 cnt
85 '
86 +
87 test_expect_success 'git diff-index --cached HEAD' '
89 - git update-index c && {
90 - git diff-index --quiet --cached HEAD >cnt
91 - test $? = 1 && test_line_count = 0 cnt
92 - }
88 + git update-index c &&
89 + test_expect_code 1 git diff-index --quiet --cached HEAD >cnt &&
90 + test_line_count = 0 cnt
91 '
92
93 test_expect_success 'git diff, one file outside repo' '
t/t4053-diff-no-index.sh
+2 -2
@@ -17,8 +17,8 @@ test_expect_success 'setup' '
17 '
18
19 test_expect_success 'git diff --no-index directories' '
20 - git diff --no-index a b >cnt
21 - test $? = 1 && test_line_count = 14 cnt
20 + test_expect_code 1 git diff --no-index a b >cnt &&
21 + test_line_count = 14 cnt
22 '
23
24 test_expect_success 'git diff --no-index relative path outside repo' '