Skip to content

Commit 5b062e1

Browse files
peffgitster
authored andcommitted
t5312: be more assertive about command failure
When repacking or pruning in a corrupted repository, our tests in t5312 argue that it is OK to complete the operation or bail, as long as we don't actually delete the objects pointed to by the corruption. This isn't a wrong line of reasoning, but the tests are a bit permissive by using test_might_fail. The fact is that we _do_ bail currently, and if we ever stopped doing so, that would be worthy of a human investigating. So let's switch these to test_must_fail. Signed-off-by: Jeff King <[email protected]> Reviewed-by: Jonathan Tan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 078eecb commit 5b062e1

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

t/t5312-prune-corruption.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ if we see, for example, a ref with a bogus name, it is OK either to
77
bail out or to proceed using it as a reachable tip, but it is _not_
88
OK to proceed as if it did not exist. Otherwise we might silently
99
delete objects that cannot be recovered.
10+
11+
Note that we do assert command failure in these cases, because that is
12+
what currently happens. If that changes, these tests should be revisited.
1013
'
1114
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
1215
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
@@ -35,7 +38,7 @@ test_expect_success 'create history reachable only from a bogus-named ref' '
3538
test_expect_success 'pruning does not drop bogus object' '
3639
test_when_finished "git hash-object -w -t commit saved" &&
3740
create_bogus_ref &&
38-
test_might_fail git prune --expire=now &&
41+
test_must_fail git prune --expire=now &&
3942
git cat-file -e $bogus
4043
'
4144

@@ -53,9 +56,9 @@ test_expect_success 'non-destructive repack ignores bogus name' '
5356

5457
test_expect_success 'destructive repack keeps packed object' '
5558
create_bogus_ref &&
56-
test_might_fail git repack -Ad --unpack-unreachable=now &&
59+
test_must_fail git repack -Ad --unpack-unreachable=now &&
5760
git cat-file -e $bogus &&
58-
test_might_fail git repack -ad &&
61+
test_must_fail git repack -ad &&
5962
git cat-file -e $bogus
6063
'
6164

@@ -83,7 +86,7 @@ test_expect_success 'create history with missing tip commit' '
8386

8487
test_expect_success 'pruning with a corrupted tip does not drop history' '
8588
test_when_finished "git hash-object -w -t commit saved" &&
86-
test_might_fail git prune --expire=now &&
89+
test_must_fail git prune --expire=now &&
8790
git cat-file -e $recoverable
8891
'
8992

0 commit comments

Comments
 (0)