1 # -*- Mode: perl; indent-tabs-mode: nil -*-
3 # The contents of this file are subject to the Mozilla Public
4 # License Version 1.1 (the "License"); you may not use this file
5 # except in compliance with the License. You may obtain a copy of
6 # the License at http://www.mozilla.org/MPL/
8 # Software distributed under the License is distributed on an "AS
9 # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
10 # implied. See the License for the specific language governing
11 # rights and limitations under the License.
13 # The Original Code are the Bugzilla Tests.
15 # Contributor(s): David Miller <justdave@bugzilla.org>
16 # Frédéric Buclin <LpSolit@gmail.com>
28 use Test::More qw(no_plan);
33 # Extract all Perl modules.
34 foreach my $file (@Support::Files::testitems) {
35 if ($file =~ /^(.*)\.pm$/) {
38 $mods{$module} = $file;
42 foreach my $module (keys %mods) {
46 open(SOURCE, $mods{$module});
47 while (my $line = <SOURCE>) {
48 last if ($line =~ /^__END__/);
49 if ($line =~ /^=cut/) {
54 if ($line =~ /^=(head|over|item|back|pod|begin|end|for)/) {
58 if ($line =~ /^package\s+([^;]);/) {
61 elsif ($line =~ /^\s*(?:use|^require) *"?(Bugzilla.*?)"?(?:;|\s+qw[\(\{]|\s+\(\))/) {
65 $used =~ s#\$module#[^:]+#;
66 $used =~ s#\${[^}]+}#[^:]+#;
69 if ($used eq 'Bugzilla::Auth::Login::[^:]+' ) { $exclude = 'Bugzilla::Auth::Login::Stack' }
70 elsif ($used eq 'Bugzilla::Auth::Verify::[^:]+') { $exclude = 'Bugzilla::Auth::Verify::Stack' }
71 elsif ($used eq 'Bugzilla::Config::[^:]+' ) { $exclude = 'Bugzilla::Config::Common' }
72 push(@use, grep(/^$used$/, grep(!/^$exclude$/, keys %mods)));
77 foreach my $u (@use) {
78 if (!grep {$_ eq $u} @{$deps{$module}}) {
79 push(@{$deps{$module}}, $u);
85 my ($module, $used_module) = @_;
86 my @list = ($used_module);
88 while (my $next = shift @list) {
89 if ($module eq $next) {
90 ok(0, "Dependency on $used_module from $module causes loop. --ERROR");
94 push(@list, @{$deps{$next}}) if defined $deps{$next};
98 ok(1, "No dependency loop between $module and $used_module");
102 foreach my $module (keys %deps) {
103 foreach my $used_module (@{$deps{$module}}) {
104 creates_loop($module, $used_module);