chiark / gitweb /
test suite: gitattributes: new test, still wip
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 14 Jan 2017 23:08:37 +0000 (23:08 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 16 Jan 2017 01:16:53 +0000 (01:16 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
debian/tests/control
tests/tests/gitattributes [new file with mode: 0755]

index 2ba4183818d004e7dd493123f6591e0086b5f637..5563a80c2d5f43d03db67b8cffbc1fc1fd90efa3 100644 (file)
@@ -11,6 +11,10 @@ Tests-Directory: tests/tests
 Depends: dgit, dgit-infrastructure, devscripts, debhelper (>=8), fakeroot, build-essential
 Restrictions: x-dgit-intree-only x-dgit-git-only
 
 Depends: dgit, dgit-infrastructure, devscripts, debhelper (>=8), fakeroot, build-essential
 Restrictions: x-dgit-intree-only x-dgit-git-only
 
+Tests: gitattributes
+Tests-Directory: tests/tests
+Depends: dgit, dgit-infrastructure, devscripts, debhelper (>=8), fakeroot, build-essential, bsdgames
+
 Tests: defdistro-mirror mirror mirror-debnewgit mirror-private
 Tests-Directory: tests/tests
 Depends: dgit, dgit-infrastructure, devscripts, debhelper (>=8), fakeroot, build-essential, rsync
 Tests: defdistro-mirror mirror mirror-debnewgit mirror-private
 Tests-Directory: tests/tests
 Depends: dgit, dgit-infrastructure, devscripts, debhelper (>=8), fakeroot, build-essential, rsync
diff --git a/tests/tests/gitattributes b/tests/tests/gitattributes
new file mode 100755 (executable)
index 0000000..0b4bad6
--- /dev/null
@@ -0,0 +1,111 @@
+#!/bin/bash
+set -e
+. tests/lib
+
+t-dependencies bsdgames
+t-tstunt-parsechangelog
+
+t-archive-none example
+v=1.0
+t-worktree $v
+
+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 -----
+
+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
+       echo >>af/$filename "Test file with $attrspec"
+       printf >>af/$filename 'crlf: \r\n'
+       echo >>af/$filename 'id $Id: $'
+       echo >>af/$filename 'id $Id: SPLARK $'
+       echo >>.gitattributes "af/$filename" "$attrspec"
+}
+
+badattr () {
+       attrname=$1; shift
+       badattr1 $attrname-set $attrname
+       badattr1 $attrname-unset -$attrname
+       badattr1 $attrname-unspec \!$attrname
+       local val
+       for val in "$@"; do
+               badattr1 $attrname=$val $attrname=$val
+       done
+}
+
+# xxx want to make each of these files into a quilt patch
+
+t-git-config core.eol crlf
+
+badattr        text auto
+badattr eol lf crlf
+badattr ident
+
+t-git-config filter.dgit-test-crazy-f.smudge '/usr/games/rot13 2'
+t-git-config filter.dgit-test-crazy-f.clean  '/usr/games/rot13 24'
+t-git-config filter.dgit-test-crazy-f.requrired true
+
+badattr filter dgit-test-crazy-f
+
+badattr diff
+badattr merge text binary union
+badattr whitespace
+badattr export-ignore
+badattr export-subst
+badattr delta
+badattr encoding no-such-encoding
+
+mv af ../af.aside
+addpatch gitattrs
+
+mv ../af.aside af
+addpatch files
+
+sha256sum af/* >sums
+addpatch sums
+
+dpkg-source -b .
+
+cd ..
+mkdir $p.import
+cd $p.import
+git init
+
+#t-dgit --force-import-gitapply-absurd import-dsc ../${p}_${v}.dsc +import
+t-dgit import-dsc ../${p}_${v}.dsc +import
+
+git checkout import
+
+for f in af/*; do
+       git cat-file blob "refs/heads/import:$f" | sha256sum | \
+               sed -e 's#-$#'$f'#' \
+               >>../sums
+done
+
+diff -U0 sums ../sums
+
+#t-ok