diff options
Diffstat (limited to 't/001compile.t')
-rw-r--r-- | t/001compile.t | 141 |
1 files changed, 71 insertions, 70 deletions
diff --git a/t/001compile.t b/t/001compile.t index 3d8d82bf4..ae609d5ba 100644 --- a/t/001compile.t +++ b/t/001compile.t @@ -18,58 +18,59 @@ use lib qw(. lib local/lib/perl5 t); use Config; use Support::Files; use Test::More; -BEGIN { - if ($ENV{CI}) { - plan skip_all => 'Not running compile tests in CI.'; - exit; - } - plan tests => @Support::Files::testitems + @Support::Files::test_files; - use_ok('Bugzilla::Constants'); - use_ok('Bugzilla::Install::Requirements'); - use_ok('Bugzilla'); +BEGIN { + if ($ENV{CI}) { + plan skip_all => 'Not running compile tests in CI.'; + exit; + } + plan tests => @Support::Files::testitems + @Support::Files::test_files; + + use_ok('Bugzilla::Constants'); + use_ok('Bugzilla::Install::Requirements'); + use_ok('Bugzilla'); } Bugzilla->usage_mode(USAGE_MODE_TEST); sub compile_file { - my ($file) = @_; - - # Don't allow CPAN.pm to modify the global @INC, which the version - # shipped with Perl 5.8.8 does. (It gets loaded by - # Bugzilla::Install::CPAN.) - local @INC = @INC; - - if ($file =~ /extensions/) { - skip "$file: extensions not tested", 1; - return; - } - - if ($file =~ s/\.pm$//) { - $file =~ s{/}{::}g; - use_ok($file); - return; - } - - open(my $fh, $file); - my $bang = <$fh>; - close $fh; - - my $T = ""; - if ($bang =~ m/#!\S*perl\s+-.*T/) { - $T = "T"; - } - - my $libs = '-It '; - if ($ENV{PERL5LIB}) { - $libs .= join " ", map { "-I\"$_\"" } split /$Config{path_sep}/, $ENV{PERL5LIB}; - } - my $perl = qq{"$^X"}; - my $output = `$perl $libs -c$T -MSupport::Systemexec $file 2>&1`; - chomp($output); - my $return_val = $?; - $output =~ s/^\Q$file\E syntax OK$//ms; - diag($output) if $output; - ok(!$return_val, $file) or diag('--ERROR'); + my ($file) = @_; + + # Don't allow CPAN.pm to modify the global @INC, which the version + # shipped with Perl 5.8.8 does. (It gets loaded by + # Bugzilla::Install::CPAN.) + local @INC = @INC; + + if ($file =~ /extensions/) { + skip "$file: extensions not tested", 1; + return; + } + + if ($file =~ s/\.pm$//) { + $file =~ s{/}{::}g; + use_ok($file); + return; + } + + open(my $fh, $file); + my $bang = <$fh>; + close $fh; + + my $T = ""; + if ($bang =~ m/#!\S*perl\s+-.*T/) { + $T = "T"; + } + + my $libs = '-It '; + if ($ENV{PERL5LIB}) { + $libs .= join " ", map {"-I\"$_\""} split /$Config{path_sep}/, $ENV{PERL5LIB}; + } + my $perl = qq{"$^X"}; + my $output = `$perl $libs -c$T -MSupport::Systemexec $file 2>&1`; + chomp($output); + my $return_val = $?; + $output =~ s/^\Q$file\E syntax OK$//ms; + diag($output) if $output; + ok(!$return_val, $file) or diag('--ERROR'); } my @testitems = (@Support::Files::testitems, @Support::Files::test_files); @@ -77,28 +78,28 @@ my $file_features = map_files_to_features(); # Test the scripts by compiling them foreach my $file (@testitems) { - # These were already compiled, above. - next if ($file eq 'Bugzilla.pm' - or $file eq 'Bugzilla/Constants.pm' - or $file eq 'Bugzilla/Install/Requirements.pm'); - SKIP: { - if ($file eq 'mod_perl.pl') { - skip 'mod_perl.pl cannot be compiled from the command line', 1; - } - my $feature = $file_features->{$file}; - if ($feature and !Bugzilla->feature($feature)) { - skip "$file: $feature not enabled", 1; - } - - # Check that we have a DBI module to support the DB, if this - # is a database module (but not Schema) - if ($file =~ m{Bugzilla/DB/([^/]+)\.pm$} - and $file ne "Bugzilla/DB/Schema.pm") - { - my $module = lc($1); - Bugzilla->feature($module) or skip "$file: Driver for $module not installed", 1; - } - - compile_file($file); + + # These were already compiled, above. + next + if ($file eq 'Bugzilla.pm' + or $file eq 'Bugzilla/Constants.pm' + or $file eq 'Bugzilla/Install/Requirements.pm'); +SKIP: { + if ($file eq 'mod_perl.pl') { + skip 'mod_perl.pl cannot be compiled from the command line', 1; } + my $feature = $file_features->{$file}; + if ($feature and !Bugzilla->feature($feature)) { + skip "$file: $feature not enabled", 1; + } + + # Check that we have a DBI module to support the DB, if this + # is a database module (but not Schema) + if ($file =~ m{Bugzilla/DB/([^/]+)\.pm$} and $file ne "Bugzilla/DB/Schema.pm") { + my $module = lc($1); + Bugzilla->feature($module) or skip "$file: Driver for $module not installed", 1; + } + + compile_file($file); + } } |