Created
December 26, 2012 15:19
-
-
Save anonymous/4380878 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Test::AllModules; | |
use strict; | |
use warnings; | |
use Module::Pluggable::Object; | |
use List::MoreUtils qw(any); | |
use Test::More (); | |
our $VERSION = '0.01'; | |
use Exporter; | |
our @ISA = qw/Exporter/; | |
our @EXPORT = qw/all_ok/; | |
sub all_ok { | |
my %param = @_; | |
my $search_path = $param{search_path}; | |
my @checks = @{ $param{checks} || [] }; | |
unless ($search_path) { | |
Test::More::plan skip_all => 'no search path'; | |
exit; | |
} | |
Test::More::plan('no_plan'); | |
my @exceptions = @{ $param{except} || [] }; | |
my @lib | |
= @{ $param{lib} || ['lib'] }; | |
foreach my $class ( | |
grep { !is_excluded( $_, @exceptions ) } | |
sort do { | |
local @INC = @lib; | |
my $finder = Module::Pluggable::Object->new( | |
search_path => $search_path ); | |
( $search_path, $finder->plugins ); | |
} | |
) | |
{ | |
foreach my $check (@checks) { | |
next unless ref($check) eq 'CODE'; | |
Test::More::ok( $check->($class), $class ); | |
} | |
} | |
} | |
sub is_excluded { | |
my ( $module, @exceptions ) = @_; | |
any { $module eq $_ || $module =~ /$_/ } @exceptions; | |
} | |
1; | |
__END__ | |
=encoding utf-8 | |
=head1 NAME | |
Test::AllModules - | |
=head1 SYNOPSIS | |
use Test::AllModules; | |
=head1 DESCRIPTION | |
Test::AllModules is | |
=head1 SOURCE AVAILABILITY | |
This source is in Github: | |
http://github.com/dann/ | |
=head1 CONTRIBUTORS | |
Many thanks to: | |
=head1 AUTHOR | |
Dann E<lt>[email protected]<gt> | |
=head1 SEE ALSO | |
=head1 LICENSE | |
This library is free software; you can redistribute it and/or modify | |
it under the same terms as Perl itself. | |
=cut |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment