-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
this is the fixed version of the wrong test appearing in the distro
- Loading branch information
Reini Urban
committed
Jun 9, 2016
1 parent
2a38dfc
commit f0fa45b
Showing
1 changed file
with
74 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#!perl | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Test::More; | ||
|
||
|
||
|
||
use File::Find; | ||
use File::Temp qw{ tempdir }; | ||
|
||
my @modules; | ||
find( | ||
sub { | ||
return if $File::Find::name !~ /\.pm\z/; | ||
my $found = $File::Find::name; | ||
$found =~ s{^lib/}{}; | ||
$found =~ s{[/\\]}{::}g; | ||
$found =~ s/\.pm$//; | ||
# nothing to skip | ||
push @modules, $found; | ||
}, | ||
'lib', | ||
); | ||
|
||
sub _find_scripts { | ||
my $dir = shift @_; | ||
|
||
my @found_scripts = (); | ||
find( | ||
sub { | ||
return unless -f; | ||
my $found = $File::Find::name; | ||
# nothing to skip | ||
open my $FH, '<', $_ or do { | ||
note( "Unable to open $found in ( $! ), skipping" ); | ||
return; | ||
}; | ||
my $shebang = <$FH>; | ||
return unless $shebang =~ /^#!.*?\bperl\b\s*$/; | ||
push @found_scripts, $found; | ||
}, | ||
$dir, | ||
); | ||
|
||
return @found_scripts; | ||
} | ||
|
||
my @scripts; | ||
do { push @scripts, _find_scripts($_) if -d $_ } | ||
for qw{ bin script scripts }; | ||
|
||
my $plan = scalar(@modules) + scalar(@scripts); | ||
$plan ? (plan tests => $plan) : (plan skip_all => "no tests to run"); | ||
|
||
{ | ||
# fake home for cpan-testers | ||
# no fake requested ## local $ENV{HOME} = tempdir( CLEANUP => 1 ); | ||
|
||
like( qx{ $^X -Mblib -e "require $_; print '$_ ok'" }, qr/^\s*$_ ok/s, "$_ loaded ok" ) | ||
for sort @modules; | ||
|
||
SKIP: { | ||
eval "use Test::Script 1.05; 1;"; | ||
skip "Test::Script needed to test script compilation", scalar(@scripts) if $@; | ||
foreach my $file ( @scripts ) { | ||
my $script = $file; | ||
$script =~ s!.*/!!; | ||
script_compiles( $file, "$script script compiles" ); | ||
} | ||
} | ||
|
||
} |