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 @@
## dependencies ##
use strict;
use lib 't';
use lib qw(. lib t);
use Support::Files;
use Test::More qw(no_plan);
......@@ -30,6 +29,16 @@ use Test::More qw(no_plan);
my %mods;
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.
foreach my $file (@Support::Files::testitems) {
if ($file =~ /^(.*)\.pm$/) {
......@@ -58,18 +67,19 @@ foreach my $module (keys %mods) {
if ($line =~ /^package\s+([^;]);/) {
$module = $1;
}
elsif ($line =~ /^\s*(?:use|^require) *"?(Bugzilla.*?)"?(?:;|\s+qw[\(\{]|\s+\(\))/) {
my $used = $1;
$used =~ s#/#::#g;
$used =~ s#\.pm$##;
$used =~ s#\$module#[^:]+#;
$used =~ s#\${[^}]+}#[^:]+#;
$used =~ s#[" ]##g;
my $exclude = "";
if ($used eq 'Bugzilla::Auth::Login::[^:]+' ) { $exclude = 'Bugzilla::Auth::Login::Stack' }
elsif ($used eq 'Bugzilla::Auth::Verify::[^:]+') { $exclude = 'Bugzilla::Auth::Verify::Stack' }
elsif ($used eq 'Bugzilla::Config::[^:]+' ) { $exclude = 'Bugzilla::Config::Common' }
push(@use, grep(/^$used$/, grep(!/^$exclude$/, keys %mods)));
elsif ($line =~ BASE_REGEX or $line =~ MODULE_REGEX) {
my $used_string = $1;
# "use base" can have multiple modules
my @used_array = split(/\s+/, $used_string);
foreach my $used (@used_array) {
next if $used !~ /^Bugzilla/;
$used =~ s#/#::#g;
$used =~ s#\.pm$##;
$used =~ s#\$module#[^:]+#;
$used =~ s#\${[^}]+}#[^:]+#;
$used =~ s#[" ]##g;
push(@use, grep(/^\Q$used\E$/, keys %mods));
}
}
}
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