Permalink
Browse files

Add make prove target.

The prove target will attempt to run the tests in parallel.

Also add a make tst target which will try to run prove but fall back to
running "make test" if necessary.

Abstract the code out into Devel::Cover::BuildUtils and call "make prove" in
the make all_test target.
  • Loading branch information...
1 parent a08e168 commit da2bb0754be2b39d0b7089f0742b074e63c851ed @pjcj committed Sep 4, 2010
Showing with 103 additions and 23 deletions.
  1. +1 −0 MANIFEST
  2. +6 −0 Makefile.PL
  3. +91 −0 utils/Devel/Cover/BuildUtils.pm
  4. +5 −23 utils/all_versions
View
1 MANIFEST
@@ -101,6 +101,7 @@ tests/uncoverable
typemap
utils/all_versions
utils/create_gold
+utils/Devel/Cover/BuildUtils.pm
utils/install/buildperl
utils/install/System.pm
utils/makeh
View
6 Makefile.PL
@@ -482,6 +482,12 @@ text : out
wrun : pure_all
\t \$(PERL) \$(TAINT) -Iblib/lib -Iblib/arch -MDevel::Cover=-ignore,blib,-merge,0 tests/\$(TEST)
+prove : pure_all
+\t \$(PERL) -Iutils -MDevel::Cover::BuildUtils=prove_command -le '\$\$c = prove_command and print \$\$c and system \$\$c'
+
+tst : pure_all
+\t \$(PERL) -Iutils -MDevel::Cover::BuildUtils=prove_command -le '\$\$c = prove_command and print \$\$c and system \$\$c and system "make test"'
+
DB = cover_db
dump :
View
91 utils/Devel/Cover/BuildUtils.pm
@@ -0,0 +1,91 @@
+# Copyright 2010, Paul Johnson (pjcj@cpan.org)
+
+# This software is free. It is licensed under the same terms as Perl itself.
+
+# The latest version of this software should be available from my homepage:
+# http://www.pjcj.net
+
+package Devel::Cover::BuildUtils;
+
+use strict;
+use warnings;
+
+our $VERSION = "0.70";
+
+use Exporter;
+
+our @ISA = "Exporter";
+our @EXPORT_OK = qw(find_prove cpus prove_command);
+
+sub find_prove
+{
+ my $perl = $^X;
+ unless (-x $perl)
+ {
+ my ($dir) = grep -x "$_/$perl", split /:/, $ENV{PATH};
+ $perl = "$dir/$perl";
+ }
+
+ eval { $perl = readlink($perl) || $perl };
+ # print "perl is [$perl]\n";
+ my ($dir) = $perl =~ m|(.*)/[^/]+|;
+ my ($prove) = grep -x, <$dir/prove*>;
+
+ warn "prove cannot be found in $dir\n";
+
+ $prove
+}
+
+sub cpus
+{
+ my $cpus = 1;
+ eval { chomp ($cpus = `grep -c processor /proc/cpuinfo`); };
+ $cpus
+}
+
+sub prove_command
+{
+ my $prove = find_prove or return;
+ my $cpus = cpus;
+ $cpus-- if $cpus > 4;
+ "$prove -brj$cpus t"
+}
+
+__END__
+
+=head1 NAME
+
+Devel::Cover::BuildUtils - Build utility functions for Devel::Cover
+
+=head1 SYNOPSIS
+
+ use Devel::Cover::BuildUtils "find_prove";
+
+=head1 DESCRIPTION
+
+Build utility functions for Devel::Cover.
+
+=head1 SEE ALSO
+
+ Devel::Cover
+
+=head1 METHODS
+
+=head1 BUGS
+
+Huh?
+
+=head1 VERSION
+
+Version 0.70 - 29th August 2010
+
+=head1 LICENCE
+
+Copyright 2001-2010, Paul Johnson (pjcj@cpan.org)
+
+This software is free. It is licensed under the same terms as Perl itself.
+
+The latest version of this software should be available from my homepage:
+http://www.pjcj.net
+
+=cut
View
28 utils/all_versions
@@ -10,8 +10,12 @@
use strict;
use warnings;
+use lib "utils";
+
use Getopt::Long;
+use Devel::Cover::BuildUtils "prove_command";
+
my $Options =
{
dry_run => 0,
@@ -68,27 +72,5 @@ for my $v (@{$Options->{version}})
sys "make clean";
sys "$perl Makefile.PL";
sys "make";
- if ($c eq "test")
- {
- my ($dir) = grep -x "$_/$perl", split /:/, $ENV{PATH};
- eval
- {
- my $l = readlink "$dir/$perl";
- ($dir) = $l =~ m|(.*)/[^/]+|;
- };
- my ($prove) = grep -x,
- map "$dir/prove$_",
- "", $v, $v =~ /([\d.]+)/ ? $1 : "";
- if ($prove)
- {
- my $cpus = 1;
- eval { chomp ($cpus = `grep -c processor /proc/cpuinfo`); };
- $cpus-- if $cpus > 4;
- $c = "$prove -b -r -j$cpus t";
- eval { sys $c, 1 };
- next unless $@;
- }
- $c = "make test";
- }
- sys $c, 1;
+ sys "make prove", 1 if $c eq "test";
}

0 comments on commit da2bb07

Please sign in to comment.