[libcode-tidyall-perl] 242/374: handle errors correctly in PerlCritic
Jonas Smedegaard
js at alioth.debian.org
Sun Sep 29 22:26:28 UTC 2013
This is an automated email from the git hooks/post-receive script.
js pushed a commit to branch master
in repository libcode-tidyall-perl.
commit 94bc033ab6ec797891db5d35497fa44261c104b4
Author: Jonathan Swartz <swartz at pobox.com>
Date: Fri Sep 14 13:17:50 2012 -0400
handle errors correctly in PerlCritic
---
lib/Code/TidyAll/Plugin/PerlCritic.pm | 8 ++++----
lib/Code/TidyAll/t/Plugin/PerlCritic.pm | 11 +++++++++++
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/lib/Code/TidyAll/Plugin/PerlCritic.pm b/lib/Code/TidyAll/Plugin/PerlCritic.pm
index 9cbb2db..7974aa3 100644
--- a/lib/Code/TidyAll/Plugin/PerlCritic.pm
+++ b/lib/Code/TidyAll/Plugin/PerlCritic.pm
@@ -1,15 +1,15 @@
package Code::TidyAll::Plugin::PerlCritic;
-use Perl::Critic::Command qw();
use Capture::Tiny qw(capture_merged);
use Moo;
extends 'Code::TidyAll::Plugin';
+sub _build_cmd { 'perlcritic' }
+
sub validate_file {
my ( $self, $file ) = @_;
- my @argv = ( split( /\s/, $self->argv ), $file );
- local @ARGV = @argv;
- my $output = capture_merged { Perl::Critic::Command::run() };
+ my $cmd = sprintf( "%s %s %s", $self->cmd, $self->argv, $file );
+ my $output = capture_merged { system($cmd) };
die "$output\n" if $output !~ /^.* source OK\n/;
}
diff --git a/lib/Code/TidyAll/t/Plugin/PerlCritic.pm b/lib/Code/TidyAll/t/Plugin/PerlCritic.pm
index 0cac688..d00ace4 100644
--- a/lib/Code/TidyAll/t/Plugin/PerlCritic.pm
+++ b/lib/Code/TidyAll/t/Plugin/PerlCritic.pm
@@ -24,6 +24,17 @@ sub test_main : Tests {
conf => { argv => "--profile $rc_file" },
expect_ok => 1,
);
+ $self->tidyall(
+ source => 'my $foo = 5\n',
+ conf => { argv => "--profile $rc_file --badoption" },
+ expect_error => qr/Unknown option: badoption/
+ );
+ write_file( $rc_file, "badconfig = 1\n" );
+ $self->tidyall(
+ source => 'my $foo = 5\n',
+ conf => { argv => "--profile $rc_file" },
+ expect_error => qr/"badconfig" is not a supported option/
+ );
}
1;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libcode-tidyall-perl.git
More information about the Pkg-perl-cvs-commits
mailing list