|
|
|
@ -4,6 +4,7 @@ use strict; |
|
|
|
|
use Test::More; |
|
|
|
|
use Getopt::Std; |
|
|
|
|
use CPAN::Meta; |
|
|
|
|
use File::Temp; |
|
|
|
|
|
|
|
|
|
sub usage { |
|
|
|
|
my $exit = shift; |
|
|
|
@ -24,20 +25,31 @@ sub getmodule { |
|
|
|
|
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 $module = $1, last; |
|
|
|
|
/(\S+)/ and $ret = $1, last; |
|
|
|
|
} |
|
|
|
|
close M; |
|
|
|
|
BAIL_OUT("can't find a module name in $conffile") |
|
|
|
|
if !defined $module; |
|
|
|
|
return $module; |
|
|
|
|
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') }; |
|
|
|
@ -47,7 +59,7 @@ sub getmodule { |
|
|
|
|
|
|
|
|
|
$dist = $meta->name; |
|
|
|
|
|
|
|
|
|
$module = $dist; |
|
|
|
|
my $module = $dist; |
|
|
|
|
$module =~ s,-,::,g; |
|
|
|
|
|
|
|
|
|
my $file = "$dist.pm"; |
|
|
|
@ -61,16 +73,38 @@ sub getmodule { |
|
|
|
|
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 => 2 * scalar @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) { |
|
|
|
|
my $cmd = qq($^X -w -M"$mod" -e 1 2>&1); |
|
|
|
|
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"); |
|
|
|
|
ok(!@out, "$cmd produced no output"); |
|
|
|
|
@out = grep { !/$whitelist/ } @out if defined $whitelist; |
|
|
|
|
ok(!@out, "$cmd produced no (non-whitelisted) output"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|