Created
July 31, 2014 14:23
-
-
Save jonasbn/61f5e3ff8a2ed289b48c to your computer and use it in GitHub Desktop.
Perl test to compile contents of lib/
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 | |
#Courtesy of Ovid | |
#Ref: http://use.perl.org/~Ovid/journal/37797 | |
use strict; | |
use warnings; | |
use File::Find; | |
use File::Spec; | |
use lib 'lib'; | |
use Test::More; | |
BEGIN { | |
my $DIR = 'lib/'; | |
sub to_module($) { | |
my $file = shift; | |
$file =~ s{\.pm$}{}; | |
$file =~ s{\\}{/}g; # to make win32 happy | |
$file =~ s/^$DIR//; | |
return join '::' => grep _ => File::Spec->splitdir($file); | |
} | |
my @modules; | |
find({ | |
no_chdir => 1, | |
wanted => sub { | |
push @modules => map { to_module $_ } $File::Find::name | |
if /\.pm$/; | |
}, | |
}, $DIR | |
); | |
plan tests => scalar @modules; | |
for my $module (@modules) { | |
use_ok $module or BAIL_OUT("Could not use $module"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment