Skip to content

Commit d43eba0

Browse files
newrengitster
authored andcommitted
t6036: prefer test_when_finished to manual cleanup in following test
Manually cleaning up from former tests in subsequent ones breaks the ability to select which tests we want to run. Use test_when_finished to avoid this problem. Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6ac767e commit d43eba0

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

t/t6036-recursive-corner-cases.sh

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@ test_description='recursive merge corner cases involving criss-cross merges'
44

55
. ./test-lib.sh
66

7-
get_clean_checkout () {
8-
git reset --hard &&
9-
git clean -fdqx &&
10-
git checkout "$1"
11-
}
12-
137
#
148
# L1 L2
159
# o---o
@@ -445,10 +439,12 @@ test_expect_success 'setup differently handled merges of directory/file conflict
445439
'
446440

447441
test_expect_success 'merge of D & E1 fails but has appropriate contents' '
442+
test_when_finished "git -C directory-file reset --hard" &&
443+
test_when_finished "git -C directory-file clean -fdqx" &&
448444
(
449445
cd directory-file &&
450446
451-
get_clean_checkout D^0 &&
447+
git checkout D^0 &&
452448
453449
test_must_fail git merge -s recursive E1^0 &&
454450
@@ -468,10 +464,12 @@ test_expect_success 'merge of D & E1 fails but has appropriate contents' '
468464
'
469465

470466
test_expect_success 'merge of E1 & D fails but has appropriate contents' '
467+
test_when_finished "git -C directory-file reset --hard" &&
468+
test_when_finished "git -C directory-file clean -fdqx" &&
471469
(
472470
cd directory-file &&
473471
474-
get_clean_checkout E1^0 &&
472+
git checkout E1^0 &&
475473
476474
test_must_fail git merge -s recursive D^0 &&
477475
@@ -491,10 +489,12 @@ test_expect_success 'merge of E1 & D fails but has appropriate contents' '
491489
'
492490

493491
test_expect_success 'merge of D & E2 fails but has appropriate contents' '
492+
test_when_finished "git -C directory-file reset --hard" &&
493+
test_when_finished "git -C directory-file clean -fdqx" &&
494494
(
495495
cd directory-file &&
496496
497-
get_clean_checkout D^0 &&
497+
git checkout D^0 &&
498498
499499
test_must_fail git merge -s recursive E2^0 &&
500500
@@ -516,10 +516,12 @@ test_expect_success 'merge of D & E2 fails but has appropriate contents' '
516516
'
517517

518518
test_expect_success 'merge of E2 & D fails but has appropriate contents' '
519+
test_when_finished "git -C directory-file reset --hard" &&
520+
test_when_finished "git -C directory-file clean -fdqx" &&
519521
(
520522
cd directory-file &&
521523
522-
get_clean_checkout E2^0 &&
524+
git checkout E2^0 &&
523525
524526
test_must_fail git merge -s recursive D^0 &&
525527

0 commit comments

Comments
 (0)