Commit ed4af424 authored by jake%acutex.net's avatar jake%acutex.net

Bug 103664 - Tests should "use strict;" and not contain any tabs. We should…

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