File Coverage

blib/lib/Module/Depends/Intrusive.pm
Criterion Covered Total %
statement 74 86 86.0
branch 11 16 68.7
condition 4 8 50.0
subroutine 15 20 75.0
pod n/a
total 104 130 80.0


line stmt bran cond sub pod time code
1 1     1   1378 use strict;
  1         2  
  1         59  
2             package Module::Depends::Intrusive;
3 1     1   5 use base qw( Module::Depends );
  1         3  
  1         93  
4 1     1   7 use Cwd qw( getcwd );
  1         2  
  1         112  
5 1     1   1418 use ExtUtils::MakeMaker ();
  1         135084  
  1         172  
6              
7             sub _find_modules {
8 10     10   13 my $self = shift;
9              
10             # this order is important, as when a Makefile.PL and Build.PL are
11             # present, the Makefile.PL could just be a passthrough
12 10 100       190 my $pl = -e 'Build.PL' ? 'Build.PL' : -e 'Makefile.PL' ? 'Makefile.PL' : 0;
    100          
13 10 100       26 unless ($pl) {
14 1         4 $self->error( 'No {Build,Makefile}.PL found in '.$self->dist_dir );
15 1         19 return $self;
16             }
17              
18             # fake up Module::Build and ExtUtils::MakeMaker
19 1     1   9 no warnings 'redefine';
  1         2  
  1         778  
20 9         20 local *STDIN; # run non-interactive
21             local *ExtUtils::Liblist::ext = sub {
22 0     0   0 my ($class, $lib) = @_;
23 0         0 $lib =~ s/\-l//;
24 0         0 push @{ $self->libs }, $lib;
  0         0  
25 0         0 return 1;
26 9         51 };
27 9     0   34 local *CORE::GLOBAL::exit = sub { };
  0         0  
28 9         25 local $INC{"Module/Build.pm"} = 1;
29 9         280 local @MyModuleBuilder::ISA = qw( Module::Build );
30             local *Module::Build::new = sub {
31 2     2   255 my $class = shift;
32 2         11 my %args = @_;
33 2   50     23 $self->requires( $args{requires} || {} );
34 2   100     44 $self->build_requires( $args{build_requires} || {} );
35 2         38 bless {}, "Module::Depends::Intrusive::Fake::Module::Build";
36 9         70 };
37 9     0   32 local *Module::Build::subclass = sub { 'Module::Build' };
  0         0  
38 9         15 local $Module::Build::VERSION = 666;
39              
40             my $WriteMakefile = sub {
41 4     4   3304 my %args = @_;
42 4   50     39 $self->requires( $args{PREREQ_PM} || {} );
43 4         102 1;
44 9         32 };
45 9         20 local *main::WriteMakefile;
46 9         19 local *ExtUtils::MakeMaker::WriteMakefile = $WriteMakefile;
47              
48             # Inline::MakeMaker
49 9         19 local $INC{"Inline/MakeMaker.pm"} = 1;
50              
51 9         25 local @Inline::MakeMaker::EXPORT = qw( WriteMakefile WriteInlineMakefile );
52 9         188 local @Inline::MakeMaker::ISA = qw( Exporter );
53 9         36 local *Inline::MakeMaker::WriteMakefile = $WriteMakefile;
54 9         14 local *Inline::MakeMaker::WriteInlineMakefile = $WriteMakefile;
55              
56             # Module::Install
57 9         18 local $INC{"inc/Module/Install.pm"} = 1;
58 9         16 local $inc::Module::Install::VERSION = 666;
59 9         234 local @inc::Module::Install::ISA = qw( Exporter );
60 9         103 local @inc::Module::Install::EXPORT = qw(
61             configure_requires repository bugtracker
62             all_from auto_install AUTOLOAD build_requires check_nmake include
63             include_deps installdirs Makefile makemaker_args Meta name no_index
64             requires WriteAll clean_files can_cc sign cc_inc_paths cc_files
65             cc_optimize_flags author license
66              
67             );
68 9     17   155 local *inc::Module::Install::AUTOLOAD = sub { 1 };
  17         1879  
69             local *inc::Module::Install::requires = sub {
70 3 50   3   21 my %deps = (@_ == 1 ? ( $_[0] => 0 ) : @_);
71 3         26 $self->requires->{ $_ } = $deps{ $_ } for keys %deps;
72 9         34 };
73 9         30 local *inc::Module::Install::include_deps = *inc::Module::Install::requires;
74             local *inc::Module::Install::build_requires = sub {
75 4 100   4   157 my %deps = (@_ == 1 ? ( $_[0] => 0 ) : @_);
76 4         22 $self->build_requires->{ $_ } = $deps{ $_ } for keys %deps;
77 9         51 };
78             local *inc::Module::Install::configure_requires = sub {
79 2 50   2   29 my %deps = (@_ == 1 ? ( $_[0] => 0 ) : @_);
80 2         11 $self->configure_requires->{ $_ } = $deps{ $_ } for keys %deps;
81 9         39 };
82              
83 9         242 my $file = File::Spec->catfile( getcwd(), $pl );
84 9         23 eval {
85             package main;
86 1     1   7 no strict;
  1         2  
  1         28  
87 1     1   5 no warnings;
  1         2  
  1         282  
88 9         128 local $0 = $file;
89 9         3635 do "$file";
90             };
91 9 50       109 $self->error( $@ ) if $@;
92 9         23 delete $INC{$file};
93 9         486 return $self;
94             }
95              
96             package Module::Depends::Intrusive::Fake::Module::Build;
97 0     0   0 sub DESTROY {}
98 2     2   35 sub AUTOLOAD { shift }
99             sub y_n {
100 0     0     my ($self, $question, $default) = @_;
101 0   0       $default ||= 'n';
102 0 0         return 1 if lc $default eq 'y';
103 0           return 0; # ok, we may say no when yes was intended, but we can't hang
104             }
105              
106             1;
107              
108             __END__