Skip to content

Commit e7d053d

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2f69de5 commit e7d053d

File tree

1 file changed

+10
-56
lines changed

1 file changed

+10
-56
lines changed

t/t4117-apply-reject.sh

Lines changed: 10 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,13 @@ test_expect_success 'apply --reject is incompatible with --3way' '
5656

5757
test_expect_success 'apply without --reject should fail' '
5858
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 &&
6560
test_cmp file1 saved.file1
6661
'
6762

6863
test_expect_success 'apply without --reject should fail' '
6964
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 &&
7666
test_cmp file1 saved.file1
7767
'
7868

@@ -81,47 +71,24 @@ test_expect_success 'apply with --reject should fail but update the file' '
8171
cat saved.file1 >file1 &&
8272
rm -f file1.rej file2.rej &&
8373
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 &&
9075
test_cmp file1 expected &&
9176
9277
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
9979
'
10080

10181
test_expect_success 'apply with --reject should fail but update the file' '
10282
10383
cat saved.file1 >file1 &&
10484
rm -f file1.rej file2.rej file2 &&
10585
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 &&
11688
test_cmp file2 expected &&
11789
11890
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
12592
12693
'
12794

@@ -130,25 +97,12 @@ test_expect_success 'the same test with --verbose' '
13097
cat saved.file1 >file1 &&
13198
rm -f file1.rej file2.rej file2 &&
13299
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 &&
143102
test_cmp file2 expected &&
144103
145104
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
152106
153107
'
154108

0 commit comments

Comments
 (0)