]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 103664 - Tests should "use strict;" and not contain any tabs. We should also...
authorjake%acutex.net <>
Sat, 20 Oct 2001 05:39:46 +0000 (05:39 +0000)
committerjake%acutex.net <>
Sat, 20 Oct 2001 05:39:46 +0000 (05:39 +0000)
Patch by David D. Kilzer <ddkilzer@theracingworld.com>
Additional edits by myself to add the emacs mode line.  Also, the change to runtests.sh was done by me.

runtests.sh
t/001compile.t
t/002goodperl.t
t/003safesys.t
t/004template.t
t/005no_tabs.t
t/Support/Files.pm
t/Support/Systemexec.pm
t/Support/Templates.pm

index c558fcf7dc29058b5045ae7fd5c6319392cb2921..ab18e2e00448c9eb9056651203874439156eb8a8 100755 (executable)
@@ -1,12 +1,12 @@
 #!/bin/sh
 
-export VERBOSE=0
+export TEST_VERBOSE=0
 PART1='use Test::Harness qw(&runtests $verbose); $verbose='
 PART2='; runtests @ARGV;'
 for f in $*; do
   if [ $f == "--verbose" ] ; then
-    export VERBOSE=1
+    export TEST_VERBOSE=1
   fi
 done
 
-/usr/bonsaitools/bin/perl -e "${PART1}${VERBOSE}${PART2}" t/*.t
+/usr/bonsaitools/bin/perl -e "${PART1}${TEST_VERBOSE}${PART2}" t/*.t
index edaa9cacdd23ba20a73145bdfe673bf25ef1ff32..78c1ab477089ea35ec25905fe0dccdbb85121c50 100644 (file)
@@ -1,4 +1,5 @@
-# 
+# -*- Mode: perl; indent-tabs-mode: nil -*-
+#
 # The contents of this file are subject to the Mozilla Public
 # License Version 1.1 (the "License"); you may not use this file
 # except in compliance with the License. You may obtain a copy of
@@ -40,17 +41,15 @@ BEGIN { use Support::Files; }
 BEGIN { $tests = @Support::Files::testitems + 4; }
 BEGIN { use Test::More tests => $tests; }
 
-sub foo {
-$warnings = "foo"; #oy!
-}
+use strict;
 
 # First now we test the scripts                                                   
-@testitems = @Support::Files::testitems; 
+my @testitems = @Support::Files::testitems; 
+my %warnings;
+my $verbose = $::ENV{TEST_VERBOSE};
+my $perlapp = $^X;
 
-my $warnings;
-my $verbose = $::ENV{VERBOSE};
-$perlapp=$^X;
-foreach $file (@testitems) {
+foreach my $file (@testitems) {
         $file =~ s/\s.*$//; # nuke everything after the first space (#comment)
         next if (!$file); # skip null entries
         open (FILE,$file);
@@ -60,20 +59,20 @@ foreach $file (@testitems) {
         if ($bang =~ m/#!\S*perl\s+-.*T/) {
             $T = "T";
         }
-       $command = "$perlapp"." -c$T $file 2>&1";
-       $loginfo=`$command`;
-#        print '@@'.$loginfo.'##';
-       if ($loginfo =~ /syntax ok$/im) {
-               $warnings{$_} = 1 foreach ($loginfo =~ /\((W.*?)\)/mg);
-               if ($1) {
+        my $command = "$perlapp"." -c$T $file 2>&1";
+        my $loginfo=`$command`;
+        #print '@@'.$loginfo.'##';
+        if ($loginfo =~ /syntax ok$/im) {
+                $warnings{$_} = 1 foreach ($loginfo =~ /\((W.*?)\)/mg);
+                if ($1) {
                         if ($verbose) { print STDERR $loginfo; }
                         ok(0,$file."--WARNING");
                 } else {
-                       ok(1,$file);
-               }
-       } else {
+                        ok(1,$file);
+                }
+        } else {
                 if ($verbose) { print STDERR $loginfo; }
-               ok(0,$file."--ERROR");
+                ok(0,$file."--ERROR");
         }
 }      
 
index 8efa8367a60ae62022ff0a557eac3bcc855f912e..3615d489a6ef7580bdd5025ebd54ecba14abe24e 100644 (file)
@@ -1,3 +1,4 @@
+# -*- Mode: perl; indent-tabs-mode: nil -*-
 # 
 # The contents of this file are subject to the Mozilla Public
 # License Version 1.1 (the "License"); you may not use this file
@@ -40,34 +41,37 @@ BEGIN { use Support::Files; }
 BEGIN { $tests = @Support::Files::testitems * 2; }
 BEGIN { use Test::More tests => $tests; }
 
-@testitems = @Support::Files::testitems; # get the files to test.
+use strict;
 
-foreach $file (@testitems) {
+my @testitems = @Support::Files::testitems; # get the files to test.
+my $verbose = $::ENV{TEST_VERBOSE};
+
+foreach my $file (@testitems) {
         $file =~ s/\s.*$//; # nuke everything after the first space (#comment)
         next if (!$file); # skip null entries
-       $filecontent = `cat $file`;
-       if ($filecontent !~ /\/usr\/bonsaitools\/bin\/perl/) {
-               ok(1,"$file does not have a shebang");  
-               next;
-       } else {
-               if ($filecontent =~ m#/usr/bonsaitools/bin/perl -w#) {
-                       ok(1,"$file uses -w");
-                       next;
-               } else {
-                       ok(0,"$file is MISSING -w");
-                       next;
-               }
-       }
+        my $filecontent = `cat $file`;
+        if ($filecontent !~ /\/usr\/bonsaitools\/bin\/perl/) {
+                ok(1,"$file does not have a shebang"); 
+                next;
+        } else {
+                if ($filecontent =~ m#/usr/bonsaitools/bin/perl -w#) {
+                        ok(1,"$file uses -w");
+                        next;
+                } else {
+                        ok(0,"$file is MISSING -w");
+                        next;
+                }
+        }
 }
-foreach $file (@testitems) {
-       $file =~ s/\s.*$//; # nuke everything after the first space (#comment)
-       next if (!$file); # skip null entries
-       $filecontent = `cat $file`;
-       if ($filecontent !~ /use strict/) {
-               ok(0,"$file DOES NOT use strict");
-       } else {
-               ok(1,"$file uses strict");
-       }
+foreach my $file (@testitems) {
+        $file =~ s/\s.*$//; # nuke everything after the first space (#comment)
+        next if (!$file); # skip null entries
+        my $filecontent = `cat $file`;
+        if ($filecontent !~ /use strict/) {
+                ok(0,"$file DOES NOT use strict");
+        } else {
+                ok(1,"$file uses strict");
+        }
 }
 
 
index d114555135a71273b1aef8b67cff35683ae6ce04..94d137aa97ec3580e33b9eeba339d8c2bdc38ef8 100644 (file)
@@ -1,3 +1,4 @@
+# -*- Mode: perl; indent-tabs-mode: nil -*-
 # 
 # The contents of this file are subject to the Mozilla Public
 # License Version 1.1 (the "License"); you may not use this file
@@ -40,19 +41,22 @@ BEGIN { use Support::Files; }
 BEGIN { $tests = @Support::Files::testitems; }    
 BEGIN { use Test::More tests => $tests; }
 
-@testitems = @Support::Files::testitems; 
-my $verbose = $::ENV{VERBOSE};
-$perlapp=$^X;
-foreach $file (@testitems) {
-       $file =~ s/\s.*$//; # nuke everything after the first space (#comment)
-       next if (!$file); # skip null entries
-       $command = "$perlapp -c -It/Support -MSystemexec $file 2>&1";
-       $loginfo=`$command`;
-       if ($loginfo =~ /arguments for Systemexec::system|exec/im) {
-               ok(0,"$file DOES NOT use proper system or exec calls");
-               if ($verbose) { print STDERR $loginfo; }
-       } else {
-               ok(1,"$file uses proper system and exec calls");
-       }
+use strict;
+
+my @testitems = @Support::Files::testitems; 
+my $verbose = $::ENV{TEST_VERBOSE};
+my $perlapp = $^X;
+
+foreach my $file (@testitems) {
+        $file =~ s/\s.*$//; # nuke everything after the first space (#comment)
+        next if (!$file); # skip null entries
+        my $command = "$perlapp -c -It -MSupport::Systemexec $file 2>&1";
+        my $loginfo=`$command`;
+        if ($loginfo =~ /arguments for Support::Systemexec::(system|exec)/im) {
+                ok(0,"$file DOES NOT use proper system or exec calls");
+                if ($verbose) { print STDERR $loginfo; }
+        } else {
+                ok(1,"$file uses proper system and exec calls");
+        }
 }
 
index 6a0b7cd479f799efb3b05b38d8e9a1b5fac6e748..f66176a7217564c049570801a3b0c4ce0ed9a418 100644 (file)
@@ -29,11 +29,12 @@ BEGIN { use Support::Templates; }
 BEGIN { $tests = @Support::Templates::testitems * 2; }
 BEGIN { use Test::More tests => $tests; }
 
+use strict;
 use Template;
 
 my @testitems = @Support::Templates::testitems;
 my $include_path = $Support::Templates::include_path;
-my $verbose = $::ENV{VERBOSE};
+my $verbose = $::ENV{TEST_VERBOSE};
 
 # Check to make sure all templates that are referenced in
 # Bugzilla exist in the proper place.
index fef0bf72ceccf57c91e553b98f5fcc2e955ad963..66b2af5d613ea499c94522eb4a369b3901b4dded 100644 (file)
@@ -21,7 +21,7 @@
 #
 
 #################
-#Bugzilla Test 4#
+#Bugzilla Test 5#
 #####no_tabs#####
 
 BEGIN { use lib "t/"; }
@@ -29,8 +29,10 @@ BEGIN { use Support::Files; }
 BEGIN { $tests = @Support::Files::testitems; }
 BEGIN { use Test::More tests => $tests; }
 
+use strict;
+
 my @testitems = @Support::Files::testitems;
-my $verbose = $::ENV{VERBOSE};
+my $verbose = $::ENV{TEST_VERBOSE};
 
 foreach my $file (@testitems) {
     open (FILE, "$file");
index 9235b5c70a1e04ec916ec6b236841a00d471322f..2396e5d2806c826ca5d194206e09e192919f5d92 100644 (file)
@@ -1,3 +1,4 @@
+# -*- Mode: perl; indent-tabs-mode: nil -*-
 # 
 # The contents of this file are subject to the Mozilla Public
 # License Version 1.1 (the "License"); you may not use this file
@@ -43,7 +44,7 @@ sub isTestingFile {
   my ($file) = @_;
   my $exclude;
   foreach $exclude (@exclude_files) {
-       if ($file eq $exclude) { return undef; } # get rid of excluded files.
+        if ($file eq $exclude) { return undef; } # get rid of excluded files.
   }
 
   if ($file =~ /\.cgi$|\.pl$/) {
@@ -57,9 +58,9 @@ sub isTestingFile {
 }
 
 foreach $currentfile (@files) {
-       if (isTestingFile($currentfile)) {
-               push(@testitems,$currentfile);
-       }
+        if (isTestingFile($currentfile)) {
+                push(@testitems,$currentfile);
+        }
 }
 
 
index eee445c14a7489392bb5e5c6cb752c62d182d060..676ee02a4f80daefc45d545fc4190c17caa78090 100644 (file)
@@ -1,4 +1,6 @@
-package Systemexec;
+# -*- Mode: perl; indent-tabs-mode: nil -*-
+
+package Support::Systemexec;
 require Exporter;
 @ISA = qw(Exporter);
 @EXPORT = qw(system exec);
index 4d19c2ccab3be8f5b6777cd084c2e28fdeb4918d..6e5fb29042ade72ee1f4e507af44dd3723042278 100644 (file)
@@ -35,11 +35,11 @@ foreach my $file (@files) {
     my @lines = <FILE>;
     close (FILE);
     foreach my $line (@lines) {
-       if ($line =~ m/template->process\(\"(.+?)\", .+?\)/) {
+        if ($line =~ m/template->process\(\"(.+?)\", .+?\)/) {
             $template = $1;
-           push (@testitems, $template) unless $t{$template};
-           $t{$template} = 1;
-       }
+            push (@testitems, $template) unless $t{$template};
+            $t{$template} = 1;
+        }
     }
 }