[PATCH v2 0/6] mktag tests: test more exhaustively
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Jun 17, 2021, 10:41 UTC
- Message-ID
- <cover-0.6-0000000000-20210617T104011Z-avarab@gmail.com>
- In-Reply-To
- <cover-0.6-00000000000-20210614T172422Z-avarab@gmail.com>
A re-roll of [1] which adds more mktag tests. Fixes the issues noted in [2] and one more that I spotted myself: I used a "$bad_tag" in an earlier commit than it was defined. I've fixed that, and changed the structure of the tests (use rev-parse to assert) to make sure it is defined before we do the "test_must_fail" tests.
1. https://lore.kernel.org/git/cover-0.6-00000000000-20210614T172422Z-avarab@gmail.com 2. https://lore.kernel.org/git/6148debe-fc44-67b7-ac9c-f27d376bc9f2@gmail.com
Ævar Arnfjörð Bjarmason (6): mktag tests: parse out options in helper mktag tests: invert --no-strict test mktag tests: test hash-object --literally and unreachable fsck mktag tests: test update-ref and reachable fsck mktag tests: test for-each-ref mktag tests: test fast-export
t/t3800-mktag.sh | 121 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 106 insertions(+), 15 deletions(-)
Range-diff against v1:
1: d49549973d = 1: d49549973d mktag tests: parse out options in helper
2: 550dcedfcb = 2: 550dcedfcb mktag tests: invert --no-strict test
3: 96520b3e89 ! 3: bab235d752 mktag tests: test hash-object --literally and unreachable fsck
@@ t/t3800-mktag.sh: check_verify_failure () {
--no-strict)
no_strict=yes
;;
-- esac &&
+ --fsck-obj-ok)
+ fsck_obj_ok=yes
+ ;;
-+ esac
+ esac &&
shift
done &&
-
@@ t/t3800-mktag.sh: check_verify_failure () {
git mktag --no-strict <tag.sig
fi
@@ t/t3800-mktag.sh: check_verify_failure () {
+ then
+ git -C bad-tag fsck
+ else
-+ test_must_fail git -C bad-tag fsck >out 2>err
++ test_must_fail git -C bad-tag fsck
+ fi
+ '
}
4: 0359becdc9 ! 4: a1d95c81ea mktag tests: test update-ref and reachable fsck
@@ t/t3800-mktag.sh: check_verify_failure () {
# Reset any leftover state from the last $subject
rm -rf bad-tag &&
+ git init --bare bad-tag &&
+- git -C bad-tag hash-object -t tag -w --stdin --literally <tag.sig
++ bad_tag=$(git -C bad-tag hash-object -t tag -w --stdin --literally <tag.sig)
+ '
+
+ test_expect_success "hash-object & fsck unreachable: $subject" '
@@ t/t3800-mktag.sh: check_verify_failure () {
- test_must_fail git -C bad-tag fsck >out 2>err
+ test_must_fail git -C bad-tag fsck
fi
'
+
+ test_expect_success "update-ref & fsck reachable: $subject" '
++ # Make sure the earlier test created it for us
++ git rev-parse "$bad_tag" &&
++
+ # The update-ref of the bad content will fail, do it
+ # anyway to see if it segfaults
+ test_might_fail git -C bad-tag update-ref "$tag_ref" "$bad_tag" &&
5: 8a626fc63a ! 5: f4c41be92d mktag tests: test for-each-ref
@@ Commit message
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
## t/t3800-mktag.sh ##
-@@ t/t3800-mktag.sh: check_verify_failure () {
- rm -rf bad-tag &&
-
- git init --bare bad-tag &&
-- git -C bad-tag hash-object -t tag -w --stdin --literally <tag.sig
-+ bad_tag=$(git -C bad-tag hash-object -t tag -w --stdin --literally <tag.sig)
- '
-
- test_expect_success "hash-object & fsck unreachable: $subject" '
@@ t/t3800-mktag.sh: check_verify_failure () {
# will always fail.
test_must_fail git -C bad-tag fsck
'
+
+ test_expect_success "for-each-ref: $subject" '
++ # Make sure the earlier test created it for us
++ git rev-parse "$bad_tag" &&
++
+ echo "$bad_tag" >"bad-tag/$tag_ref" &&
+
+ printf "%s tag\t%s\n" "$bad_tag" "$tag_ref" >expected &&
6: 6d613d88ac ! 6: 797c8d3a87 mktag tests: test fast-export
@@ t/t3800-mktag.sh: check_verify_failure () {
'
+
+ test_expect_success "fast-export & fast-import: $subject" '
++ # Make sure the earlier test created it for us
++ git rev-parse "$bad_tag" &&
++
+ test_must_fail git -C bad-tag fast-export --all &&
-+ test_must_fail git -C bad-tag fast-export $bad_tag
++ test_must_fail git -C bad-tag fast-export "$bad_tag"
+ '
}
-- 2.32.0.571.gdba276db2c