. tests/lib
t-dependencies bsdgames
+t-dependencies man-db git-man
t-tstunt-parsechangelog
t-archive-none example
-v=1.0
-t-worktree $v
+t-git-none
+bv=1.0
+t-worktree $bv
-cd $p
-
-: ----- convert to "3.0 (quilt)"
-
-rm -rf .git
-tar --exclude=debian -C .. -zcf ../${p}_${v}.orig.tar.gz $p
-dch -v 1.0-1 -m convert
-mkdir -p debian/source
-echo '3.0 (quilt)' >debian/source/format
-
-v=1.0-1
-
-: ----- make everything break -----
+: ----- prepare badnesses -----
mkdir af
-addpatch () {
- pname=$1
- cat >../editor.pl <<END
- next if m/^$/..0;
- s{^(description:).*}{\$1 dgit test patch $pname}i;
- \$_='' if m/^ /;
-END
- EDITOR="perl -pi $tmp/editor.pl" dpkg-source -iX --commit . $pname
- test -f debian/patches/$pname
-}
-
badattr1 () {
local filename=$1
local attrspec=$2
printf >>af/$filename 'crlf: \r\n'
echo >>af/$filename 'id $Id: $'
echo >>af/$filename 'id $Id: SPLARK $'
- echo >>.gitattributes "af/$filename" "$attrspec"
+ echo >>gitattrs "af/$filename" "$attrspec"
}
badattr () {
badattr delta
badattr encoding no-such-encoding
-mv af ../af.aside
-addpatch gitattrs
+man gitattributes \
+| perl -ne 'print $1,"\n" if m/^ *(\w[-a-z]*)$/' \
+> grepped-attrs
-mv ../af.aside af
-addpatch files
+exec <grepped-attrs
+while read attr; do
+ badattr $attr
+done
sha256sum af/* >sums
-addpatch sums
-dpkg-source -b .
+# ----- common to source formats -----
-cd ..
-mkdir $p.import
-cd $p.import
-git init
+sfmt_setup () {
+ v=$1
+ sfmt=$2
-#t-dgit --force-import-gitapply-absurd import-dsc ../${p}_${v}.dsc +import
-t-dgit import-dsc ../${p}_${v}.dsc +import
+ pdb=$p.$sfmt
-git checkout import
+ local addpatch=${sfmt}_addpatch
+ local convert=${sfmt}_convert
-for f in af/*; do
- git cat-file blob "refs/heads/import:$f" | sha256sum | \
- sed -e 's#-$#'$f'#' \
- >>../sums
-done
+ cp -a $p $pdb-edit
+ cd $pdb-edit
+
+ $convert
+
+ dch -v $v -m convert
+
+ rm -rf .git
+
+ cp ../gitattrs .gitattributes
+ $addpatch gitattrs
+
+ cp -a ../af .
+ $addpatch files
+
+ cp ../sums .
+ $addpatch sums
+
+ dpkg-source -b .
+
+ cd ..
+}
+
+sums_check () {
+ # caller should cd into working directory, set
+ # $sums $branch
+ # and check out $branch
+
+ 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
+}
+
+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
+ fgrep 'warning: source tree 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
+ sha256sum af/* >../$sums.broken
+
+ for s in ../sums ../$sums.broken; do
+ sed 's/[0-9a-f]* //' $s >$s.nosums
+ done
+ diff -U0 ../sums.nosums ../$sums.broken.nosums
+ set +e
+ diff -U0 ../sums ../$sums.broken
+ rc=$?
+ set -e
+ test $rc = 1
+
+ t-dgit setup-new-tree
+
+ t-dgit-warn-check 1 $dgitargs import-dsc ../$dscf +$branch
+ git checkout $branch
+ git reset --hard
+
+ sums_check
+
+ cd ..
+}
+
+: ----- generate the orig -----
+
+origtar=${p}_${bv}.orig.tar.gz
+
+tar --exclude=debian --exclude=.git -zcf $origtar $p
+
+: ----- test 1.0 native -----
+
+native_addpatch () { :; }
+native_convert () { :; }
+
+sfmt_setup 1.1 native
+sfmt_import norm
+
+: ----- test 1.0 diff -----
+
+diff_addpatch () { :; }
+diff_convert () { :; }
+
+sfmt_setup 1.1 diff
+sfmt_import norm
+
+: ----- test "3.0 (quilt)" -----
+
+quilt_addpatch () {
+ pname=$1
+ cat >../editor.pl <<END
+ next if m/^$/..0;
+ s{^(description:).*}{\$1 dgit test patch $pname}i;
+ \$_='' if m/^ /;
+END
+ EDITOR="perl -pi $tmp/editor.pl" dpkg-source -iX --commit . $pname
+ test -f debian/patches/$pname
+}
+
+quilt_convert () {
+ mkdir -p debian/source
+ echo '3.0 (quilt)' >debian/source/format
+}
-diff -U0 sums ../sums
+sfmt_setup 1.0-1 quilt
+sfmt_import norm
+sfmt_import absurd --force-import-gitapply-absurd
#t-ok