Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions Bugzilla/Install/Requirements.pm
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,20 @@ use constant FEATURE_FILES => (
inbound_email => ['email_in.pl'],
jobqueue => [
'Bugzilla/Job/*', 'Bugzilla/JobQueue.pm',
'Bugzilla/JobQueue/*', 'jobqueue.pl'
'Bugzilla/JobQueue/*', 'jobqueue.pl',
'jobqueue-worker.pl'
],
patch_viewer => ['Bugzilla/Attachment/PatchReader.pm'],
updates => ['Bugzilla/Update.pm'],
mfa => ['Bugzilla/MFA/*.pm'],
memcached => ['Bugzilla/Memcache.pm'],
s3 => ['Bugzilla/S3.pm', 'Bugzilla/S3/Bucket.pm', 'Bugzilla/Attachment/S3.pm']
patch_viewer => ['Bugzilla/Attachment/PatchReader.pm'],
updates => ['Bugzilla/Update.pm'],
mfa => ['Bugzilla/MFA/*.pm'],
memcached => ['Bugzilla/Memcache.pm'],
oauth2_server => ['Bugzilla/App/Plugin/OAuth2.pm'],
alien_cmark => ['Bugzilla/Markdown/GFM.pm', 'Bugzilla/Markdown/GFM/*.pm'],
chart_clicker => ['Bugzilla/Report/SecurityRisk.pm'],
s3 => [
'Bugzilla/S3.pm', 'Bugzilla/S3/Bucket.pm',
'Bugzilla/Attachment/S3.pm', 'Bugzilla/Attachment/Storage/S3.pm'
]
);

sub check_all_cpan_features {
Expand Down
110 changes: 110 additions & 0 deletions t/001compile.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This Source Code Form is "Incompatible With Secondary Licenses", as
# defined by the Mozilla Public License, v. 2.0.


#################
#Bugzilla Test 1#
###Compilation###

use 5.10.1;
use strict;
use warnings;

use lib qw(. lib t);
use Config;
use Support::Files;
use Test::More tests => scalar(@Support::Files::testitems)
+ scalar(@Support::Files::test_files);

BEGIN {
use_ok('Bugzilla::Constants');
use_ok('Bugzilla::Install::Requirements');
use_ok('Bugzilla');
}

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 =~ s/\.pm$//) {

# Extension modules live at extensions/<Name>/lib/<Path>.pm but declare
# the package Bugzilla::Extension::<Name>::<Path>. Map to the real package
# name so use_ok() finds the module already loaded by the extension loader,
# instead of recompiling it under a bogus path-derived name (which breaks
# Moo-generated accessors and inlined constructors).
if ($file =~ s{^extensions/([^/]+)/lib/}{}) {
my $ext_name = $1;
$file =~ s{/}{::}g;
$file = "Bugzilla::Extension::${ext_name}::${file}";
}
else {
$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 = '';
if ($ENV{PERL5LIB}) {
$libs = join " ", map {"-I\"$_\""} split /$Config{path_sep}/, $ENV{PERL5LIB};
}
my $perl = qq{"$^X"};
my $output = `$perl $libs -c$T $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);
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"
and $file ne "Bugzilla/DB/QuoteIdentifier.pm") {
my $module = lc($1);
my $dbd = DB_MODULE->{$module}->{dbd}->{module};
eval("use $dbd; 1") or skip "$file: $dbd not installed", 1;
}

compile_file($file);
}
}
23 changes: 13 additions & 10 deletions t/Support/Files.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ our @additional_files = ();
use constant IGNORE => qw(
Bugzilla/DuoAPI.pm
Bugzilla/DuoWeb.pm
Bugzilla/Test/MockDB.pm
Bugzilla/Report/Ping/Simple.pm
);

our @files = glob('*');
Expand All @@ -30,20 +32,21 @@ our @extensions = grep { $_ ne 'extensions/create.pl' && !-e "$_/disabled" }
glob('extensions/*');

foreach my $extension (@extensions) {
find(sub { push(@files, $File::Find::name) if $_ =~ /\.pm$|\.pl$/; },
$extension);
find(
sub {
# Skip files under a disabled sub-directory (e.g. Connector.disabled/)
# and template data files (template/.../*.pl), which are not
# stand-alone modules or scripts and cannot be compiled on their own.
return if $File::Find::name =~ m{\.disabled(?:/|$)};
return if $File::Find::name =~ m{/template/};
push(@files, $File::Find::name) if $_ =~ /\.pm$|\.pl$/;
},
$extension
);
}

our @test_files = glob('t/*.t xt/*/*.t');

foreach my $extension (@extensions) {

# Skip disabled extensions
next if -e "$extension/disabled";

find(sub { push(@files, $File::Find::name) if $_ =~ /\.pm$/; }, $extension);
}

sub isTestingFile {
my ($file) = @_;
my $exclude;
Expand Down
Loading