Skip to content

Commit

Permalink
run modules tests with timeout
Browse files Browse the repository at this point in the history
git-svn-id: http://perl-compiler.googlecode.com/svn/trunk@288 ed534f1a-1453-0410-ab30-dfc593a8b23c
  • Loading branch information
Reini Urban committed Feb 2, 2010
1 parent 1d70b1c commit 4761075
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
1 change: 1 addition & 0 deletions Changes
Expand Up @@ -18,6 +18,7 @@
Fixed Getopt::Long crash with AV D magic (regdata),
save_magic returns now the magic types as string.
Fixed unescaped savere (test ExtUtils::Install).
Fixed CvSTASH "initializer element is not constant" (Test::Harness)
* CC.pm (1.06): Added missing unexported definitions for MSWin32,
>=5.10: newGP, vivify_ref, prepare_SV_for_RV (tests 18, 29).
PerlProc_setjmp, PerlProc_longjmp (tests 12, 32).
Expand Down
39 changes: 33 additions & 6 deletions t/modules.t
Expand Up @@ -21,6 +21,31 @@ BEGIN {
}
}

use Config;

eval { require IPC::Run; };
my $have_IPC_Run = defined $IPC::Run::VERSION;

sub run_cmd {
my ($cmd, $timeout) = @_;

if ( ! $have_IPC_Run ) {
local $@;
$out = `$cmd`;
$result = !$?;
} else {
my $in;
my @cmd = split /\s+/, $cmd;
if ($timeout) {
$result = IPC::Run::run(\@cmd, \$in, \$out, \$err,
IPC::Run::timeout($timeout));
} else {
$result = IPC::Run::run(\@cmd, \$in, \$out, \$err);
}
}
return ($result, $out, $err);
}

my %TODO = map{$_=>1}
qw(Attribute::Handlers B::Hooks::EndOfScope YAML MooseX::Types);
if ($] >= 5.010) {
Expand All @@ -33,7 +58,6 @@ if ($] >= 5.011004) {
$TODO{Test::NoWarnings} = 0;
}

use Config;
my @modules;
{
local $/;
Expand Down Expand Up @@ -62,8 +86,7 @@ if ($log) {
use File::Copy;
copy $log, "$log.bak";
}
open LOG, ">", "$log.err";
close LOG;
open ERR, ">", "$log.err";
open LOG, ">", $log or die "Cannot write to $log";
eval { require B::C; };
print LOG "# B::C::VERSION = ",$B::C::VERSION,"\n";
Expand All @@ -90,22 +113,25 @@ for my $m (@modules) {
print F "use $m;\nprint \"ok\";";
close F;
for my $opt (@opts) {
`echo "$m - $opt" >>$log.err` if $^O ne 'MSWin32';
my $stderr = $^O eq 'MSWin32' ? "" : ($log ? "2>>$log.err" : "2>/dev/null");
if (`$^X -Mblib blib/script/perlcc $opt -r mod.pl $stderr` eq "ok") {
print ERR "$m - $opt\n" if $log;
# my $stderr = $^O eq 'MSWin32' ? "" : ($log ? "2>>$log.err" : "2>/dev/null";
my ($result, $out, $err) = run_cmd("$^X -Mblib blib/script/perlcc $opt -r mod.pl");
if ($result and $out eq "ok") {
print "ok $i #",$TODO{$m}?"TODO":""," perlcc -r $opt use $m\n";
if ($log) {
print LOG "pass $m",$opt ? " - $opt\n" : "\n";
}
$pass++;
}
else {
print ERR "$err\n" if $log and $have_IPC_Run;
$fail++;
if ($opt or $TODO{$m}) {
print "ok $i #TODO perlcc -r $opt no $m\n";
print LOG "fail $m - $opt\n" if $log;
} else {
print "not ok $i # perlcc -r $opt no $m\n";
print "# ", join "\n#", split/\n/, $err;
print LOG "fail $m\n" if $log;
}
}
Expand Down Expand Up @@ -133,4 +159,5 @@ print LOG $footer;
END {
unlink ("mod.pl", "a");
close LOG if $log;
close ERR if $log;
}

0 comments on commit 4761075

Please sign in to comment.