Skip to content
This repository
Browse code

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...
commit da2bb0754be2b39d0b7089f0742b074e63c851ed 1 parent a08e168
Paul Johnson authored
1  MANIFEST
@@ -101,6 +101,7 @@ tests/uncoverable
101 101 typemap
102 102 utils/all_versions
103 103 utils/create_gold
  104 +utils/Devel/Cover/BuildUtils.pm
104 105 utils/install/buildperl
105 106 utils/install/System.pm
106 107 utils/makeh
6 Makefile.PL
@@ -482,6 +482,12 @@ text : out
482 482 wrun : pure_all
483 483 \t \$(PERL) \$(TAINT) -Iblib/lib -Iblib/arch -MDevel::Cover=-ignore,blib,-merge,0 tests/\$(TEST)
484 484
  485 +prove : pure_all
  486 +\t \$(PERL) -Iutils -MDevel::Cover::BuildUtils=prove_command -le '\$\$c = prove_command and print \$\$c and system \$\$c'
  487 +
  488 +tst : pure_all
  489 +\t \$(PERL) -Iutils -MDevel::Cover::BuildUtils=prove_command -le '\$\$c = prove_command and print \$\$c and system \$\$c and system "make test"'
  490 +
485 491 DB = cover_db
486 492
487 493 dump :
91 utils/Devel/Cover/BuildUtils.pm
... ... @@ -0,0 +1,91 @@
  1 +# Copyright 2010, Paul Johnson (pjcj@cpan.org)
  2 +
  3 +# This software is free. It is licensed under the same terms as Perl itself.
  4 +
  5 +# The latest version of this software should be available from my homepage:
  6 +# http://www.pjcj.net
  7 +
  8 +package Devel::Cover::BuildUtils;
  9 +
  10 +use strict;
  11 +use warnings;
  12 +
  13 +our $VERSION = "0.70";
  14 +
  15 +use Exporter;
  16 +
  17 +our @ISA = "Exporter";
  18 +our @EXPORT_OK = qw(find_prove cpus prove_command);
  19 +
  20 +sub find_prove
  21 +{
  22 + my $perl = $^X;
  23 + unless (-x $perl)
  24 + {
  25 + my ($dir) = grep -x "$_/$perl", split /:/, $ENV{PATH};
  26 + $perl = "$dir/$perl";
  27 + }
  28 +
  29 + eval { $perl = readlink($perl) || $perl };
  30 + # print "perl is [$perl]\n";
  31 + my ($dir) = $perl =~ m|(.*)/[^/]+|;
  32 + my ($prove) = grep -x, <$dir/prove*>;
  33 +
  34 + warn "prove cannot be found in $dir\n";
  35 +
  36 + $prove
  37 +}
  38 +
  39 +sub cpus
  40 +{
  41 + my $cpus = 1;
  42 + eval { chomp ($cpus = `grep -c processor /proc/cpuinfo`); };
  43 + $cpus
  44 +}
  45 +
  46 +sub prove_command
  47 +{
  48 + my $prove = find_prove or return;
  49 + my $cpus = cpus;
  50 + $cpus-- if $cpus > 4;
  51 + "$prove -brj$cpus t"
  52 +}
  53 +
  54 +__END__
  55 +
  56 +=head1 NAME
  57 +
  58 +Devel::Cover::BuildUtils - Build utility functions for Devel::Cover
  59 +
  60 +=head1 SYNOPSIS
  61 +
  62 + use Devel::Cover::BuildUtils "find_prove";
  63 +
  64 +=head1 DESCRIPTION
  65 +
  66 +Build utility functions for Devel::Cover.
  67 +
  68 +=head1 SEE ALSO
  69 +
  70 + Devel::Cover
  71 +
  72 +=head1 METHODS
  73 +
  74 +=head1 BUGS
  75 +
  76 +Huh?
  77 +
  78 +=head1 VERSION
  79 +
  80 +Version 0.70 - 29th August 2010
  81 +
  82 +=head1 LICENCE
  83 +
  84 +Copyright 2001-2010, Paul Johnson (pjcj@cpan.org)
  85 +
  86 +This software is free. It is licensed under the same terms as Perl itself.
  87 +
  88 +The latest version of this software should be available from my homepage:
  89 +http://www.pjcj.net
  90 +
  91 +=cut
28 utils/all_versions
@@ -10,8 +10,12 @@
10 10 use strict;
11 11 use warnings;
12 12
  13 +use lib "utils";
  14 +
13 15 use Getopt::Long;
14 16
  17 +use Devel::Cover::BuildUtils "prove_command";
  18 +
15 19 my $Options =
16 20 {
17 21 dry_run => 0,
@@ -68,27 +72,5 @@ for my $v (@{$Options->{version}})
68 72 sys "make clean";
69 73 sys "$perl Makefile.PL";
70 74 sys "make";
71   - if ($c eq "test")
72   - {
73   - my ($dir) = grep -x "$_/$perl", split /:/, $ENV{PATH};
74   - eval
75   - {
76   - my $l = readlink "$dir/$perl";
77   - ($dir) = $l =~ m|(.*)/[^/]+|;
78   - };
79   - my ($prove) = grep -x,
80   - map "$dir/prove$_",
81   - "", $v, $v =~ /([\d.]+)/ ? $1 : "";
82   - if ($prove)
83   - {
84   - my $cpus = 1;
85   - eval { chomp ($cpus = `grep -c processor /proc/cpuinfo`); };
86   - $cpus-- if $cpus > 4;
87   - $c = "$prove -b -r -j$cpus t";
88   - eval { sys $c, 1 };
89   - next unless $@;
90   - }
91   - $c = "make test";
92   - }
93   - sys $c, 1;
  75 + sys "make prove", 1 if $c eq "test";
94 76 }

0 comments on commit da2bb07

Please sign in to comment.
Something went wrong with that request. Please try again.