Re: [PATCH v3] Test fsck a bit harder
- From
Johannes Sixt <j6t@kdbg.org>
- Date
- Feb 20, 2009, 20:29 UTC
- Message-ID
- <499F12BF.4080405@kdbg.org>
- In-Reply-To
- <effac809336c1e05613eed315483ec32f3a4c75b.1235158438.git.trast@student.ethz.ch>
Thomas Rast schrieb:
Show 5 quoted lines
> +test_expect_success 'object with bad sha1' ' > + sha=$(echo blob | git hash-object -w --stdin) && > + echo $sha && > + old=$(echo $sha | sed "s+^..+&/+") && > + new=$(dirname $old)/ffffffffffffffffffffffffffffffffffffff &&
new=${old%/*}/ffffffffffffffffffffffffffffffffffffff &&> + sha="$(dirname $new)$(basename $new)"
sha=${new%/*}${new##*/} &¬e the '&&'!
Show 6 quoted lines
> + mv .git/objects/$old .git/objects/$new && > + git update-index --add --cacheinfo 100644 $sha foo && > + tree=$(git write-tree) && > + cmt=$(echo bogus | git commit-tree $tree) && > + git update-ref refs/heads/bogus $cmt && > + (git fsck 2>out; true) &&
Any particular reason not to use
test_must_fail git fsck 2>out &&
here?
Show 5 quoted lines
> + grep "$sha.*corrupt" out && > + rm -f .git/objects/$new && > + git update-ref -d refs/heads/bogus && > + git read-tree -u --reset HEAD > +'
Shouldn't the cleanup be outside the test_expect_success so that later tests work even if this one fails? (Ditto for subsequent tests.)
> +test_expect_success 'tag pointing to nonexistent' ' > + tag=$(git hash-object -t tag -w --stdin < invalid-tag) && > + echo $tag > .git/refs/tags/invalid && > + git fsck 2>&1 | tee out &&
test_must_fail git fsck > out 2>&1 &&
> + grep "missing commit ffffffffffffffffffffffffffffffffffffffff" out &&
...
> +test_expect_success 'tag pointing to something else than its type' ' > + tag=$(git hash-object -t tag -w --stdin < wrong-tag) && > + echo $tag > .git/refs/tags/wrong && > + git fsck 2>&1 | tee out &&
test_must_fail git fsck > out 2>&1 &&
> + grep "Object.*is a blob, not a commit" out &&
...
-- Hannes