t4117: use modern test_* helpers
We can use test_must_fail and test_path_* to avoid some hand-rolled if statements. This makes the code shorter, and makes it more obvious when we are breaking 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:13 UTC
e7d053ddb97f9a5a14567d9311dc6d8badf73a9c
1 file changed
+10
-56
t/t4117-apply-reject.sh
+10
-56
@@ -56,23 +56,13 @@ test_expect_success 'apply --reject is incompatible with --3way' '
56
57
test_expect_success 'apply without --reject should fail' '
58
59
- if git apply patch.1
60
- then
61
- echo "Eh? Why?"
62
- exit 1
63
- fi
64
-
59
+ test_must_fail git apply patch.1 &&
60
test_cmp file1 saved.file1
61
'
62
63
test_expect_success 'apply without --reject should fail' '
64
70
- if git apply --verbose patch.1
71
- then
72
- echo "Eh? Why?"
73
- exit 1
74
- fi
75
-
65
+ test_must_fail git apply --verbose patch.1 &&
66
test_cmp file1 saved.file1
67
'
68
@@ -81,21 +71,11 @@ test_expect_success 'apply with --reject should fail but update the file' '
71
cat saved.file1 >file1 &&
72
rm -f file1.rej file2.rej &&
73
84
- if git apply --reject patch.1
85
- then
86
- echo "succeeds with --reject?"
87
- exit 1
88
- fi
89
-
74
+ test_must_fail git apply --reject patch.1 &&
75
test_cmp file1 expected &&
76
77
cat file1.rej &&
93
-
94
- if test -f file2.rej
95
- then
96
- echo "file2 should not have been touched"
97
- exit 1
98
- fi
78
+ test_path_is_missing file2.rej
79
'
80
81
test_expect_success 'apply with --reject should fail but update the file' '
@@ -103,25 +83,12 @@ test_expect_success 'apply with --reject should fail but update the file' '
83
cat saved.file1 >file1 &&
84
rm -f file1.rej file2.rej file2 &&
85
106
- if git apply --reject patch.2 >rejects
107
- then
108
- echo "succeeds with --reject?"
109
- exit 1
110
- fi
111
-
112
- test -f file1 && {
113
- echo "file1 still exists?"
114
- exit 1
115
- }
86
+ test_must_fail git apply --reject patch.2 >rejects &&
87
+ test_path_is_missing file1 &&
88
test_cmp file2 expected &&
89
90
cat file2.rej &&
119
-
120
- if test -f file1.rej
121
- then
122
- echo "file2 should not have been touched"
123
- exit 1
124
- fi
91
+ test_path_is_missing file1.rej
92
93
'
94
@@ -130,25 +97,12 @@ test_expect_success 'the same test with --verbose' '
97
cat saved.file1 >file1 &&
98
rm -f file1.rej file2.rej file2 &&
99
133
- if git apply --reject --verbose patch.2 >rejects
134
- then
135
- echo "succeeds with --reject?"
136
- exit 1
137
- fi
138
-
139
- test -f file1 && {
140
- echo "file1 still exists?"
141
- exit 1
142
- }
100
+ test_must_fail git apply --reject --verbose patch.2 >rejects &&
101
+ test_path_is_missing file1 &&
102
test_cmp file2 expected &&
103
104
cat file2.rej &&
146
-
147
- if test -f file1.rej
148
- then
149
- echo "file2 should not have been touched"
150
- exit 1
151
- fi
105
+ test_path_is_missing file1.rej
106
107
'
108