X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=dgit.git;a=blobdiff_plain;f=tests%2Flib;h=cf7d4cfb008fd3a3f87a60d4e67f02a45fc635c5;hp=fb9ee38b4ab113e27268a3391ec4bd14ba04d35f;hb=030ae37385ca7cb5d3ad6a05ecf381df15c49867;hpb=e3d689abb4446aa168d150d2832fe9fd76933dcc diff --git a/tests/lib b/tests/lib index fb9ee38b..cf7d4cfb 100644 --- a/tests/lib +++ b/tests/lib @@ -349,8 +349,35 @@ t-git-dir-check () { esac } +t-expect-fsck-fail () { + echo >>$tmp/fsck.expected-errors "$1" +} + t-git-fsck () { - git fsck --no-dangling --strict || ${expect_fsck_fail:+true} false + set +e + LC_MESSAGES=C git fsck --no-dangling --strict 2>&1 \ + | tee dgit-test-fsck.errs + ps="${PIPESTATUS[*]}" + set -e + + local pats + if [ -f $tmp/fsck.expected-errors ]; then + pats=(-w -f $tmp/fsck.expected-errors) + else + test "$ps" = "0 0" + fi + pats+=(-e 'notice: HEAD points to an unborn branch') + pats+=(-e 'notice: No default references') + + set +e + grep -v "${pats[@]}" dgit-test-fsck.errs + rc=$? + set -e + case $rc in + 1) ;; # no unexpected errors + 0) fail "unexpected messages from git-fsck" ;; + *) fail "grep of git-fsck failed" ;; + esac } t-fscks () { @@ -871,6 +898,15 @@ t-gbp-example-prep () { remotes/dgit/dgit/sid } +t-make-badcommit () { + badcommit=$( + git cat-file commit HEAD | \ + perl -pe 's/^committer.*\n//' | \ + git hash-object -w -t commit --stdin + ) + t-expect-fsck-fail $badcommit +} + t-commit () { local msg=$1 v=${2:-${majorv:-1}.$revision}