summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2023-10-29 12:24:41 +0000
committerIan Jackson <ijackson@chiark.greenend.org.uk>2023-10-29 15:38:11 +0000
commiteb70825bf369153222437cad727fbe1521cf3acc (patch)
treef9d660a8105b475fd2c5b4e620f63a2b6bddac50 /tests
parent1755f06db54e5848292243798d1ded4f5bdd9a18 (diff)
tests: import-r1clog: new test
This lets us test various corner cases for imports. Right now it just checks that the synthetic commits importing -1 orig tarballs have the right date and author. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Diffstat (limited to 'tests')
-rwxr-xr-xtests/tests/import-r1clog68
1 files changed, 68 insertions, 0 deletions
diff --git a/tests/tests/import-r1clog b/tests/tests/import-r1clog
new file mode 100755
index 0000000..ae24d17
--- /dev/null
+++ b/tests/tests/import-r1clog
@@ -0,0 +1,68 @@
+#!/bin/bash
+set -e
+. tests/lib
+
+p=sunxi-tools
+v_upstr=1.2
+v_base=$v_upstr-2
+v_input=$v_base.~~dgittest
+
+dpkg-source -x $troot/pkg-srcs/${p}_${v_input}.dsc unmang
+
+mkdir $p
+cd $p
+git init
+cd ..
+
+perl-i-clog () {
+ perl -i "$@" debian/changelog
+}
+
+mangle-start () {
+ mang=$1
+ v="$v_base.$mang"
+ cp -al unmang $mang
+ cd $mang
+ perl-i-clog -pe 's{\~\~dgittest}{'$mang'} if $.==1'
+ cat >>debian/changelog <<'END'
+
+sunxi-tools (1.0-1) unstable; urgency=medium
+
+ * Lies for dgit testing
+
+ -- Example <example@example.org> Sat, 12 Jul 2011 20:51:56 +0100
+END
+}
+mangle-import () {
+ rm -f debian/*~
+ dpkg-source -b .
+ cd ../$p
+ t-dgit import-dsc ../${p}_${v}.dsc $mang
+ git checkout $mang
+}
+mangle-done () {
+ cd ..
+}
+
+mangle-start good
+mangle-import
+
+: ---------- 'check that if all is well we make right author line' ----------
+
+perl -ne <debian/changelog '
+ next unless m{^'$p' \('$v_upstr'-1\) }...m{^\S};
+ next unless m{^ -- (.*) (.*) ([-+]\d+)};
+ $time_t = `date -d "$2 $3" +%s`;
+ chomp $time_t;
+ $authline = "$1 $time_t $3";
+ print "author $authline\n";
+ print "committer $authline\n";
+ exit 0;
+' >../headlines-exp
+ch=$(git log -P --grep '^\[dgit import orig ' --pretty='format:%H')
+git cat-file commit $ch |
+perl -ne 'next if m/^$/..0; print if m/^(?:author|committer) /' \
+ >../headlines-got-orig
+diff ../headlines-exp ../headlines-got-orig
+
+mangle-done