parent
10ed38bd3a
commit
841c5ba504
@ -1,143 +0,0 @@ |
||||
#!/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="--verbose --recurse --merge" |
||||
PKG_PERL_XVFB_ARGS="-a" |
||||
|
||||
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 |
||||
TDIR2=${TDIR}/lemonldap-ng-$dir |
||||
mkdir -p $TDIR2/blib/lib \ |
||||
$TDIR2/blib/arch \ |
||||
$TDIR2/lib/Debian/pkgperl \ |
||||
$TDIR2/blib/lib/Debian/pkgperl |
||||
cp -a lemonldap-ng-$dir/t $TDIR2/ |
||||
if [ -d lemonldap-ng-$dir/site ]; then |
||||
cp -a lemonldap-ng-$dir/site $TDIR2/ |
||||
fi |
||||
cat <<'EOF' > $TDIR2/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 $TDIR2/lib/Debian/pkgperl/Foobar.pm $TDIR2/blib/lib/Debian/pkgperl |
||||
|
||||
if [ ! -e $TDIR2/MANIFEST ]; then |
||||
cat <<'EOF' > $TDIR2/MANIFEST |
||||
lib/Debian/pkgperl/Foobar.pm |
||||
EOF |
||||
fi |
||||
|
||||
if [ ! -e $TDIR2/MANIFEST.SKIP ]; then |
||||
cp /dev/null $TDIR2/MANIFEST.SKIP |
||||
fi |
||||
done |
||||
|
||||
# Missing file |
||||
cp lemonldap-ng-common/lemonldap-ng.ini ${TDIR}/lemonldap-ng-common |
||||
|
||||
# Test that have no interest |
||||
rm -f $TDIR/*/t/99-pod.t \ |
||||
$TDIR/lemonldap-ng-manager/t/03-HTML-forms.t \ |
||||
$TDIR/lemonldap-ng-manager/t/20-test-coverage.t \ |
||||
$TDIR/lemonldap-ng-manager/t/80-attributes.t \ |
||||
$TDIR/lemonldap-ng-manager/t/90-translations.t |
||||
|
||||
for INI in $(find $TDIR/lemonldap-ng-* -name lemonldap-ng.ini); do |
||||
echo "Change $INI logLevel to debug" |
||||
perl -pi -e 's/^logLevel\s*=\s*\w+$/logLevel=debug/' $INI || true |
||||
done |
||||
|
||||
# For now, too many bugs with Moose in autopkg jail, so manager isn't tested |
||||
for dir in common handler portal manager; do |
||||
TDIR2=${TDIR}/lemonldap-ng-$dir |
||||
|
||||
# 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 TDIR2; $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 $TDIR2/$file |
||||
done |
||||
fi |
||||
fi |
||||
|
||||
tests_file=$(pwd)/debian/tests/pkg-perl/smoke-tests |
||||
cd $TDIR2 |
||||
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= |
||||
PKG_PERL_XVFB_ARGS= |
||||
PKG_PERL_XVFB_SERVER_ARGS= |
||||
fi |
||||
|
||||
test_targets=$(ls -d t/*.t 2>/dev/null || true) |
||||
|
||||
if [ ! -n "$test_targets" ]; then |
||||
echo 'Nothing to prove, skipping.' |
||||
else |
||||
$XVFB $PKG_PERL_XVFB_ARGS ${PKG_PERL_XVFB_SERVER_ARGS:+-s} ${PKG_PERL_XVFB_SERVER_ARGS:+"$PKG_PERL_XVFB_SERVER_ARGS"} prove -I"$TDIR" --blib $PKG_PERL_PROVE_ARGS $test_targets 2>&1 |
||||
fi |
||||
|
||||
cd - |
||||
|
||||
done |
@ -1,104 +0,0 @@ |
||||
#!/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"); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,110 +0,0 @@ |
||||
#!/usr/bin/perl -w |
||||
use strict; |
||||
|
||||
use Test::More; |
||||
use Getopt::Std; |
||||
use CPAN::Meta; |
||||
use File::Temp; |
||||
|
||||
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 |
||||
|
||||
$module = read_conffile($conffile); |
||||
return $module if defined $module; |
||||
return getmeta(); |
||||
} |
||||
|
||||
sub read_conffile { |
||||
my $conffile = shift; |
||||
my $ret; |
||||
if ( -f $conffile ) { |
||||
open(M, "<", $conffile) |
||||
or BAIL_OUT("$conffile exists but can't be read"); |
||||
while (<M>) { |
||||
chomp; |
||||
next if /^\s*#/; |
||||
/(\S+)/ and $ret = $1, last; |
||||
} |
||||
close M; |
||||
BAIL_OUT("can't find anything in $conffile") |
||||
if !defined $ret; |
||||
} |
||||
return $ret; |
||||
} |
||||
|
||||
sub getmeta { |
||||
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; |
||||
|
||||
my $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; |
||||
} |
||||
|
||||
sub getwhitelist { |
||||
my $whitelist = 'debian/tests/pkg-perl/use-whitelist'; |
||||
my $ret; |
||||
$ret = read_conffile($whitelist) if ( -f $whitelist ); |
||||
$ret; |
||||
} |
||||
|
||||
my @modules = @ARGV ? @ARGV : getmodule(); |
||||
|
||||
my $whitelist = getwhitelist(); |
||||
|
||||
usage() if !@modules; |
||||
|
||||
plan tests => 4 * scalar @modules; |
||||
|
||||
# don't run the command in the source directory, in case |
||||
# cwd is on @INC |
||||
|
||||
my $dir; |
||||
$dir = $ENV{'AUTOPKGTEST_TMP'}; |
||||
$dir = $ENV{'ADTTMP'} if !defined $dir; |
||||
$dir = File::Temp::tempdir( CLEANUP => 1 ) if !defined $dir; |
||||
|
||||
chdir($dir) or die("can't chdir to $dir"); |
||||
|
||||
for my $mod (@modules) { |
||||
for my $envprefix ('', 'env PERL_DL_NONLAZY=1 ') { |
||||
my $cmd = qq($envprefix $^X -w -M"$mod" -e 1 2>&1); |
||||
my @out = qx($cmd); |
||||
note(@out) if @out; |
||||
ok(!$?, "$cmd exited successfully"); |
||||
@out = grep { !/$whitelist/ } @out if defined $whitelist; |
||||
ok(!@out, "$cmd produced no (non-whitelisted) output"); |
||||
} |
||||
} |
@ -0,0 +1,2 @@ |
||||
t |
||||
lemonldap-ng.ini |
@ -0,0 +1 @@ |
||||
Use the appropriate handler.* |
@ -0,0 +1,3 @@ |
||||
t |
||||
site/templates |
||||
site/htdocs/static/struct.json |
@ -0,0 +1,4 @@ |
||||
t/03-HTML-forms.t |
||||
t/80-attributes.t |
||||
t/90-translations.t |
||||
t/99-pod.t |
@ -0,0 +1,4 @@ |
||||
t |
||||
site/templates |
||||
site/htdocs/static/common/icons/ok.png |
||||
inc |
@ -0,0 +1,2 @@ |
||||
t/90-Translations.t |
||||
t/99-pod.t |
@ -0,0 +1,9 @@ |
||||
Apache2 |
||||
ApacheMP2 |
||||
Common/Logger/Sentry.pm |
||||
Handler/Lib/SecureToken.pm |
||||
Handler/Server/SecureToken.pm |
||||
Portal/Main/Run |
||||
Portal/Main/Init |
||||
Portal/Main/Display |
||||
Portal/Main/Process |
Loading…
Reference in new issue