Fix a problem with bad tests and bad code in globbed Pluggable excludes.
This commit is contained in:
parent
77389ea60f
commit
cc84994ea7
2 changed files with 14 additions and 7 deletions
|
|
@ -110,9 +110,10 @@ sub find {
|
|||
@modulesHash{ @modules } = ( 1 ) x @modules;
|
||||
delete @modulesHash{ @{ $options->{exclude} } };
|
||||
@modules = keys %modulesHash;
|
||||
my @excludePatterns = map { s/(?<!\.)\*/.*/g; $_; } grep { /\*/ } @modules;
|
||||
my @excludePatterns = map { s/(?<!\.)\*/.*/g; $_; } grep { /\*/ } @{ $options->{exclude} };
|
||||
if (@excludePatterns) {
|
||||
my $pattern = join q{|}, @excludePatterns;
|
||||
warn $pattern;
|
||||
my $exclusions = qr/$pattern/;
|
||||
@modules = grep { ! m/$exclusions/ } @modules;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue