« blib/lib/Dist/Zilla/PluginBundle/LOGIE.pm
↑ Summary
Dist-Zilla-PluginBundle-LOGIE-0.01/t/release-eol.t »
| 1 | #!perl | ||||||||||
| 2 | |||||||||||
| 3 | 4 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 4 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 4 | ▶ | use Test::More; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | |||||||||||
| 9 | |||||||||||
| 10 | 4 | ▶ | use File::Find; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 4 | ▶ | use File::Temp qw{ tempdir }; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | 4 | my @modules; | |||||||||
| 14 | find( | ||||||||||
| 15 | 20 | ▶ | sub { | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||
| 16 | 20 | ▶ | return if $File::Find::name !~ /\.pm\z/; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 17 | 4 | my $found = $File::Find::name; | |||||||||
| 18 | 4 | $found =~ s{^lib/}{}; | |||||||||
| 19 | 4 | $found =~ s{[/\\]}{::}g; | |||||||||
| 20 | 4 | $found =~ s/\.pm$//; | |||||||||
| 21 | # nothing to skip | ||||||||||
| 22 | 4 | push @modules, $found; | |||||||||
| 23 | }, | ||||||||||
| 24 | 4 | 'lib', | |||||||||
| 25 | ); | ||||||||||
| 26 | |||||||||||
| 27 | 0 | ▶ | sub _find_scripts { | ||||||||
|
Subroutine
_find_scripts: not called CC=1 SCAR=6.9
| |||||||||||
| 28 | 0 | my $dir = shift @_; | |||||||||
| 29 | |||||||||||
| 30 | 0 | my @found_scripts = (); | |||||||||
| 31 | find( | ||||||||||
| 32 | 0 | ▶ | sub { | ||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||
| 33 | 0 | ▶ | return unless -f; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | 0 | my $found = $File::Find::name; | |||||||||
| 35 | # nothing to skip | ||||||||||
| 36 | 0 | ▶ | open my $FH, '<', $_ or do { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | 0 | note( "Unable to open $found in ( $! ), skipping" ); | |||||||||
| 38 | 0 | return; | |||||||||
| 39 | }; | ||||||||||
| 40 | 0 | my $shebang = <$FH>; | |||||||||
| 41 | 0 | ▶ | return unless $shebang =~ /^#!.*?\bperl\b\s*$/; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 42 | 0 | push @found_scripts, $found; | |||||||||
| 43 | }, | ||||||||||
| 44 | 0 | $dir, | |||||||||
| 45 | ); | ||||||||||
| 46 | |||||||||||
| 47 | 0 | return @found_scripts; | |||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | 4 | my @scripts; | |||||||||
| 51 | 12 | ▶ | do { push @scripts, _find_scripts($_) if -d $_ } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 52 | 4 | for qw{ bin script scripts }; | |||||||||
| 53 | |||||||||||
| 54 | 4 | my $plan = scalar(@modules) + scalar(@scripts); | |||||||||
| 55 | 4 | ▶ | $plan ? (plan tests => $plan) : (plan skip_all => "no tests to run"); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 56 | |||||||||||
| 57 | { | ||||||||||
| 58 | # fake home for cpan-testers | ||||||||||
| 59 | # no fake requested ## local $ENV{HOME} = tempdir( CLEANUP => 1 ); | ||||||||||
| 60 | |||||||||||
| 61 | 4 | like( qx{ $^X -Ilib -e "require $_; print '$_ ok'" }, qr/^\s*$_ ok/s, "$_ loaded ok" ) | |||||||||
| 62 | 4 | for sort @modules; | |||||||||
| 63 | |||||||||||
| 64 | SKIP: { | ||||||||||
| 65 | 0 | ▶ | eval "use Test::Script 1.05; 1;"; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.6
| |||||||||||
| 66 | 4 | ▶ | skip "Test::Script needed to test script compilation", scalar(@scripts) if $@; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 67 | 0 | foreach my $file ( @scripts ) { | |||||||||
| 68 | 0 | my $script = $file; | |||||||||
| 69 | 0 | $script =~ s!.*/!!; | |||||||||
| 70 | 0 | script_compiles( $file, "$script script compiles" ); | |||||||||
| 71 | } | ||||||||||
| 72 | } | ||||||||||
| 73 | } | ||||||||||