Skip to content

Instantly share code, notes, and snippets.

Created December 26, 2012 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/4380878 to your computer and use it in GitHub Desktop.
Save anonymous/4380878 to your computer and use it in GitHub Desktop.
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>techmemo@gmail.comE<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