summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbugreport%peshkin.net <>2002-08-26 02:19:03 +0200
committerbugreport%peshkin.net <>2002-08-26 02:19:03 +0200
commitbe0b080ba47cf3431119d61c5b1ef4c443d318f4 (patch)
tree620ab58d66bdb90461dcf9235844d559cfcbf089
parent35d4b47b98c2f8a9c9813090e11c33c20a8e2dbb (diff)
downloadbugzilla-be0b080ba47cf3431119d61c5b1ef4c443d318f4.tar.gz
bugzilla-be0b080ba47cf3431119d61c5b1ef4c443d318f4.tar.xz
Bug 163494 - runtests.sh needs a switch to include optional modules
Tests now detect optional modules and only exclude optional files if optional module dependencies are not met. Also major indent cleanup r=timeless
-rw-r--r--t/Support/Files.pm54
1 files changed, 38 insertions, 16 deletions
diff --git a/t/Support/Files.pm b/t/Support/Files.pm
index e68d08ea7..2e9e9f3c3 100644
--- a/t/Support/Files.pm
+++ b/t/Support/Files.pm
@@ -18,6 +18,7 @@
# Rights Reserved.
#
# Contributor(s): Zach Lipton <zach@zachlipton.com>
+# Joel Peshkin <bugreport@peshkin.net>
#
# Alternatively, the contents of this file may be used under the
# terms of the GNU General Public License Version 2 or later (the
@@ -34,34 +35,55 @@
package Support::Files;
+# exclude_deps is a hash of arrays listing the files to be excluded
+# if a module is not available
+#
@additional_files = ('syncshadowdb','processmail');
-@exclude_files = ('importxml.pl');
+%exclude_deps = (
+ 'XML::Parser' => ['importxml.pl'],
+);
+
# XXX - this file should be rewritten to use File::Find or similar
$file = '*';
@files = (glob($file), glob('Bugzilla/*.pm'));
+sub have_pkg {
+ my ($pkg) = @_;
+ my ($msg, $vnum, $vstr);
+ no strict 'refs';
+ eval { my $p; ($p = $pkg . ".pm") =~ s!::!/!g; require $p; };
+ return !($@);
+}
+
+@exclude_files = ();
+foreach $dep (keys(%exclude_deps)) {
+ if (!have_pkg($dep)) {
+ push @exclude_files, @{$exclude_deps{$dep}};
+ }
+}
+
sub isTestingFile {
- my ($file) = @_;
- my $exclude;
- foreach $exclude (@exclude_files) {
+ my ($file) = @_;
+ my $exclude;
+ foreach $exclude (@exclude_files) {
if ($file eq $exclude) { return undef; } # get rid of excluded files.
- }
+ }
- if ($file =~ /\.cgi$|\.pl$|\.pm$/) {
- return 1;
- }
- my $additional;
- foreach $additional (@additional_files) {
- if ($file eq $additional) { return 1; }
- }
- return undef;
+ if ($file =~ /\.cgi$|\.pl$|\.pm$/) {
+ return 1;
+ }
+ my $additional;
+ foreach $additional (@additional_files) {
+ if ($file eq $additional) { return 1; }
+ }
+ return undef;
}
foreach $currentfile (@files) {
- if (isTestingFile($currentfile)) {
- push(@testitems,$currentfile);
- }
+ if (isTestingFile($currentfile)) {
+ push(@testitems,$currentfile);
+ }
}