| 1 | package Test::LocalFunctions::Receptor; | ||||||||||
| 2 | |||||||||||
| 3 | 48 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 48 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 48 | ▶ | use ExtUtils::Manifest qw/maniread/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 20 | ▶ | sub all_local_functions_ok { | ||||||||
|
Subroutine
all_local_functions_ok: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||
| 8 | 20 | my ( $backend, $args ) = @_; | |||||||||
| 9 | |||||||||||
| 10 | 20 | my $builder = $backend->builder; | |||||||||
| 11 | 20 | my @libs = _list_modules_in_manifest($builder, $args->{ignore_modules}); | |||||||||
| 12 | |||||||||||
| 13 | 20 | $builder->plan( tests => scalar @libs ); | |||||||||
| 14 | |||||||||||
| 15 | 20 | my $fail = 0; | |||||||||
| 16 | 20 | for my $lib (@libs) { | |||||||||
| 17 | 62 | ▶ | _test_local_functions( $backend, $builder, $lib, $args ) or $fail++; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 18 | } | ||||||||||
| 19 | 4 | return $fail == 0; | |||||||||
| 20 | } | ||||||||||
| 21 | |||||||||||
| 22 | 37 | ▶ | sub local_functions_ok { | ||||||||
|
Subroutine
local_functions_ok: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 23 | 37 | my ( $backend, $lib, $args ) = @_; | |||||||||
| 24 | 37 | return _test_local_functions( $backend, $backend->builder, $lib, $args ); | |||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | 99 | ▶ | sub _test_local_functions { | ||||||||
|
Subroutine
_test_local_functions: called CC=3 SCAR=11.0
| |||||||||||
| 28 | 99 | my ( $caller, $builder, $file, $args ) = @_; | |||||||||
| 29 | |||||||||||
| 30 | 99 | local $Test::Builder::Level = $Test::Builder::Level + 1; | |||||||||
| 31 | |||||||||||
| 32 | 99 | ▶ | my $pid; $pid = fork or do { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | 30 | ▶ | defined $pid ? exit $caller->is_in_use( $builder, $file, $args ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | : die "failed forking: $!" | ||||||||||
| 35 | }; | ||||||||||
| 36 | 69 | wait; | |||||||||
| 37 | 69 | return $builder->ok( $? == 0, $file ); | |||||||||
| 38 | } | ||||||||||
| 39 | |||||||||||
| 40 | 20 | ▶ | sub _list_modules_in_manifest { | ||||||||
|
Subroutine
_list_modules_in_manifest: called CC=5 SCAR=16.1
| |||||||||||
| 41 | 20 | my ( $builder, $ignores ) = @_; | |||||||||
| 42 | |||||||||||
| 43 | 20 | ▶ | if ( not -f $ExtUtils::Manifest::MANIFEST ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 44 | 0 | $builder->plan( skip_all => "$ExtUtils::Manifest::MANIFEST doesn't exist" ); | |||||||||
| 45 | } | ||||||||||
| 46 | 20 | my $manifest = maniread(); | |||||||||
| 47 | 20 | my @libs = grep { m!\Alib/.*\.pm\Z! } keys %{$manifest}; | |||||||||
| 48 | |||||||||||
| 49 | 20 | for my $ignore (@$ignores) { | |||||||||
| 50 | 6 | $ignore =~ s!::!/!g; | |||||||||
| 51 | 6 | $ignore =~ /\.pm\Z/; | |||||||||
| 52 | 6 | ▶ | $ignore .= '.pm' if $& ne '.pm'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 53 | 6 | $ignore =~ m!\Alib/!; | |||||||||
| 54 | 6 | ▶ | $ignore = "lib/$ignore" if $& ne 'lib/'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 55 | 6 | @libs = grep { $_ ne $ignore } @libs; | |||||||||
| 56 | } | ||||||||||
| 57 | 20 | return @libs; | |||||||||
| 58 | } | ||||||||||
| 59 | 48 | 1; | |||||||||