X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=tests%2Ftests%2Fgitattributes;h=9e1c246a476cf400c95b76af163663ef1c5938ca;hb=98f0b776adea78bc0f4c379a8e956a3cb69046ae;hp=fd3faa35899acc3e43bd5870ee5b7e7c4773150e;hpb=606993b2249c69f0a3b6ee95c4cf42dc97c99e83;p=dgit.git diff --git a/tests/tests/gitattributes b/tests/tests/gitattributes index fd3faa35..9e1c246a 100755 --- a/tests/tests/gitattributes +++ b/tests/tests/gitattributes @@ -103,23 +103,29 @@ sfmt_setup () { cd .. } -sfmt_import () { - inst=$1 - dgitargs=$2 - branch="import.$sfmt-$inst" - brkerr=stderr.$sfmt-$inst.broken - dscf=${p}_${v}.dsc - sums=sums.$sfmt-$inst +sums_check () { + # caller should cd into working directory, set + # $sums $branch + # and check out $branch - mkdir $pdb-import-$inst - cd $pdb-import-$inst - git init + sha256sum af/* >../$sums.checkout + diff -U0 ../sums ../$sums.checkout + + for f in af/*; do + git cat-file blob "refs/heads/$branch:$f" \ + | sha256sum \ + | sed -e 's#-$#'$f'#' \ + >>../$sums + done + + diff -U0 ../sums ../$sums +} + +sums_check_broken () { + # caller should cd into working directory, set + # $sums + # and check out the broken branch - LC_MESSAGES=C \ - t-dgit $dgitargs import-dsc ../$dscf +$branch.broken \ - 2>&1 |tee ../$brkerr - fgrep 'warning: source tree contains .gitattributes' ../$brkerr - git checkout $branch.broken sha256sum af/* >../$sums.broken for s in ../sums ../$sums.broken; do @@ -131,21 +137,53 @@ sfmt_import () { rc=$? set -e test $rc = 1 +} + +t-dgit-warn-check () { + local warnok=$1; shift + # warnok should be 0 if the warning is expected + # 1 if the warning is NOT expected + + local err=stderr.$wd + + LC_MESSAGES=C t-dgit "$@" 2>&1 |tee ../$err + + set +e + egrep 'warning: .* contains \.gitattributes' ../$err + rc=$? + set -e + + test "$rc" = "$warnok" +} + +sfmt_import () { + inst=$1 + dgitargs=$2 + branch="import.$sfmt-$inst" + dscf=${p}_${v}.dsc + sums=sums.$sfmt-$inst + wd=$pdb-import-$inst + + mkdir $wd + cd $wd + git init + + t-dgit-warn-check 0 $dgitargs import-dsc ../$dscf +$branch.broken + + git checkout $branch.broken + + sums_check_broken t-dgit setup-new-tree - t-dgit $dgitargs import-dsc ../$dscf +$branch + t-dgit-warn-check 1 $dgitargs import-dsc ../$dscf +$branch git checkout $branch + touch af/* + git reset --hard - for f in af/*; do - git cat-file blob "refs/heads/$branch:$f" \ - | sha256sum \ - | sed -e 's#-$#'$f'#' \ - >>../$sums - done + sums_check cd .. - diff -U0 sums $sums } : ----- generate the orig ----- @@ -192,4 +230,27 @@ sfmt_setup 1.0-1 quilt sfmt_import norm sfmt_import absurd --force-import-gitapply-absurd -#t-ok +: ----- 'test clone (with "3.0 (quilt)")' ----- + +mv $origtar ${dscf%.dsc}.* $tmp/mirror/pool/main/ +t-archive-query sid + +t-dgit-warn-check 0 -cdgit.default.setup-gitattributes=false \ + clone $p sid $p.clone.broken +cd $p.clone.broken + +sums=$p.clone.broken +sums_check_broken + +cd .. + +t-dgit-warn-check 1 clone $p sid $p.clone + +cd $p.clone +sums=sums.clone +branch=dgit/sid +sums_check + +cd .. + +t-ok