]> git.imager.perl.org - imager.git/commitdiff
imcover.perl: add an option to just regen coverage
authorTony Cook <tony@develop-help.com>
Sat, 13 Feb 2016 02:19:39 +0000 (13:19 +1100)
committerTony Cook <tony@develop-help.com>
Tue, 16 Feb 2016 09:33:22 +0000 (20:33 +1100)
imcover.perl

index 5c75c4386345493365479d365111013d50d09eb4..09db97a8f7b8d5bc1150b947caa92de14d16d98c 100644 (file)
@@ -9,33 +9,39 @@ my @tests;
 my $verbose;
 my $nodc;
 my $make_opts = "";
 my $verbose;
 my $nodc;
 my $make_opts = "";
+my $regen_only;
 GetOptions("t|test=s" => \@tests,
           "m=s" => \$make_opts,
           "n" => \$nodc,
 GetOptions("t|test=s" => \@tests,
           "m=s" => \$make_opts,
           "n" => \$nodc,
-          "v" => \$verbose)
+          "v" => \$verbose,
+          "r" => \$regen_only)
   or die;
 
   or die;
 
-my $make = $Config{make};
-# if there's a way to make with profiling for a recursive build like
-# Imager I don't see how
-if (-f 'Makefile') {
-  run("$make clean");
-}
-run("cover -delete");
-run("perl Makefile.PL --coverage @ARGV")
-  and die "Makefile.PL failed\n";
-run("$make $make_opts 'OTHERLDFLAGS=-ftest-coverage -fprofile-arcs'")
-  and die "build failed\n";
+my $do_build = !$regen_only;
+if ($do_build) {
+  my $make = $Config{make};
+  # if there's a way to make with profiling for a recursive build like
+  # Imager I don't see how
+  if (-f 'Makefile') {
+    run("$make clean");
+  }
+  run("cover -delete");
+  run("perl Makefile.PL --coverage @ARGV")
+    and die "Makefile.PL failed\n";
+  run("$make $make_opts 'OTHERLDFLAGS=-ftest-coverage -fprofile-arcs'")
+    and die "build failed\n";
 
 
-{
-  local $ENV{DEVEL_COVER_OPTIONS} = "-db," . getcwd() . "/cover_db,-coverage,statement,branch,condition,subroutine";
-  my $makecmd = "$make test TEST_VERBOSE=1";
-  $makecmd .= " HARNESS_PERL_SWITCHES=-MDevel::Cover" unless $nodc;
-  if (@tests) {
-    $makecmd .= " TEST_FILES='@tests'";
+  {
+    local $ENV{DEVEL_COVER_OPTIONS} = "-db," . getcwd() . "/cover_db,-coverage,statement,branch,condition,subroutine";
+    my $makecmd = "$make test";
+    $makecmd .= " TEST_VERBOSE=1" if $verbose;
+    $makecmd .= " HARNESS_PERL_SWITCHES=-MDevel::Cover" unless $nodc;
+    if (@tests) {
+      $makecmd .= " TEST_FILES='@tests'";
+    }
+    run($makecmd)
+      and die "Test failed\n";
   }
   }
-  run($makecmd)
-    and die "Test failed\n";
 }
 
 # build gcov files
 }
 
 # build gcov files
@@ -85,3 +91,18 @@ sub run {
   print "Running: $cmd\n" if $verbose;
   return system $cmd;
 }
   print "Running: $cmd\n" if $verbose;
   return system $cmd;
 }
+
+=head1 NAME
+
+imcover.perl - perform C and perl coverage testing for Imager
+
+=head1 SYNOPSIS
+
+  perl imcover.perl [-m=...][-t=...][-n][-v][-r] -- ... Makefile.PL options
+
+=head1 DESCRIPTION
+
+Builds Imager with the C< -ftest-coverage -fprofile-arcs > gcc options
+and then runs perl's tests.
+
+=cut