Skip to content

Instantly share code, notes, and snippets.

@masartz
Created February 3, 2015 02:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masartz/70df3a81ef6829a342d2 to your computer and use it in GitHub Desktop.
Save masartz/70df3a81ef6829a342d2 to your computer and use it in GitHub Desktop.
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