chiark / gitweb /
Test suite: lib-import-chk: Break out from import-nonnative
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 7 Nov 2016 23:52:23 +0000 (23:52 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 7 Nov 2016 23:55:40 +0000 (23:55 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
tests/lib-import-chk [new file with mode: 0644]
tests/tests/import-nonnative

diff --git a/tests/lib-import-chk b/tests/lib-import-chk
new file mode 100644 (file)
index 0000000..ee33cbe
--- /dev/null
@@ -0,0 +1,84 @@
+
+t-import-chk1 () {
+       p=$1
+       v=$2
+
+       t-archive $p $v
+}
+t-import-chk2() {
+       t-git-none
+       rm -rf $p
+       t-dgit --no-rm-on-error clone $p
+
+       # And now we make an update using the same orig tarball, and
+       # check that the orig import is stable.
+
+       cd $p
+
+       git branch first-import
+
+       m='Commit for import check'
+       echo "$m" >>import-check
+
+       v=${v%-*}-99
+       dch -v $v -D unstable -m "$m"
+
+       git add import-check debian/changelog
+       git commit -m "$m"
+
+       t-dgit -wgf quilt-fixup
+       t-dgit -wgf build-source
+
+       # The resulting .dsc does not have a Dgit line (because dgit push
+       # puts that in).  So we just shove it in the archive now
+
+       ln ../${p}_${v}.* $tmp/mirror/pool/main/
+       t-archive-query
+
+       t-dgit fetch
+
+       git branch first-2nd-import remotes/dgit/dgit/sid
+
+       t-git-next-date
+
+       git update-ref refs/remotes/dgit/dgit/sid first-import
+
+       t-dgit fetch
+
+       t-refs-same-start
+       t-ref-same refs/remotes/dgit/dgit/sid
+       t-ref-same refs/heads/first-2nd-import
+
+       for orig in ../${p}_${v%-*}.orig*.tar.*; do
+               tar -atf $orig | LC_ALL=C sort >../files.o
+               pfx=$(perl <../files.o -ne '
+                       while (<>) {
+                               m#^([^/]+/)# or exit 0;
+                               $x //= $1;
+                               $x eq $1 or exit 0;
+                       }
+                       print "$x\n";
+               ')
+               perl -i~ -pe '
+                       s#^\Q'"$pfx"'\E##;
+                       $_="" if m/^$/ || m#/$# || m#^\.git/#;
+               ' ../files.o
+               orig=${orig#../}
+               pat="^Import ${orig//./\\.}\$"
+               t-refs-same-start
+               for start in first-import first-2nd-import; do
+                       git log --pretty='tformat:%H' --grep "$pat" $start \
+                               >../t.imp
+                       test $(wc -l <../t.imp) = 1
+                       imp=$(cat ../t.imp)
+                       t-ref-same-val "$orig $start" "$imp"
+               done
+               git ls-tree -r --name-only "$t_ref_val:" \
+                       | sort >../files.g
+               diff ../files.{o,g}
+       done
+       cd ..
+}
+
+t-import-chk() { t-import-chk1 "$@"; t-import-chk2; }
+
index b8cbf255057e5f1603b7ace4f6ebe22b9b6d8f9a..fa9b74b4a80e75be0bd8820c4ddda6ac16167d10 100755 (executable)
 #!/bin/bash
 set -e
 . tests/lib
+. $troot/lib-import-chk
 
 t-tstunt-parsechangelog
 
-chk1 () {
-       p=$1
-       v=$2
-
-       t-archive $p $v
-}
-chk2() {
-       t-git-none
-       rm -rf $p
-       t-dgit --no-rm-on-error clone $p
-
-       # And now we make an update using the same orig tarball, and
-       # check that the orig import is stable.
-
-       cd $p
-
-       git branch first-import
-
-       m='Commit for import check'
-       echo "$m" >>import-check
-
-       v=${v%-*}-99
-       dch -v $v -D unstable -m "$m"
-
-       git add import-check debian/changelog
-       git commit -m "$m"
-
-       t-dgit -wgf quilt-fixup
-       t-dgit -wgf build-source
-
-       # The resulting .dsc does not have a Dgit line (because dgit push
-       # puts that in).  So we just shove it in the archive now
-
-       ln ../${p}_${v}.* $tmp/mirror/pool/main/
-       t-archive-query
-
-       t-dgit fetch
-
-       git branch first-2nd-import remotes/dgit/dgit/sid
-
-       t-git-next-date
-
-       git update-ref refs/remotes/dgit/dgit/sid first-import
-
-       t-dgit fetch
-
-       t-refs-same-start
-       t-ref-same refs/remotes/dgit/dgit/sid
-       t-ref-same refs/heads/first-2nd-import
-
-       for orig in ../${p}_${v%-*}.orig*.tar.*; do
-               tar -atf $orig | LC_ALL=C sort >../files.o
-               pfx=$(perl <../files.o -ne '
-                       while (<>) {
-                               m#^([^/]+/)# or exit 0;
-                               $x //= $1;
-                               $x eq $1 or exit 0;
-                       }
-                       print "$x\n";
-               ')
-               perl -i~ -pe '
-                       s#^\Q'"$pfx"'\E##;
-                       $_="" if m/^$/ || m#/$# || m#^\.git/#;
-               ' ../files.o
-               orig=${orig#../}
-               pat="^Import ${orig//./\\.}\$"
-               t-refs-same-start
-               for start in first-import first-2nd-import; do
-                       git log --pretty='tformat:%H' --grep "$pat" $start \
-                               >../t.imp
-                       test $(wc -l <../t.imp) = 1
-                       imp=$(cat ../t.imp)
-                       t-ref-same-val "$orig $start" "$imp"
-               done
-               git ls-tree -r --name-only "$t_ref_val:" \
-                       | sort >../files.g
-               diff ../files.{o,g}
-       done
-       cd ..
-}
-
-chk() { chk1 "$@"; chk2; }
-
 # 1.0 with diff
-chk pari-extra 3-1
+t-import-chk pari-extra 3-1
 
 # 3.0 (quilt), multiple patches, multiple origs
-chk example 1.0-1
+t-import-chk example 1.0-1
 
 # 3.0 (quilt), single-debian-patch, one orig
-chk sunxi-tools 1.2-2.~~dgittest
+t-import-chk sunxi-tools 1.2-2.~~dgittest
 
 mangle1 () {
        rm -f ${1}_*
-       chk1 "$@"
+       t-import-chk1 "$@"
        cd $tmp/mirror/pool/main
        dpkg-source -x ${p}_${v}.dsc td
        orig=${p}_${v%-*}.orig.tar.gz
@@ -116,7 +34,7 @@ mangle2 () {
        cd $tmp
        t-archive-none $p
        t-archive-query
-       chk2
+       t-import-chk2
 }
 
 # 3.0 (quilt), multiple patches, tarbomb orig