[libcode-tidyall-perl] 249/374: update MasonTidy test
Jonas Smedegaard
js at alioth.debian.org
Sun Sep 29 22:26:29 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 25c6cd2e7c013afc57051d1219e3b7e67971f59d
Author: Jonathan Swartz <swartz at pobox.com>
Date: Fri Sep 21 03:55:03 2012 -0700
update MasonTidy test
---
Changes | 2 +-
lib/Code/TidyAll/Config/INI/Reader.pm | 19 +++++++++++++++
lib/Code/TidyAll/Plugin/JSHint.pm | 7 ++++++
lib/Code/TidyAll/Plugin/MasonTidy.pm | 1 +
lib/Code/TidyAll/t/Basic.pm | 42 +++-----------------------------
lib/Code/TidyAll/t/Plugin/MasonTidy.pm | 2 +-
6 files changed, 32 insertions(+), 41 deletions(-)
diff --git a/Changes b/Changes
index 028b0c1..f9487b8 100644
--- a/Changes
+++ b/Changes
@@ -5,7 +5,7 @@ Revision history for Code-TidyAll
0.11 Sep 12, 2012
* Improvements
- - Allow multiple select and ignore patterns separated by whitespace
+ - Allow multiple select and ignore patterns, separated by whitespace or on separate lines
- Add -l/--list flag to show which plugins match which files
- Add conf_name parameter to specify name other than tidyall.ini
- Redirect stdout to stderr with -p/--pipe, so that stdout is dedicated to the tidied content
diff --git a/lib/Code/TidyAll/Config/INI/Reader.pm b/lib/Code/TidyAll/Config/INI/Reader.pm
new file mode 100644
index 0000000..8ccc911
--- /dev/null
+++ b/lib/Code/TidyAll/Config/INI/Reader.pm
@@ -0,0 +1,19 @@
+package Code::TidyAll::Config::INI::Reader;
+use strict;
+use warnings;
+use base qw(Config::INI::Reader);
+
+sub set_value {
+ my ( $self, $name, $value ) = @_;
+
+ if ( exists( $self->{data}{ $self->current_section }{$name} ) ) {
+ die "cannot list multiple config values for '$name'"
+ unless $name =~ /select|ignore/;
+ $self->{data}{ $self->current_section }{$name} .= " " . $value;
+ }
+ else {
+ $self->{data}{ $self->current_section }{$name} = $value;
+ }
+}
+
+1;
diff --git a/lib/Code/TidyAll/Plugin/JSHint.pm b/lib/Code/TidyAll/Plugin/JSHint.pm
index 1a3913f..51de692 100644
--- a/lib/Code/TidyAll/Plugin/JSHint.pm
+++ b/lib/Code/TidyAll/Plugin/JSHint.pm
@@ -4,6 +4,13 @@ use Capture::Tiny qw(capture_merged);
use Moo;
extends 'Code::TidyAll::Plugin';
+sub validate_params {
+ my ( $self, $params ) = @_;
+
+ delete( $params->{options} );
+ return $self->SUPER::validate_params($params);
+}
+
sub _build_cmd { 'jshint' }
sub BUILDARGS {
diff --git a/lib/Code/TidyAll/Plugin/MasonTidy.pm b/lib/Code/TidyAll/Plugin/MasonTidy.pm
index 3e5cca7..8a214c0 100644
--- a/lib/Code/TidyAll/Plugin/MasonTidy.pm
+++ b/lib/Code/TidyAll/Plugin/MasonTidy.pm
@@ -15,6 +15,7 @@ sub transform_source {
my $opts_good;
my $output = capture_merged { $opts_good = Mason::Tidy->get_options( $argv_list, \%params ) };
die $output if !$opts_good;
+ die sprintf( "unrecognized arguments '%s'", join( " ", @$argv_list ) ) if @$argv_list;
my $mt = Mason::Tidy->new(%params);
my $dest = $mt->tidy($source);
return $dest;
diff --git a/lib/Code/TidyAll/t/Basic.pm b/lib/Code/TidyAll/t/Basic.pm
index 9aac578..a95fb35 100644
--- a/lib/Code/TidyAll/t/Basic.pm
+++ b/lib/Code/TidyAll/t/Basic.pm
@@ -10,7 +10,7 @@ sub test_plugin { "+Code::TidyAll::Test::Plugin::$_[0]" }
my %UpperText = ( test_plugin('UpperText') => { select => '**/*.txt' } );
my %ReverseFoo = ( test_plugin('ReverseFoo') => { select => '**/foo*' } );
my %RepeatFoo = ( test_plugin('RepeatFoo') => { select => '**/foo*' } );
-my ( $conf1, $conf2 );
+my $cli_conf;
sub create_dir {
my ( $self, $files ) = @_;
@@ -258,35 +258,11 @@ sub test_errors : Tests {
throws_ok { $ct->process_files("$other_dir/foo.txt") } qr/not underneath root dir/;
}
-sub test_conf_file : Tests {
- my $self = shift;
- my $root_dir = $self->create_dir();
- my $conf_file = "$root_dir/tidyall.ini";
- write_file( $conf_file, $conf1 );
-
- my $ct = Code::TidyAll->new_from_conf_file($conf_file);
- my %expected = (
- backup_ttl => '5m',
- backup_ttl_secs => '300',
- no_backups => undef,
- no_cache => 1,
- root_dir => dirname($conf_file),
- data_dir => "$root_dir/.tidyall.d",
- plugins => {
- '+Code::TidyAll::Test::Plugin::UpperText' => { select => '**/*.txt' },
- '+Code::TidyAll::Test::Plugin::RepeatFoo' => { select => '**/foo*', times => 3 }
- }
- );
- while ( my ( $method, $value ) = each(%expected) ) {
- cmp_deeply( $ct->$method, $value, "$method" );
- }
-}
-
sub test_cli : Tests {
my $self = shift;
my $root_dir = $self->create_dir();
my $conf_file = "$root_dir/tidyall.ini";
- write_file( $conf_file, $conf2 );
+ write_file( $conf_file, $cli_conf );
write_file( "$root_dir/foo.txt", "hello" );
my $output = capture_stdout {
@@ -321,19 +297,7 @@ sub test_cli : Tests {
unlike( $stderr, qr/\S/, "pipe: no stderr" );
}
-$conf1 = '
-backup_ttl = 5m
-no_cache = 1
-
-[+Code::TidyAll::Test::Plugin::UpperText]
-select = **/*.txt
-
-[+Code::TidyAll::Test::Plugin::RepeatFoo]
-select = **/foo*
-times = 3
-';
-
-$conf2 = '
+$cli_conf = '
backup_ttl = 15m
verbose = 1
diff --git a/lib/Code/TidyAll/t/Plugin/MasonTidy.pm b/lib/Code/TidyAll/t/Plugin/MasonTidy.pm
index f04dd58..75f9b7f 100644
--- a/lib/Code/TidyAll/t/Plugin/MasonTidy.pm
+++ b/lib/Code/TidyAll/t/Plugin/MasonTidy.pm
@@ -9,7 +9,7 @@ sub test_main : Tests {
$source = '%if($foo) {\n%bar(1,2);\n%}';
$self->tidyall(
source => $source,
- expect_tidy => '% if ($foo) {\n% bar( 1, 2 );\n% }'
+ expect_tidy => '% if ($foo) {\n% bar( 1, 2 );\n% }'
);
$self->tidyall(
source => $source,
--
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