Create a gist now

Instantly share code, notes, and snippets.

perl module use_ok test
#!/usr/bin/env perl
use strict;
use warnings;
use File::Find;
use Test::More;
my @TARGET_DIR = (qw/ lib /);
subtest 'test_syntax' => sub{
for my $dir ( @TARGET_DIR ){
File::Find::find({
wanted => sub {
my $path = $File::Find::name;
if ($path =~ qr{(.*\.pm)$}xms) {
my $namespace = _path2namespace( $path );
use_ok( $namespace );
}
},
preprocess => sub {
grep { $_ ne '.git' } @_;
},
}, $dir);
}
};
sub _path2namespace{
my $path = shift;
$path =~ s!(\Alib/|\.pm\z)!!g;
$path =~ s!/!::!g;
return $path;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment