From cc84994ea7cc916262cdb8026e5ad5aef3b0ebf5 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Tue, 17 Nov 2009 23:33:44 -0800 Subject: [PATCH] Fix a problem with bad tests and bad code in globbed Pluggable excludes. --- lib/WebGUI/Pluggable.pm | 3 ++- t/Pluggable.t | 18 ++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/WebGUI/Pluggable.pm b/lib/WebGUI/Pluggable.pm index 003dda97f..b15d7a03f 100644 --- a/lib/WebGUI/Pluggable.pm +++ b/lib/WebGUI/Pluggable.pm @@ -110,9 +110,10 @@ sub find { @modulesHash{ @modules } = ( 1 ) x @modules; delete @modulesHash{ @{ $options->{exclude} } }; @modules = keys %modulesHash; - my @excludePatterns = map { s/(?{exclude} }; if (@excludePatterns) { my $pattern = join q{|}, @excludePatterns; + warn $pattern; my $exclusions = qr/$pattern/; @modules = grep { ! m/$exclusions/ } @modules; } diff --git a/t/Pluggable.t b/t/Pluggable.t index cb78bd72e..3ad9d004b 100644 --- a/t/Pluggable.t +++ b/t/Pluggable.t @@ -41,7 +41,7 @@ use WebGUI::Pluggable; #---------------------------------------------------------------------------- # Tests -plan tests => 11; # Increment this number for each test you create +plan tests => 12; # Increment this number for each test you create #---------------------------------------------------------------------------- # put your tests here @@ -103,13 +103,19 @@ is($dumper->Dump, q|$VAR1 = { cmp_deeply( [ WebGUI::Pluggable::find( 'WebGUI::i18n', { exclude => [ 'WebGUI::i18n::English::WebGUI*' ] } ) ], - bag( grep { $_ ne 'WebGUI::i18n::English::WebGUI' || $_ ne 'WebGUI::i18n::English::WebGUIProfile' } @testFiles ), + bag( grep { $_ ne 'WebGUI::i18n::English::WebGUI' && $_ ne 'WebGUI::i18n::English::WebGUIProfile' } @testFiles ), "find() with exclude with glob", ); + cmp_deeply( + [ WebGUI::Pluggable::find( 'WebGUI::i18n', { exclude => [ 'WebGUI::i18n::English*' ] } ) ], + [], + "find() with exclude with massive glob", + ); + cmp_deeply( [ WebGUI::Pluggable::find( 'WebGUI::i18n', { exclude => [ 'WebGUI::i18n::English::WebGUI.*' ] } ) ], - bag( grep { $_ ne 'WebGUI::i18n::English::WebGUI' || $_ ne 'WebGUI::i18n::English::WebGUIProfile' } @testFiles ), + bag( grep { $_ ne 'WebGUI::i18n::English::WebGUI' && $_ ne 'WebGUI::i18n::English::WebGUIProfile' } @testFiles ), "find() with exclude with regex", ); @@ -117,9 +123,9 @@ is($dumper->Dump, q|$VAR1 = { [ WebGUI::Pluggable::find( 'WebGUI::i18n', { exclude => [ qw/WebGUI::i18n::English::WebGUI.* WebGUI::i18n::English::ShipDriver_USPS*/ ] } ) ], bag( grep { $_ ne 'WebGUI::i18n::English::WebGUI' - || $_ ne 'WebGUI::i18n::English::WebGUIProfile' - || $_ ne 'WebGUI::i18n::English::ShipDriver_USPS' - || $_ ne 'WebGUI::i18n::English::ShipDriver_USPSInternational' + && $_ ne 'WebGUI::i18n::English::WebGUIProfile' + && $_ ne 'WebGUI::i18n::English::ShipDriver_USPS' + && $_ ne 'WebGUI::i18n::English::ShipDriver_USPSInternational' } @testFiles ), "find() with multiple excludes", );