diff --git a/CHANGES b/CHANGES index f23d813..3a3879b 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +0.0.3 2022-02-16 15:08:23 +0100 Tobias Bossert + - Also forward includes to target mojo command + 0.0.2 2022-02-11 12:52:26 +0100 Tobias Bossert - Repo updates - Constrained dependency versions diff --git a/README.md b/README.md index 69b6eb8..f1b50d0 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,15 @@ ![https://metacpan.org/pod/Mojolicious::Command::coverage](https://img.shields.io/cpan/v/Mojolicious-Command-coverage) -Start you Mojo app in coverage mode +Start you Mojo app in coverage mode. In short this command does the following: + +```text + +./myapp.pl coverage [application arguments] +# Is translated to +perl -I $INC[0] ... - I $INC[N] -MDevel::Cover=$coverageConfig -MDevel::Deanonymize=$deanonConfig myapp.pl [application arguments] + +``` # SYNOPSIS diff --git a/VERSION b/VERSION index 7bcd0e3..6812f81 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.0.2 \ No newline at end of file +0.0.3 \ No newline at end of file diff --git a/lib/Mojolicious/Command/coverage.pm b/lib/Mojolicious/Command/coverage.pm index e558b8c..8f9e72a 100644 --- a/lib/Mojolicious/Command/coverage.pm +++ b/lib/Mojolicious/Command/coverage.pm @@ -4,6 +4,8 @@ use warnings FATAL => 'all'; use Mojo::Base 'Mojolicious::Command', -signatures; use Mojo::Util qw(getopt); +use Data::Dumper; + our $VERSION = "0.0.2"; # Do not update manually # Short description @@ -39,6 +41,9 @@ sub run($self, @args) { $coverageConfig = $self->app->coverageConfig; print "Command::coverage: Taking config from `$appName->coverageConfig` for Devel::Cover \n"; } + # We also have to forward @INC which may have been set-up with Findbin + my @Is = ('-I') x scalar @INC; + my @includes = map {($Is[$_], $INC[$_])} (0 .. $#INC); # this is basically zip(arr1,arr2) in other languages # if there is no custom config, we fallback to default $deanonConfig = $appName if $deanonConfig eq ""; @@ -46,10 +51,10 @@ sub run($self, @args) { my @commandline_inject = (); if ($deanonConfig ne "0") { - @commandline_inject = ('perl', "-MDevel::Cover=$coverageConfig", "-MDevel::Deanonymize=$deanonConfig", $0); + @commandline_inject = ('perl', @includes, "-MDevel::Cover=$coverageConfig", "-MDevel::Deanonymize=$deanonConfig", $0); } else { - @commandline_inject = ('perl', "-MDevel::Cover=$coverageConfig", $0); + @commandline_inject = ('perl', @includes, "-MDevel::Cover=$coverageConfig", $0); } # Merge with application arguments my @full_commandline = (@commandline_inject, @orig_args[$n_args .. $#orig_args]); @@ -84,7 +89,12 @@ Mojolicious::Command::coverage - Run your application with coverage statistics =head1 DESCRIPTION -Starts your mojo application with L and optionally L. +Starts your mojo application with L and optionally L. In short this command does the following: + + ./myapp.pl coverage [application arguments] + # Is translated to + perl -I $INC[0] ... - I $INC[N] -MDevel::Cover=$coverageConfig -MDevel::Deanonymize=$deanonConfig myapp.pl [application arguments] + =cut