This is an automated email from the git hooks/post-receive script. xguimard-guest pushed a commit to branch master in repository lemonldap-ng.
commit 205ac694412c591503794729047c3185b5d09469 Author: Xavier Guimard <x.guim...@free.fr> Date: Wed Nov 9 20:12:12 2016 +0100 Add autopkgtest tests --- debian/changelog | 1 + debian/control | 1 + debian/tests/control | 12 +++ debian/tests/lib/build-deps.d/smoke | 118 +++++++++++++++++++++ .../lib/runtime-deps-and-recommends.d/syntax.t | 104 ++++++++++++++++++ debian/tests/lib/runtime-deps.d/use.t | 76 +++++++++++++ debian/tests/runner | 32 ++++++ 7 files changed, 344 insertions(+) diff --git a/debian/changelog b/debian/changelog index bea1d57..e97d899 100644 --- a/debian/changelog +++ b/debian/changelog @@ -9,6 +9,7 @@ lemonldap-ng (1.9.6-1) UNRELEASED; urgency=medium * Update patches * Add lsb-base in fastcgi server dependencies * Replace Net::Twitter dependency by Net::OAuth + * Add autopkgtest tests -- Xavier Guimard <x.guim...@free.fr> Tue, 18 Oct 2016 11:18:26 +0200 diff --git a/debian/control b/debian/control index e34a2c7..0b33e24 100644 --- a/debian/control +++ b/debian/control @@ -2,6 +2,7 @@ Source: lemonldap-ng Maintainer: Debian Perl Group <pkg-perl-maintain...@lists.alioth.debian.org> Uploaders: Xavier Guimard <x.guim...@free.fr> Section: perl +Testsuite: autopkgtest Priority: extra Build-Depends: debhelper (>= 9), dh-systemd, diff --git a/debian/tests/control b/debian/tests/control new file mode 100644 index 0000000..a56629f --- /dev/null +++ b/debian/tests/control @@ -0,0 +1,12 @@ +#Test-Command: ./debian/tests/runner build-deps +#Depends: @, @builddeps@, pkg-perl-autopkgtest, libmouse-perl + +Test-Command: ./debian/tests/runner runtime-deps +Depends: @, pkg-perl-autopkgtest, libmouse-perl + +Test-Command: ./debian/tests/runner runtime-deps-and-recommends +Depends: @, pkg-perl-autopkgtest, libmouse-perl +Restrictions: needs-recommends + +Test-Command: ./debian/tests/runner heavy-deps +Depends: @, pkg-perl-autopkgtest, pkg-perl-autopkgtest-heavy, libmouse-perl diff --git a/debian/tests/lib/build-deps.d/smoke b/debian/tests/lib/build-deps.d/smoke new file mode 100755 index 0000000..d7b53aa --- /dev/null +++ b/debian/tests/lib/build-deps.d/smoke @@ -0,0 +1,118 @@ +#!/bin/sh +set -e + +cleanup() { + cd $PDIR + + #Clean up after smoke-setup + cleanup_file=debian/tests/pkg-perl/smoke-cleanup + if [ -x $cleanup_file ] + then + ( export TDIR; $cleanup_file ) + fi + + rm -rf $TDIR +} + +TEMP=${ADTTMP:-${TMPDIR:-/tmp}} + +TDIR=$(mktemp -d $TEMP/smokeXXXXXX) + +PDIR=`pwd` + +trap cleanup EXIT + +file_list=debian/tests/pkg-perl/smoke-files +if [ ! -r $file_list ]; then + # backward compatibility squared for now + file_list=debian/tests/pkg-perl/test-files +fi +if [ ! -r $file_list ]; then + # backward compatibility for now + file_list=debian/tests/test-files +fi + +export AUTOMATED_TESTING=1 +export NONINTERACTIVE_TESTING=1 + +# overridable with smoke-env +PKG_PERL_PROVE_ARGS="--merge" + +env_list=debian/tests/pkg-perl/smoke-env +if [ ! -r $env_list ]; then + env_list=debian/tests/pkg-perl/env-smoke +fi +if [ -r $env_list ]; then + eval $(sed '/^ *\(#\|$\)/d; s/^/export /' $env_list) +fi + +for dir in common handler portal manager; do + TMPDIR=$TMPDIR + mkdir -p $TMPDIR/blib/lib \ + $TMPDIR/blib/arch + cp -a lemonldap-ng-$dir/t $TMPDIR/ + cat <<'EOF' > $TMPDIR/lib/Debian/pkgperl/Foobar.pm +package Debian::pkgperl::Foobar; +our $VERSION = '0.01'; +1; +__END__ +=head1 NAME + +Debian::pkgperl::Foobar - dummy module for test checkers + +=cut +EOF + cp $TMPDIR/lib/Debian/pkgperl/Foobar.pm $TMPDIR/blib/lib/Debian/pkgperl + + if [ ! -e $TMPDIR/MANIFEST ]; then + cat <<'EOF' > $TMPDIR/MANIFEST +lib/Debian/pkgperl/Foobar.pm +EOF + fi + + if [ ! -e $TMPDIR/MANIFEST.SKIP ]; then + cp /dev/null $TMPDIR/MANIFEST.SKIP + fi + + # common nuisances, no value with runtime tests + rm -f $TMPDIR/t/99-pod.t + + # this is intended to be a last resort, please use it responsibly + setup_file=debian/tests/pkg-perl/smoke-setup + if [ -x $setup_file ] + then + ( export TMPDIR; $setup_file ) + + # Evaluate skip list a second time since smoke-setup might have + # generated some of the to-be-skipped files. + if [ -r $skip_list ]; then + egrep -v '^ *(#|$)' $skip_list | while read file; do + rm -f $TMPDIR/$file + done + fi + fi + + tests_file=$(pwd)/debian/tests/pkg-perl/smoke-tests + cd $TMPDIR + if [ -r $tests_file ]; then + test_targets=$(eval ls -d $(egrep -v '^#' $tests_file) 2>/dev/null || true) + fi + + if command -v xvfb-run >/dev/null + then + XVFB="xvfb-run -a" + else + XVFB= + fi + + if [ -z "$test_targets" ] && [ -d t ]; then test_targets=$(ls -d t/*.t 2>/dev/null || true); fi + + if [ ! -n "$test_targets" ]; then + echo 'Nothing to prove, skipping.' + else + $XVFB prove -I"$TMPDIR" --blib --verbose $PKG_PERL_PROVE_ARGS $test_targets 2>&1 + fi + + if [ -f test.pl ]; then $XVFB perl -I"$TMPDIR" ./test.pl; fi 2>&1 + +done diff --git a/debian/tests/lib/runtime-deps-and-recommends.d/syntax.t b/debian/tests/lib/runtime-deps-and-recommends.d/syntax.t new file mode 100755 index 0000000..5b20fde --- /dev/null +++ b/debian/tests/lib/runtime-deps-and-recommends.d/syntax.t @@ -0,0 +1,104 @@ +#!/usr/bin/perl -w +use strict; + +use Test::More; +use Getopt::Std; + +sub usage { + my $exit = shift; + $exit = 0 if !defined $exit; + print "Usage: $0 [ package ] ...\n"; + print "\tpackages are read from debian/control if not given as arguments\n"; + exit $exit; +} + +my %opts; +getopts('h', \%opts) + or usage(); + +usage(0) if $opts{h}; + +sub getpackages { + my @p; + my $c = "debian/control"; + -f $c or BAIL_OUT("no packages listed and $c not found"); + open(C, '<', $c) or BAIL_OUT("opening $c for reading failed:$!"); + while (<C>) { + chomp; + /^\s*Package:\s+(\S+)/ and push @p, $1; + } + close C or BAIL_OUT("closing $c failed: $!"); + return @p; +} + +sub readskip { + my $skip = "debian/tests/pkg-perl/syntax-skip"; + $skip = "debian/tests/pkg-perl/skip-syntax" if ! -r $skip; + -r $skip or return (); + open (S, '<', $skip) + or BAIL_OUT("$skip exists but can't be read"); + + my @ret; + while (<S>) { + chomp; + next if !/\S/; + next if /^\s*#/; + push @ret, qr/\Q$_\E/; + } + close S; + return @ret; +} + +my @packages = @ARGV ? @ARGV : getpackages(); + +usage() if !@packages; + +plan tests => 4 * scalar @packages; + +my @to_skip = readskip(); + +for my $package (@packages) { + SKIP: { + ok(!system(qq(dpkg-query --list "$package" >/dev/null 2>&1)), + "Package $package is known to dpkg"); + + skip "$package not installed", 3 if $?; + + my @status_info = qx{dpkg-query --status "$package"}; + ok(@status_info, "Got status information for package $package"); + skip "$package has Suggestions and no explicit skip list", 2 + if grep /^Suggests:/, @status_info and ! @to_skip; + + my @files = qx{dpkg-query --listfiles "$package" 2>/dev/null}; + + ok(@files, "Got file list for package $package"); + + skip "nothing to test", 1 if !@files; + + my @pms; + F: for (@files) { + chomp; + next if !/\.pm$/; + for my $skip_re (@to_skip) { + note "skipping $_", next F if /$skip_re/; + } + my $oninc = 0; + for my $incdir (@INC) { + $oninc++, last if /^\Q$incdir/; + } + next if !$oninc; + push @pms, $_; + } + + skip "no perl modules to test in $package", 1 if !@pms; + + subtest "all modules in $package pass the syntax check" => sub { + plan tests => scalar @pms; + for (@pms) { + my @out = grep !/syntax OK/, qx($^X -wc $_ 2>&1); + note(@out) if @out; + ok(!$?, "$^X -wc $_ exited successfully"); + } + } + } +} diff --git a/debian/tests/lib/runtime-deps.d/use.t b/debian/tests/lib/runtime-deps.d/use.t new file mode 100755 index 0000000..69382b4 --- /dev/null +++ b/debian/tests/lib/runtime-deps.d/use.t @@ -0,0 +1,76 @@ +#!/usr/bin/perl -w +use strict; + +use Test::More; +use Getopt::Std; +use CPAN::Meta; + +sub usage { + my $exit = shift; + $exit = 0 if !defined $exit; + print "Usage: $0 [ Some::Module] ...\n"; + print "\tthe perl module is guessed from META.{json,yml} if not given as argument\n"; + exit $exit; +} + +my %opts; +getopts('h', \%opts) + or usage(); + +usage(0) if $opts{h}; + +sub getmodule { + my $module; + my $conffile = "debian/tests/pkg-perl/use-name"; + $conffile = "debian/tests/pkg-perl/module-name" if ! -e $conffile; # backcompat + $conffile = "debian/tests/module-name" if ! -e $conffile; # backcompat squared + if ( -f $conffile ) { + open(M, "<", $conffile) + or BAIL_OUT("$conffile exists but can't be read"); + while (<M>) { + chomp; + next if /^\s*#/; + /(\S+)/ and $module = $1, last; + } + close M; + BAIL_OUT("can't find a module name in $conffile") + if !defined $module; + return $module; + } + + my $meta; + my $dist; + eval { $meta = CPAN::Meta->load_file('META.json') }; + eval { $meta = CPAN::Meta->load_file('META.yml' ) } if !$meta; + plan skip_all => "can't guess package from META.json or META.yml" + if !$meta; + + $dist = $meta->name; + + $module = $dist; + $module =~ s,-,::,g; + + my $file = "$dist.pm"; + $file =~ s,-,/,g; + + my $basefile = $file; + $basefile =~ s,.*/,,; + + ( -f $basefile ) or (-f "lib/$file") or plan skip_all => "$basefile or lib/$file not found"; + + return $module; +} + +my @modules = @ARGV ? @ARGV : getmodule(); + +usage() if !@modules; + +plan tests => 2 * scalar @modules; + +for my $mod (@modules) { + my $cmd = qq($^X -w -M"$mod" -e 1 2>&1); + my @out = qx($cmd); + note(@out) if @out; + ok(!$?, "$cmd exited successfully"); + ok(!@out, "$cmd produced no output"); +} diff --git a/debian/tests/runner b/debian/tests/runner new file mode 100755 index 0000000..7e6c9cb --- /dev/null +++ b/debian/tests/runner @@ -0,0 +1,32 @@ +#!/bin/sh + +BASE=debian/tests/lib + +TYPE=$1 +[ -n "$TYPE" ] || exit 1 + +TESTDIR=${BASE}/${TYPE}.d +[ -d "$TESTDIR" ] || exit 1 + +SKIPLIST=debian/tests/pkg-perl/SKIP +SKIPTMP=$(mktemp) +if [ -f "$SKIPLIST" ]; then + grep -v '^ *#' "$SKIPLIST" |grep -v '^ *$' > "$SKIPTMP" +fi + +EXITCODE=0 +for T in $(run-parts --list --regex '(^[a-z0-9.]+$)' ${TESTDIR} | \ + grep -v -F -f "$SKIPTMP") ; do + if echo "$T" | grep -q '\.t$' + then + prove --norc -v "$T" + RET=$? + if [ $EXITCODE = 0 ]; then EXITCODE=$RET; fi + else + "$T" + RET=$? + if [ $EXITCODE = 0 ]; then EXITCODE=$RET; fi + fi +done +rm -f "$SKIPTMP" +exit $EXITCODE -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/lemonldap-ng.git _______________________________________________ Pkg-perl-cvs-commits mailing list Pkg-perl-cvs-commits@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits