Skip to content

Commit

Permalink
catch errors and handle gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
renormalist committed Sep 7, 2012
1 parent dfc73a9 commit d58887d
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 7 deletions.
6 changes: 5 additions & 1 deletion lib/Benchmark/Perl/Formance/Plugin/P6STD.pm
Expand Up @@ -26,7 +26,9 @@ sub prepare {
my $dstdir = tempdir( CLEANUP => 1 );
my $cmd;

my $srcdir = dist_dir('Benchmark-Perl-Formance-Cargo')."/P6STD";
my $srcdir; eval { $srcdir = dist_dir('Benchmark-Perl-Formance-Cargo')."/P6STD" };
return if $@;

print STDERR "# Make viv in $dstdir ...\n" if $options->{verbose} >= 3;
dircopy($srcdir, $dstdir);

Expand Down Expand Up @@ -71,6 +73,8 @@ sub main {
my $makeviv;
my $viv;
($workdir, $makeviv ) = prepare($options);
return { failed => "no Benchmark-Perl-Formance-Cargo" } if not $workdir;

$viv = viv($workdir, $options);

return {
Expand Down
5 changes: 4 additions & 1 deletion lib/Benchmark/Perl/Formance/Plugin/PerlCritic.pm
Expand Up @@ -25,7 +25,8 @@ sub prepare {
my ($options) = @_;

my $dstdir = tempdir( CLEANUP => 1 );
my $srcdir = dist_dir('Benchmark-Perl-Formance-Cargo')."/PerlCritic";
my $srcdir; eval { $srcdir = dist_dir('Benchmark-Perl-Formance-Cargo')."/PerlCritic" };
return if $@;

print STDERR "# Prepare Perl::Critic sources in $dstdir ...\n" if $options->{verbose} >= 3;
dircopy($srcdir, $dstdir);
Expand Down Expand Up @@ -86,6 +87,8 @@ sub main {
$count = $options->{fastmode} ? 1 : 2;

my ($dstdir) = prepare($options);
return { failed => "no Benchmark-Perl-Formance-Cargo" } if not $dstdir;

return {
upstream => upstream ($options, $dstdir),
bundled => bundled ($options, $dstdir),
Expand Down
5 changes: 4 additions & 1 deletion lib/Benchmark/Perl/Formance/Plugin/RegexpCommonTS.pm
Expand Up @@ -25,7 +25,8 @@ sub prepare {
my ($options) = @_;

my $dstdir = tempdir( CLEANUP => 1 );
my $srcdir = dist_dir('Benchmark-Perl-Formance-Cargo')."/RegexpCommonTS";
my $srcdir; eval { $srcdir = dist_dir('Benchmark-Perl-Formance-Cargo')."/RegexpCommonTS" };
return if $@;

print STDERR "# Prepare cargo RegexpCommon testsuite in $dstdir ...\n" if $options->{verbose} >= 3;

Expand Down Expand Up @@ -64,6 +65,8 @@ sub main {
$recurse = $options->{fastmode} ? "" : "-r";

my ($dstdir, $prove, $recurse) = prepare($options);
return { failed => "no Benchmark-Perl-Formance-Cargo" } if not $dstdir;

return nonaggregated($dstdir, $prove, $recurse, $options);
}

Expand Down
6 changes: 5 additions & 1 deletion lib/Benchmark/Perl/Formance/Plugin/Shootout/knucleotide.pm
Expand Up @@ -42,7 +42,9 @@ sub run
$output = '';
$threads = 2*num_cpus() || 1;

my $srcdir = dist_dir('Benchmark-Perl-Formance-Cargo')."/Shootout";
my $srcdir; eval { $srcdir = dist_dir('Benchmark-Perl-Formance-Cargo')."/Shootout" };
return { failed => "no Benchmark-Perl-Formance-Cargo" } if $@;

my $srcfile = "$srcdir/$infile";
open my $INFILE, "<", $srcfile or die "Cannot read $srcfile";

Expand Down Expand Up @@ -114,6 +116,8 @@ sub main

my $result;
my $t = timeit $count, sub { $result = run($goal) };
return $result if $result->{failed};

return {
Benchmark => $t,
goal => $goal,
Expand Down
6 changes: 5 additions & 1 deletion lib/Benchmark/Perl/Formance/Plugin/Shootout/regexdna.pm
Expand Up @@ -30,7 +30,9 @@ sub run
{
my ($infile) = @_;

my $srcdir = dist_dir('Benchmark-Perl-Formance-Cargo')."/Shootout";
my $srcdir; eval { $srcdir = dist_dir('Benchmark-Perl-Formance-Cargo')."/Shootout" };
return { failed => "no Benchmark-Perl-Formance-Cargo" } if $@;

my $srcfile = "$srcdir/$infile";
open my $INFILE, "<", $srcfile or die "Cannot read $srcfile";

Expand Down Expand Up @@ -101,6 +103,8 @@ sub main

my $result;
my $t = timeit $count, sub { $result = run($goal) };
return $result if $result->{failed};

return {
Benchmark => $t,
goal => $goal,
Expand Down
6 changes: 5 additions & 1 deletion lib/Benchmark/Perl/Formance/Plugin/Shootout/revcomp.pm
Expand Up @@ -38,7 +38,9 @@ sub run

my $data;

my $srcdir = dist_dir('Benchmark-Perl-Formance-Cargo')."/Shootout";
my $srcdir; eval { $srcdir = dist_dir('Benchmark-Perl-Formance-Cargo')."/Shootout" };
return { failed => "no Benchmark-Perl-Formance-Cargo" } if $@;

my $srcfile = "$srcdir/$infile";
open my $INFILE, "<", $srcfile or die "Cannot read $srcfile";

Expand Down Expand Up @@ -67,6 +69,8 @@ sub main

my $result;
my $t = timeit $count, sub { $result = run($goal) };
return $result if $result->{failed};

return {
Benchmark => $t,
goal => $goal,
Expand Down
3 changes: 2 additions & 1 deletion lib/Benchmark/Perl/Formance/Plugin/SpamAssassin.pm
Expand Up @@ -28,7 +28,8 @@ sub main {
$easy_ham = $options->{fastmode} ? "easy_ham_subset" : "easy_ham";

my $dstdir = tempdir( CLEANUP => 1 );
my $srcdir = dist_dir('Benchmark-Perl-Formance-Cargo')."/SpamAssassin";
my $srcdir; eval { $srcdir = dist_dir('Benchmark-Perl-Formance-Cargo')."/SpamAssassin" };
return { salearn => { failed => "no Benchmark-Perl-Formance-Cargo" } } if $@;

print STDERR "# Prepare cargo spam'n'ham files in $dstdir ...\n" if $options->{verbose} >= 3;

Expand Down

0 comments on commit d58887d

Please sign in to comment.