Commit 17867ff9 authored by Max Kanat-Alexander's avatar Max Kanat-Alexander

Bug 559999: Make t/010dependencies.t consider "use base" to be just like "use"

r=timello, a=mkanat
parent 67cf215f
...@@ -21,8 +21,7 @@ ...@@ -21,8 +21,7 @@
## dependencies ## ## dependencies ##
use strict; use strict;
use lib qw(. lib t);
use lib 't';
use Support::Files; use Support::Files;
use Test::More qw(no_plan); use Test::More qw(no_plan);
...@@ -30,6 +29,16 @@ use Test::More qw(no_plan); ...@@ -30,6 +29,16 @@ use Test::More qw(no_plan);
my %mods; my %mods;
my %deps; my %deps;
use constant MODULE_REGEX => qr/
(?:(?:^\s*use)
|
(?:^require)
)\s+
['"]?
([\w:\.\\]+)
/x;
use constant BASE_REGEX => qr/^use base qw\(([^\)]+)/;
# Extract all Perl modules. # Extract all Perl modules.
foreach my $file (@Support::Files::testitems) { foreach my $file (@Support::Files::testitems) {
if ($file =~ /^(.*)\.pm$/) { if ($file =~ /^(.*)\.pm$/) {
...@@ -58,18 +67,19 @@ foreach my $module (keys %mods) { ...@@ -58,18 +67,19 @@ foreach my $module (keys %mods) {
if ($line =~ /^package\s+([^;]);/) { if ($line =~ /^package\s+([^;]);/) {
$module = $1; $module = $1;
} }
elsif ($line =~ /^\s*(?:use|^require) *"?(Bugzilla.*?)"?(?:;|\s+qw[\(\{]|\s+\(\))/) { elsif ($line =~ BASE_REGEX or $line =~ MODULE_REGEX) {
my $used = $1; my $used_string = $1;
$used =~ s#/#::#g; # "use base" can have multiple modules
$used =~ s#\.pm$##; my @used_array = split(/\s+/, $used_string);
$used =~ s#\$module#[^:]+#; foreach my $used (@used_array) {
$used =~ s#\${[^}]+}#[^:]+#; next if $used !~ /^Bugzilla/;
$used =~ s#[" ]##g; $used =~ s#/#::#g;
my $exclude = ""; $used =~ s#\.pm$##;
if ($used eq 'Bugzilla::Auth::Login::[^:]+' ) { $exclude = 'Bugzilla::Auth::Login::Stack' } $used =~ s#\$module#[^:]+#;
elsif ($used eq 'Bugzilla::Auth::Verify::[^:]+') { $exclude = 'Bugzilla::Auth::Verify::Stack' } $used =~ s#\${[^}]+}#[^:]+#;
elsif ($used eq 'Bugzilla::Config::[^:]+' ) { $exclude = 'Bugzilla::Config::Common' } $used =~ s#[" ]##g;
push(@use, grep(/^$used$/, grep(!/^$exclude$/, keys %mods))); push(@use, grep(/^\Q$used\E$/, keys %mods));
}
} }
} }
close (SOURCE); close (SOURCE);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment