Permalink
Browse files

Add --open to open coverage results in browser

  • Loading branch information...
1 parent 1b4be4c commit d212ad1df94f48792076612596544c1bb5a5f9b4 @sdt committed Apr 22, 2012
Showing with 12 additions and 2 deletions.
  1. +12 −2 lib/Dist/Zilla/App/Command/cover.pm
@@ -9,12 +9,17 @@ use Dist::Zilla::App -command;
use File::Temp;
use Path::Class;
use File::chdir;
+use Browser::Open qw( open_browser );
sub abstract { "code coverage metrics for your distribution" }
+sub opt_spec {
+ [ 'open' => 'open the coverage results in a browser' ],
+}
+
sub execute {
- my $self = shift;
+ my ($self, $opt, $arg) = @_;
local $ENV{HARNESS_PERL_SWITCHES} = '-MDevel::Cover';
- my @cover_command = @ARGV;
+ my @cover_command = ('cover', @$arg);
# adapted from the 'test' command
my $zilla = $self->zilla;
@@ -30,10 +35,15 @@ sub execute {
$zilla->ensure_built_in($target);
$self->zilla->run_tests_in($target);
+
$self->log(join ' ' => @cover_command);
local $CWD = $target;
system @cover_command;
$self->log("leaving $target intact");
+
+ if ($opt->open) {
+ open_browser("cover_db/coverage.html", 1);
+ }
@doherty
doherty Apr 24, 2012

Please consider putting the condition at the end instead, and adding a comment explaining the Magical Number One.

}
1;

0 comments on commit d212ad1

Please sign in to comment.