#!/opt/perl524 use strict; use warnings; BEGIN { use Test::Compile::Internal; no warnings 'redefine'; *Test::Compile::Internal::all_pl_files = sub { my ( $self, @dirs ) = @_; @dirs = @dirs ? @dirs : _pl_starting_points(); my @pl; for my $file ( $self->_find_files(@dirs) ) { if ( $file =~ /(\.pl|\.psgi|\.cgi)$/i ) { # Files with .pl or .psgi or .cgi extensions are perl scripts push @pl, $file; my $shebang = $self->_read_shebang($file); if ( $shebang =~ m/perl/ ) { $shebang =~ s/\s+$//; $Test::Compile::Internal::shebang_of_file{$file} = $shebang; } } elsif ( $file =~ /(?:^[^.]+$)/ ) { # Files with no extension, but a perl shebang are perl scripts my $shebang = $self->_read_shebang($file); if ( $shebang =~ m/perl/ ) { push @pl, $file; $shebang =~ s/\s+$//; $Test::Compile::Internal::shebang_of_file{$file} = $shebang; } } } return @pl; }; *Test::Compile::Internal::_perl_file_compiles = sub { my ( $self, $file ) = @_; if ( !-f $file ) { $self->{test}->diag("$file could not be found") if $self->verbose(); return 0; } my @inc = ( 'blib/lib', @INC ); my $taint = $self->_is_in_taint_mode($file); my $command; if ( $Test::Compile::Internal::shebang_of_file{$file} ) { ( my $executable_filename = $Test::Compile::Internal::shebang_of_file{$file} ) =~ s/#!//; $command = join( " ", ( $executable_filename, "-c$taint", $file ) ); } else { $command = join( " ", ( qq{"$^X"}, ( map {qq{"-I$_"}} @inc ), "-c$taint", $file ) ); } if ( $self->verbose() ) { $self->{test}->diag( "Executing: " . $command ); } my ( $compiles, $output ); eval { ( $compiles, $output ) = $self->_run_command($command); # $output is a reference to an array of one or more lines. 1; } or do { my $array_ref_holding_custom_output = ["Can't run command '$command' for compilation test on file '$file': $@"]; ( $compiles, $output ) = ( 0, $array_ref_holding_custom_output ); }; if ( $output && ( !defined( $self->verbose() ) || $self->verbose() != 0 ) ) { if ( !$compiles || $self->verbose() ) { for my $line (@$output) { $self->{test}->diag($line); } } } return $compiles; }; } ## end BEGIN my $test = Test::Compile::Internal->new(); $test->all_files_ok('/www/cgi-bin'); $test->done_testing(); #### sub _perl_file_compiles { my ($self, $file) = @_; if ( ! -f $file ) { $self->{test}->diag("$file could not be found") if $self->verbose(); return 0; } my @inc = ('blib/lib', @INC); my $taint = $self->_is_in_taint_mode($file); my $command = join(" ", (qq{"$^X"}, (map { qq{"-I$_"} } @inc), "-c$taint", $file)); if ( $self->verbose() ) { $self->{test}->diag("Executing: " . $command); } my ($compiles, $output) = $self->_run_command($command); if ( $output && (!defined($self->verbose()) || $self->verbose() != 0) ) { if ( !$compiles || $self->verbose() ) { for my $line ( @$output ) { $self->{test}->diag($line); } } } return $compiles; }