Skip to content

Commit c6b7c7f

Browse files
artagnongitster
authored andcommitted
t3510 (cherry-pick-sequencer): use exit status
All the tests asserting failure use 'test_must_fail', which simply checks for a non-zero exit status, potentially hiding underlying bugs. So, replace instances of 'test_must_fail' with 'test_expect_code' to check the exit status explicitly, where appropriate. Reviewed-by: Jonathan Nieder <[email protected]> Signed-off-by: Ramkumar Ramachandra <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9e13136 commit c6b7c7f

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

t/t3510-cherry-pick-sequence.sh

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ test_expect_success setup '
4646

4747
test_expect_success 'cherry-pick persists data on failure' '
4848
pristine_detach initial &&
49-
test_must_fail git cherry-pick -s base..anotherpick &&
49+
test_expect_code 1 git cherry-pick -s base..anotherpick &&
5050
test_path_is_dir .git/sequencer &&
5151
test_path_is_file .git/sequencer/head &&
5252
test_path_is_file .git/sequencer/todo &&
@@ -67,7 +67,7 @@ test_expect_success 'cherry-pick mid-cherry-pick-sequence' '
6767

6868
test_expect_success 'cherry-pick persists opts correctly' '
6969
pristine_detach initial &&
70-
test_must_fail git cherry-pick -s -m 1 --strategy=recursive -X patience -X ours base..anotherpick &&
70+
test_expect_code 128 git cherry-pick -s -m 1 --strategy=recursive -X patience -X ours base..anotherpick &&
7171
test_path_is_dir .git/sequencer &&
7272
test_path_is_file .git/sequencer/head &&
7373
test_path_is_file .git/sequencer/todo &&
@@ -107,7 +107,7 @@ test_expect_success '--abort requires cherry-pick in progress' '
107107

108108
test_expect_success '--quit cleans up sequencer state' '
109109
pristine_detach initial &&
110-
test_must_fail git cherry-pick base..picked &&
110+
test_expect_code 1 git cherry-pick base..picked &&
111111
git cherry-pick --quit &&
112112
test_path_is_missing .git/sequencer
113113
'
@@ -121,7 +121,7 @@ test_expect_success '--quit keeps HEAD and conflicted index intact' '
121121
:000000 100644 OBJID OBJID A foo
122122
:000000 100644 OBJID OBJID A unrelated
123123
EOF
124-
test_must_fail git cherry-pick base..picked &&
124+
test_expect_code 1 git cherry-pick base..picked &&
125125
git cherry-pick --quit &&
126126
test_path_is_missing .git/sequencer &&
127127
test_must_fail git update-index --refresh &&
@@ -135,7 +135,7 @@ test_expect_success '--quit keeps HEAD and conflicted index intact' '
135135

136136
test_expect_success '--abort to cancel multiple cherry-pick' '
137137
pristine_detach initial &&
138-
test_must_fail git cherry-pick base..anotherpick &&
138+
test_expect_code 1 git cherry-pick base..anotherpick &&
139139
git cherry-pick --abort &&
140140
test_path_is_missing .git/sequencer &&
141141
test_cmp_rev initial HEAD &&
@@ -145,7 +145,7 @@ test_expect_success '--abort to cancel multiple cherry-pick' '
145145

146146
test_expect_success '--abort to cancel single cherry-pick' '
147147
pristine_detach initial &&
148-
test_must_fail git cherry-pick picked &&
148+
test_expect_code 1 git cherry-pick picked &&
149149
git cherry-pick --abort &&
150150
test_path_is_missing .git/sequencer &&
151151
test_cmp_rev initial HEAD &&
@@ -155,7 +155,7 @@ test_expect_success '--abort to cancel single cherry-pick' '
155155

156156
test_expect_success 'cherry-pick --abort to cancel multiple revert' '
157157
pristine_detach anotherpick &&
158-
test_must_fail git revert base..picked &&
158+
test_expect_code 1 git revert base..picked &&
159159
git cherry-pick --abort &&
160160
test_path_is_missing .git/sequencer &&
161161
test_cmp_rev anotherpick HEAD &&
@@ -165,15 +165,15 @@ test_expect_success 'cherry-pick --abort to cancel multiple revert' '
165165

166166
test_expect_success 'revert --abort works, too' '
167167
pristine_detach anotherpick &&
168-
test_must_fail git revert base..picked &&
168+
test_expect_code 1 git revert base..picked &&
169169
git revert --abort &&
170170
test_path_is_missing .git/sequencer &&
171171
test_cmp_rev anotherpick HEAD
172172
'
173173

174174
test_expect_success '--abort to cancel single revert' '
175175
pristine_detach anotherpick &&
176-
test_must_fail git revert picked &&
176+
test_expect_code 1 git revert picked &&
177177
git revert --abort &&
178178
test_path_is_missing .git/sequencer &&
179179
test_cmp_rev anotherpick HEAD &&
@@ -184,7 +184,7 @@ test_expect_success '--abort to cancel single revert' '
184184
test_expect_success '--abort keeps unrelated change, easy case' '
185185
pristine_detach unrelatedpick &&
186186
echo changed >expect &&
187-
test_must_fail git cherry-pick picked..yetanotherpick &&
187+
test_expect_code 1 git cherry-pick picked..yetanotherpick &&
188188
echo changed >unrelated &&
189189
git cherry-pick --abort &&
190190
test_cmp expect unrelated
@@ -193,7 +193,7 @@ test_expect_success '--abort keeps unrelated change, easy case' '
193193
test_expect_success '--abort refuses to clobber unrelated change, harder case' '
194194
pristine_detach initial &&
195195
echo changed >expect &&
196-
test_must_fail git cherry-pick base..anotherpick &&
196+
test_expect_code 1 git cherry-pick base..anotherpick &&
197197
echo changed >unrelated &&
198198
test_must_fail git cherry-pick --abort &&
199199
test_cmp expect unrelated &&
@@ -208,7 +208,7 @@ test_expect_success '--abort refuses to clobber unrelated change, harder case' '
208208

209209
test_expect_success 'cherry-pick still writes sequencer state when one commit is left' '
210210
pristine_detach initial &&
211-
test_must_fail git cherry-pick base..picked &&
211+
test_expect_code 1 git cherry-pick base..picked &&
212212
test_path_is_dir .git/sequencer &&
213213
echo "resolved" >foo &&
214214
git add foo &&
@@ -232,7 +232,7 @@ test_expect_success 'cherry-pick still writes sequencer state when one commit is
232232

233233
test_expect_success '--abort after last commit in sequence' '
234234
pristine_detach initial &&
235-
test_must_fail git cherry-pick base..picked &&
235+
test_expect_code 1 git cherry-pick base..picked &&
236236
git cherry-pick --abort &&
237237
test_path_is_missing .git/sequencer &&
238238
test_cmp_rev initial HEAD &&
@@ -242,22 +242,22 @@ test_expect_success '--abort after last commit in sequence' '
242242

243243
test_expect_success 'cherry-pick does not implicitly stomp an existing operation' '
244244
pristine_detach initial &&
245-
test_must_fail git cherry-pick base..anotherpick &&
245+
test_expect_code 1 git cherry-pick base..anotherpick &&
246246
test-chmtime -v +0 .git/sequencer >expect &&
247-
test_must_fail git cherry-pick unrelatedpick &&
247+
test_expect_code 128 git cherry-pick unrelatedpick &&
248248
test-chmtime -v +0 .git/sequencer >actual &&
249249
test_cmp expect actual
250250
'
251251

252252
test_expect_success '--continue complains when no cherry-pick is in progress' '
253253
pristine_detach initial &&
254-
test_must_fail git cherry-pick --continue
254+
test_expect_code 128 git cherry-pick --continue
255255
'
256256

257257
test_expect_success '--continue complains when there are unresolved conflicts' '
258258
pristine_detach initial &&
259-
test_must_fail git cherry-pick base..anotherpick &&
260-
test_must_fail git cherry-pick --continue
259+
test_expect_code 1 git cherry-pick base..anotherpick &&
260+
test_expect_code 128 git cherry-pick --continue
261261
'
262262

263263
test_expect_success '--continue of single cherry-pick' '
@@ -321,7 +321,7 @@ test_expect_success '--continue after resolving conflicts' '
321321

322322
test_expect_success '--continue after resolving conflicts and committing' '
323323
pristine_detach initial &&
324-
test_must_fail git cherry-pick base..anotherpick &&
324+
test_expect_code 1 git cherry-pick base..anotherpick &&
325325
echo "c" >foo &&
326326
git add foo &&
327327
git commit &&
@@ -371,7 +371,7 @@ test_expect_success 'follow advice and skip nil patch' '
371371

372372
test_expect_success '--continue respects opts' '
373373
pristine_detach initial &&
374-
test_must_fail git cherry-pick -x base..anotherpick &&
374+
test_expect_code 1 git cherry-pick -x base..anotherpick &&
375375
echo "c" >foo &&
376376
git add foo &&
377377
git commit &&
@@ -412,7 +412,7 @@ test_expect_success '--continue respects -x in first commit in multi-pick' '
412412

413413
test_expect_success '--signoff is not automatically propagated to resolved conflict' '
414414
pristine_detach initial &&
415-
test_must_fail git cherry-pick --signoff base..anotherpick &&
415+
test_expect_code 1 git cherry-pick --signoff base..anotherpick &&
416416
echo "c" >foo &&
417417
git add foo &&
418418
git commit &&
@@ -456,24 +456,24 @@ test_expect_success 'sign-off needs to be reaffirmed after conflict resolution,
456456

457457
test_expect_success 'malformed instruction sheet 1' '
458458
pristine_detach initial &&
459-
test_must_fail git cherry-pick base..anotherpick &&
459+
test_expect_code 1 git cherry-pick base..anotherpick &&
460460
echo "resolved" >foo &&
461461
git add foo &&
462462
git commit &&
463463
sed "s/pick /pick/" .git/sequencer/todo >new_sheet &&
464464
cp new_sheet .git/sequencer/todo &&
465-
test_must_fail git cherry-pick --continue
465+
test_expect_code 128 git cherry-pick --continue
466466
'
467467

468468
test_expect_success 'malformed instruction sheet 2' '
469469
pristine_detach initial &&
470-
test_must_fail git cherry-pick base..anotherpick &&
470+
test_expect_code 1 git cherry-pick base..anotherpick &&
471471
echo "resolved" >foo &&
472472
git add foo &&
473473
git commit &&
474474
sed "s/pick/revert/" .git/sequencer/todo >new_sheet &&
475475
cp new_sheet .git/sequencer/todo &&
476-
test_must_fail git cherry-pick --continue
476+
test_expect_code 128 git cherry-pick --continue
477477
'
478478

479479
test_expect_success 'empty commit set' '
@@ -483,18 +483,18 @@ test_expect_success 'empty commit set' '
483483

484484
test_expect_success 'malformed instruction sheet 3' '
485485
pristine_detach initial &&
486-
test_must_fail git cherry-pick base..anotherpick &&
486+
test_expect_code 1 git cherry-pick base..anotherpick &&
487487
echo "resolved" >foo &&
488488
git add foo &&
489489
git commit &&
490490
sed "s/pick \([0-9a-f]*\)/pick $_r10/" .git/sequencer/todo >new_sheet &&
491491
cp new_sheet .git/sequencer/todo &&
492-
test_must_fail git cherry-pick --continue
492+
test_expect_code 128 git cherry-pick --continue
493493
'
494494

495495
test_expect_success 'instruction sheet, fat-fingers version' '
496496
pristine_detach initial &&
497-
test_must_fail git cherry-pick base..anotherpick &&
497+
test_expect_code 1 git cherry-pick base..anotherpick &&
498498
echo "c" >foo &&
499499
git add foo &&
500500
git commit &&
@@ -505,7 +505,7 @@ test_expect_success 'instruction sheet, fat-fingers version' '
505505

506506
test_expect_success 'commit descriptions in insn sheet are optional' '
507507
pristine_detach initial &&
508-
test_must_fail git cherry-pick base..anotherpick &&
508+
test_expect_code 1 git cherry-pick base..anotherpick &&
509509
echo "c" >foo &&
510510
git add foo &&
511511
git commit &&

0 commit comments

Comments
 (0)