X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=tests%2Flib;h=52aca71b6e27cb5818bba3f040f1f5bef76aca19;hb=c660afba5804763cdd59811bac1915a8f2fd0904;hp=d075bc763f0d05249b233294d64dd91bc6b7c0f7;hpb=06398ebf1c535adf0aa818f8a3540fe1a0ce30b4;p=dgit.git diff --git a/tests/lib b/tests/lib index d075bc76..52aca71b 100644 --- a/tests/lib +++ b/tests/lib @@ -349,6 +349,52 @@ t-git-dir-check () { esac } +t-expect-fsck-fail () { + echo >>$tmp/fsck.expected-errors "$1" +} + +t-git-fsck () { + 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 () { + ( + shopt -s nullglob + for d in $tmp/*/.git $tmp/git/*.git; do + cd "$d" + t-git-fsck + done + ) +} + +t-ok () { + t-fscks + echo ok. +} + t-rm-dput-dropping () { rm -f $tmp/${p}_${v}_*.upload }