summaryrefslogtreecommitdiff
path: root/tests/tstunt
diff options
context:
space:
mode:
Diffstat (limited to 'tests/tstunt')
-rw-r--r--tests/tstunt/Dpkg/Changelog/Parse.pm71
-rwxr-xr-xtests/tstunt/debuild4
-rwxr-xr-xtests/tstunt/dpkg-parsechangelog78
-rwxr-xr-xtests/tstunt/gpg6
-rwxr-xr-xtests/tstunt/gpg-agent6
-rwxr-xr-xtests/tstunt/lintian3
6 files changed, 168 insertions, 0 deletions
diff --git a/tests/tstunt/Dpkg/Changelog/Parse.pm b/tests/tstunt/Dpkg/Changelog/Parse.pm
new file mode 100644
index 0000000..d69b7df
--- /dev/null
+++ b/tests/tstunt/Dpkg/Changelog/Parse.pm
@@ -0,0 +1,71 @@
+# -*- perl -*-
+#
+# Copyright (C) 2015-2016 Ian Jackson
+#
+# Some bits stolen from the proper Dpkg::Changelog::Parse
+# (from dpkg-dev 1.16.16):
+#
+# Copyright (C) 2005, 2007 Frank Lichtenheld <frank@lichtenheld.de>
+# Copyright (C) 2009 Raphael Hertzog <hertzog@debian.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+package Dpkg::Changelog::Parse;
+
+use strict;
+use warnings;
+
+our $VERSION = "1.00";
+
+use Dpkg::Control::Changelog;
+
+use base qw(Exporter);
+our @EXPORT = qw(changelog_parse);
+
+die +(join " ", %ENV)." ?" if $ENV{'DGIT_NO_TSTUNT_CLPARSE'};
+
+sub changelog_parse {
+ my (%options) = @_; # largely ignored
+
+#use Data::Dumper;
+#print STDERR "CLOG PARSE ", Dumper(\%options);
+#
+# We can't do this because lots of things use `since' which
+# we don't implement, and it's the test cases that arrange that
+# the since value happens to be such that we are to print one output.
+#
+# foreach my $k (keys %options) {
+# my $v = $options{$k};
+# if ($k eq 'file') { }
+# elsif ($k eq 'offset') { die "$v ?" unless $v <= 1; } # wtf, 1==0 ?
+# elsif ($k eq 'count') { die "$v ?" unless $v == 1; }
+# else { die "$k ?"; }
+# }
+
+ $options{'file'} //= 'debian/changelog';
+
+ open P, "dpkg-parsechangelog -l$options{'file'} |" or die $!;
+
+ my $fields = Dpkg::Control::Changelog->new();
+ $fields->parse(\*P, "output of stunt changelog parser");
+
+#use Data::Dumper;
+#print STDERR "PARSE $0 ", Dumper($fields);
+
+ close P or die "$! $?";
+
+ return $fields;
+}
+
+1;
diff --git a/tests/tstunt/debuild b/tests/tstunt/debuild
new file mode 100755
index 0000000..2b2ca71
--- /dev/null
+++ b/tests/tstunt/debuild
@@ -0,0 +1,4 @@
+#!/bin/bash
+set -e
+echo "DGIT TEST STUNT DEBUILD $*" >&2
+"${DGIT_TEST_REAL_DEBUILD}" --preserve-env --preserve-envvar PATH "$@"
diff --git a/tests/tstunt/dpkg-parsechangelog b/tests/tstunt/dpkg-parsechangelog
new file mode 100755
index 0000000..6a9198a
--- /dev/null
+++ b/tests/tstunt/dpkg-parsechangelog
@@ -0,0 +1,78 @@
+#!/usr/bin/perl -w
+#
+# In an example:
+#
+# $ time dpkg-parsechangelog >/dev/null
+#
+# real 0m0.712s
+# user 0m0.656s
+# sys 0m0.048s
+# $ time ~/things/Dgit/dgit/tests/tstunt/dpkg-parsechangelog >/dev/null
+#
+# real 0m0.016s
+# user 0m0.000s
+# sys 0m0.012s
+# $
+
+$SIG{__WARN__} = sub { die $_[0]; }; # no use of system, so we avoid #793471
+
+my $infile = "debian/changelog";
+
+#print STDERR ">@ARGV<\n";
+
+my @orgargv = @ARGV;
+
+if (@ARGV && $ARGV[0] =~ s/^-l//) {
+ $infile = shift @ARGV;
+}
+
+if (@ARGV) {
+ my $strip = $0;
+ $strip =~ s#/[^/]+$## or die "$0 ?";
+ foreach my $k (qw(PATH PERLLIB)) {
+ my @opath = defined $ENV{$k} ? split /\:/, $ENV{$k} : ();
+ my @npath = grep { $_ ne $strip } @opath;
+ @npath != @opath or die "$0 $k ".($ENV{$k}//"(undef)")." ?";
+ $ENV{$k} = join ':', @npath;
+ delete $ENV{$k} if !@npath;
+ }
+ die if $ENV{'DGIT_NO_TSTUNT_CLPARSE'}++;
+ exec 'dpkg-parsechangelog', @orgargv;
+}
+
+use strict;
+open C, $infile or die $!;
+
+$!=0; $_ = <C>;
+m/^(\S+) \(([^()]+)\) (\S+)\; urgency=(\S+)$/ or die "$!, $_ ?";
+print <<END or die $!;
+Source: $1
+Version: $2
+Distribution: $3
+Urgency: $4
+Changes:
+ $&
+END
+
+my $blanks = 0;
+for (;;) {
+ $!=0; $_ = <C>;
+ if (m/^ -- ([^<>]+\<\S+\>) (\w[^<>]+\w)$/) {
+ print <<END or die $!;
+Maintainer: $1
+Date: $2
+END
+ print "Timestamp: " or die $!;
+ exec qw(date +%s -d), $2; die $!;
+ } elsif (m/^ --\s*$/) {
+ last;
+ } elsif (!m/\S/) {
+ $blanks++;
+ } elsif (m/^ .*\n/) {
+ print " .\n" x $blanks or die $!;
+ $blanks=0;
+ print " $_" or die $!;
+ } else {
+ die "$!, $_ ?";
+ }
+}
diff --git a/tests/tstunt/gpg b/tests/tstunt/gpg
new file mode 100755
index 0000000..d71aa63
--- /dev/null
+++ b/tests/tstunt/gpg
@@ -0,0 +1,6 @@
+#!/bin/sh
+set -e
+exec \
+$DGIT_TEST_REAL_GPG \
+ --agent-program=$DGIT_STUNT_AGENT \
+ "$@"
diff --git a/tests/tstunt/gpg-agent b/tests/tstunt/gpg-agent
new file mode 100755
index 0000000..96ae839
--- /dev/null
+++ b/tests/tstunt/gpg-agent
@@ -0,0 +1,6 @@
+#!/bin/sh
+set -e
+exec \
+$DGIT_TEST_REAL_GPG_AGENT \
+ --debug-quick-random \
+ "$@"
diff --git a/tests/tstunt/lintian b/tests/tstunt/lintian
new file mode 100755
index 0000000..f7c2985
--- /dev/null
+++ b/tests/tstunt/lintian
@@ -0,0 +1,3 @@
+#!/bin/sh
+echo >&2 'W: dgit test suite stunt lintian detects no problems'
+exit 0