Created
February 3, 2015 02:50
-
-
Save masartz/70df3a81ef6829a342d2 to your computer and use it in GitHub Desktop.
perl module use_ok test
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
#!/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