diff options
Diffstat (limited to 't')
-rw-r--r-- | t/001compile.t | 6 | ||||
-rw-r--r-- | t/002goodperl.t | 71 | ||||
-rw-r--r-- | t/003safesys.t | 4 | ||||
-rw-r--r-- | t/004template.t | 4 | ||||
-rw-r--r-- | t/005whitespace.t | 2 | ||||
-rw-r--r-- | t/006spellcheck.t | 45 | ||||
-rw-r--r-- | t/007util.t | 8 | ||||
-rw-r--r-- | t/008filter.t | 10 | ||||
-rw-r--r-- | t/009bugwords.t | 2 | ||||
-rw-r--r-- | t/010dependencies.t | 3 | ||||
-rw-r--r-- | t/011pod.t | 4 | ||||
-rw-r--r-- | t/012throwables.t | 3 | ||||
-rw-r--r-- | t/013dbschema.t | 3 | ||||
-rw-r--r-- | t/Support/Files.pm | 18 | ||||
-rw-r--r-- | t/Support/Systemexec.pm | 5 | ||||
-rw-r--r-- | t/Support/Templates.pm | 35 |
16 files changed, 130 insertions, 93 deletions
diff --git a/t/001compile.t b/t/001compile.t index af7793093..7097ad361 100644 --- a/t/001compile.t +++ b/t/001compile.t @@ -10,8 +10,10 @@ #Bugzilla Test 1# ###Compilation### -use strict; use 5.10.1; +use strict; +use warnings; + use lib qw(. lib t); use Config; use Support::Files; @@ -52,7 +54,7 @@ sub compile_file { $libs = join " ", map { "-I\"$_\"" } split /$Config{path_sep}/, $ENV{PERL5LIB}; } my $perl = qq{"$^X"}; - my $output = `$perl $libs -wc$T $file 2>&1`; + my $output = `$perl $libs -c$T $file 2>&1`; chomp($output); my $return_val = $?; $output =~ s/^\Q$file\E syntax OK$//ms; diff --git a/t/002goodperl.t b/t/002goodperl.t index 02a57bea1..e95870d70 100644 --- a/t/002goodperl.t +++ b/t/002goodperl.t @@ -10,15 +10,19 @@ #Bugzilla Test 2# ####GoodPerl##### +use 5.10.1; use strict; +use warnings; use lib 't'; use Support::Files; -use Test::More tests => (scalar(@Support::Files::testitems) * 4); +use Test::More tests => (scalar(@Support::Files::testitems) + + scalar(@Support::Files::test_files)) * 5; -my @testitems = @Support::Files::testitems; # get the files to test. +my @testitems = (@Support::Files::test_files, @Support::Files::testitems); +my @require_taint = qw(email_in.pl importxml.pl mod_perl.pl whine.pl); foreach my $file (@testitems) { $file =~ s/\s.*$//; # nuke everything after the first space (#comment) @@ -38,23 +42,33 @@ foreach my $file (@testitems) { my $flags; if (!defined $ext || $ext eq "pl") { # standalone programs aren't taint checked yet - $flags = "w"; + if (grep { $file eq $_ } @require_taint) { + $flags = 'T'; + } + else { + $flags = ''; + } } elsif ($ext eq "pm") { ok(0, "$file is a module, but has a shebang"); next; } elsif ($ext eq "cgi") { # cgi files must be taint checked - $flags = "wT"; + $flags = 'T'; } else { ok(0, "$file has shebang but unknown extension"); next; } - if ($file_line1 =~ m#^\#\!/usr/bin/perl\s#) { - if ($file_line1 =~ m#\s-$flags#) { - ok(1,"$file uses standard perl location and -$flags"); - } else { - ok(0,"$file is MISSING -$flags --WARNING"); + if ($file_line1 =~ m#^\#\!/usr/bin/perl(?:\s-(\w+))?$#) { + my $file_flags = $1 || ''; + if ($flags eq $file_flags) { + ok(1, "$file uses standard perl location" . ($flags ? " and -$flags flag" : "")); + } + elsif ($flags) { + ok(0, "$file is MISSING -$flags flag --WARNING"); + } + else { + ok(0, "$file has unexpected -$file_flags flag --WARNING"); } } else { ok(0,"$file uses non-standard perl location"); @@ -63,7 +77,10 @@ foreach my $file (@testitems) { } foreach my $file (@testitems) { + my $found_use_perl = 0; my $found_use_strict = 0; + my $found_use_warnings = 0; + $file =~ s/\s.*$//; # nuke everything after the first space (#comment) next if (!$file); # skip null entries if (! open (FILE, $file)) { @@ -71,38 +88,28 @@ foreach my $file (@testitems) { next; } while (my $file_line = <FILE>) { - if ($file_line =~ m/^\s*use strict/) { - $found_use_strict = 1; - last; - } + $found_use_perl = 1 if $file_line =~ m/^\s*use 5.10.1/; + $found_use_strict = 1 if $file_line =~ m/^\s*use strict/; + $found_use_warnings = 1 if $file_line =~ m/^\s*use warnings/; + last if ($found_use_perl && $found_use_strict && $found_use_warnings); } close (FILE); + if ($found_use_perl) { + ok(1,"$file requires Perl 5.10.1"); + } else { + ok(0,"$file DOES NOT require Perl 5.10.1 --WARNING"); + } + if ($found_use_strict) { ok(1,"$file uses strict"); } else { ok(0,"$file DOES NOT use strict --WARNING"); } -} -foreach my $file (@testitems) { - my $found_use_feature = 0; - $file =~ s/\s.*$//; # nuke everything after the first space (#comment) - next if (!$file); # skip null entries - if (! open (FILE, $file)) { - ok(0,"could not open $file --WARNING"); - next; - } - while (my $file_line = <FILE>) { - if ($file_line =~ m/^\s*use 5.10.1/) { - $found_use_feature = 1; - last; - } - } - close (FILE); - if ($found_use_feature) { - ok(1,"$file requires Perl 5.10.1"); + if ($found_use_warnings) { + ok(1,"$file uses warnings"); } else { - ok(0,"$file DOES NOT require Perl 5.10.1 --WARNING"); + ok(0,"$file DOES NOT use warnings --WARNING"); } } diff --git a/t/003safesys.t b/t/003safesys.t index 0d6a215b1..2a257ffb9 100644 --- a/t/003safesys.t +++ b/t/003safesys.t @@ -10,7 +10,9 @@ #Bugzilla Test 3# ###Safesystem#### +use 5.10.1; use strict; +use warnings; use lib 't'; @@ -22,7 +24,7 @@ use Test::More tests => scalar(@Support::Files::testitems); # This will handle verbosity for us automatically. my $fh; { - local $^W = 0; # Don't complain about non-existent filehandles + no warnings qw(unopened); # Don't complain about non-existent filehandles if (-e \*Test::More::TESTOUT) { $fh = \*Test::More::TESTOUT; } elsif (-e \*Test::Builder::TESTOUT) { diff --git a/t/004template.t b/t/004template.t index 604559dc0..d38f9e16b 100644 --- a/t/004template.t +++ b/t/004template.t @@ -9,7 +9,9 @@ #Bugzilla Test 4# ####Templates#### +use 5.10.1; use strict; +use warnings; use lib 't'; @@ -26,7 +28,7 @@ use Test::More tests => ( scalar(@referenced_files) + 2 * $num_actual_files ); # This will handle verbosity for us automatically. my $fh; { - local $^W = 0; # Don't complain about non-existent filehandles + no warnings qw(unopened); # Don't complain about non-existent filehandles if (-e \*Test::More::TESTOUT) { $fh = \*Test::More::TESTOUT; } elsif (-e \*Test::Builder::TESTOUT) { diff --git a/t/005whitespace.t b/t/005whitespace.t index 8cb2f7e8f..b6de8cee3 100644 --- a/t/005whitespace.t +++ b/t/005whitespace.t @@ -9,7 +9,9 @@ #Bugzilla Test 5# #####no_tabs##### +use 5.10.1; use strict; +use warnings; use lib 't'; diff --git a/t/006spellcheck.t b/t/006spellcheck.t index 7f17c5169..24e00242d 100644 --- a/t/006spellcheck.t +++ b/t/006spellcheck.t @@ -10,29 +10,13 @@ #Bugzilla Test 6# ####Spelling##### +use 5.10.1; +use strict; +use warnings; + use lib 't'; use Support::Files; -BEGIN { - #add the words to check here: - @evilwords = qw( - anyways - appearence - arbitary - cancelled - critera - databasa - dependan - existance - existant - paramater - refered - repsentation - suported - varsion - ); -} - # -1 because 006spellcheck.t must not be checked. use Test::More tests => scalar(@Support::Files::testitems) + scalar(@Support::Files::test_files) - 1; @@ -41,7 +25,7 @@ use Test::More tests => scalar(@Support::Files::testitems) # This will handle verbosity for us automatically. my $fh; { - local $^W = 0; # Don't complain about non-existent filehandles + no warnings qw(unopened); # Don't complain about non-existent filehandles if (-e \*Test::More::TESTOUT) { $fh = \*Test::More::TESTOUT; } elsif (-e \*Test::Builder::TESTOUT) { @@ -53,7 +37,24 @@ my $fh; my @testitems = (@Support::Files::testitems, @Support::Files::test_files); -# at last, here we actually run the test... +#add the words to check here: +my @evilwords = qw( + anyways + appearence + arbitary + cancelled + critera + databasa + dependan + existance + existant + paramater + refered + repsentation + suported + varsion +); + my $evilwordsregexp = join('|', @evilwords); foreach my $file (@testitems) { diff --git a/t/007util.t b/t/007util.t index 495102ffa..66c2df032 100644 --- a/t/007util.t +++ b/t/007util.t @@ -9,14 +9,18 @@ #Bugzilla Test 7# #####Util.pm##### +use 5.10.1; +use strict; +use warnings; + use lib 't'; use Support::Files; use Test::More tests => 17; use DateTime; BEGIN { - use_ok(Bugzilla); - use_ok(Bugzilla::Util); + use_ok('Bugzilla'); + use_ok('Bugzilla::Util'); } # We need to override user preferences so we can get an expected value when diff --git a/t/008filter.t b/t/008filter.t index 9551ae2b2..f0a26d13f 100644 --- a/t/008filter.t +++ b/t/008filter.t @@ -15,10 +15,11 @@ # Sample exploit code: '>"><script>alert('Oh dear...')</script> +use 5.10.1; use strict; -use lib qw(. lib t); +use warnings; -use vars qw(%safe); +use lib qw(. lib t); use Bugzilla::Constants; use Support::Templates; @@ -30,6 +31,7 @@ use Cwd; my $oldrecsep = $/; my $topdir = cwd; $/ = undef; +our %safe; foreach my $path (@Support::Templates::include_paths) { $path =~ s|\\|/|g if ON_WINDOWS; # convert \ to / in path if on windows @@ -84,9 +86,9 @@ foreach my $path (@Support::Templates::include_paths) { ok(1, "($lang/$flavor) $file is filter-safe"); next; } - + # Read the entire file into a string - open (FILE, "<$file") || die "Can't open $file: $!\n"; + open (FILE, "<$file") || die "Can't open $file: $!\n"; my $slurp = <FILE>; close (FILE); diff --git a/t/009bugwords.t b/t/009bugwords.t index 988f747f2..e36651edb 100644 --- a/t/009bugwords.t +++ b/t/009bugwords.t @@ -15,7 +15,9 @@ # "[% terms.bug %]". This test makes sure the relevant words aren't used # bare. +use 5.10.1; use strict; +use warnings; use lib 't'; diff --git a/t/010dependencies.t b/t/010dependencies.t index 89a26ba5e..afd29a652 100644 --- a/t/010dependencies.t +++ b/t/010dependencies.t @@ -10,7 +10,10 @@ #Bugzilla Test 10# ## dependencies ## +use 5.10.1; use strict; +use warnings; + use lib qw(. lib t); use Support::Files; diff --git a/t/011pod.t b/t/011pod.t index fc66bca63..588db1fc5 100644 --- a/t/011pod.t +++ b/t/011pod.t @@ -10,7 +10,9 @@ #Bugzilla Test 11# ##POD validation## +use 5.10.1; use strict; +use warnings; use lib 't'; @@ -52,7 +54,7 @@ use constant MODULE_WHITELIST => qw( # This will handle verbosity for us automatically. my $fh; { - local $^W = 0; # Don't complain about non-existent filehandles + no warnings qw(unopened); # Don't complain about non-existent filehandles if (-e \*Test::More::TESTOUT) { $fh = \*Test::More::TESTOUT; } elsif (-e \*Test::Builder::TESTOUT) { diff --git a/t/012throwables.t b/t/012throwables.t index 7600cbd02..0ef043fa5 100644 --- a/t/012throwables.t +++ b/t/012throwables.t @@ -11,7 +11,10 @@ #Bugzilla Test 12# ######Errors###### +use 5.10.1; use strict; +use warnings; + use lib qw(. lib t); use Bugzilla::Constants; diff --git a/t/013dbschema.t b/t/013dbschema.t index c1f9c7f0c..217176ff2 100644 --- a/t/013dbschema.t +++ b/t/013dbschema.t @@ -12,7 +12,10 @@ # Check the Bugzilla database schema to ensure no field names conflict # with SQL reserved words. +use 5.10.1; use strict; +use warnings; + use lib qw(. t lib); use Bugzilla; use Bugzilla::DB::Schema; diff --git a/t/Support/Files.pm b/t/Support/Files.pm index 330a473b1..85fa9f583 100644 --- a/t/Support/Files.pm +++ b/t/Support/Files.pm @@ -8,15 +8,19 @@ package Support::Files; +use 5.10.1; +use strict; +use warnings; + use File::Find; -@additional_files = (); +our @additional_files = (); -@files = glob('*'); +our @files = glob('*'); find(sub { push(@files, $File::Find::name) if $_ =~ /\.pm$/;}, 'Bugzilla'); push(@files, 'extensions/create.pl'); -@extensions = +our @extensions = grep { $_ ne 'extensions/create.pl' && ! -e "$_/disabled" } glob('extensions/*'); @@ -24,7 +28,7 @@ foreach my $extension (@extensions) { find(sub { push(@files, $File::Find::name) if $_ =~ /\.pm$/;}, $extension); } -@test_files = glob('t/*.t'); +our @test_files = glob('t/*.t'); sub isTestingFile { my ($file) = @_; @@ -40,9 +44,11 @@ sub isTestingFile { return undef; } -foreach $currentfile (@files) { +our (@testitems, @module_files); + +foreach my $currentfile (@files) { if (isTestingFile($currentfile)) { - push(@testitems,$currentfile); + push(@testitems, $currentfile); } push(@module_files, $currentfile) if $currentfile =~ /\.pm$/; } diff --git a/t/Support/Systemexec.pm b/t/Support/Systemexec.pm index 620cce25e..65be229e3 100644 --- a/t/Support/Systemexec.pm +++ b/t/Support/Systemexec.pm @@ -6,6 +6,11 @@ # defined by the Mozilla Public License, v. 2.0. package Support::Systemexec; + +use 5.10.1; +use strict; +use warnings; + require Exporter; @ISA = qw(Exporter); @EXPORT = qw(system exec); diff --git a/t/Support/Templates.pm b/t/Support/Templates.pm index 2185d687f..d17c7334b 100644 --- a/t/Support/Templates.pm +++ b/t/Support/Templates.pm @@ -7,15 +7,15 @@ package Support::Templates; +use 5.10.1; use strict; +use warnings; use lib 't'; use parent qw(Exporter); -@Support::Templates::EXPORT = - qw(@languages @include_paths @english_default_include_paths - %include_path @referenced_files %actual_files $num_actual_files); -use vars qw(@languages @include_paths @english_default_include_paths - %include_path @referenced_files %actual_files $num_actual_files); +@Support::Templates::EXPORT = + qw(@languages @include_paths @english_default_include_paths + @referenced_files %actual_files $num_actual_files); use Bugzilla; use Bugzilla::Constants; @@ -25,18 +25,9 @@ use Support::Files; use File::Find; use File::Spec; -# The available template languages -@languages = (); - -# The colon separated includepath per language -%include_path = (); - -# All include paths -@include_paths = (); - # English default include paths -push @english_default_include_paths, - File::Spec->catdir(bz_locations()->{'templatedir'}, 'en', 'default'); +our @english_default_include_paths = + (File::Spec->catdir(bz_locations()->{'templatedir'}, 'en', 'default')); # And the extensions too foreach my $extension (@Support::Files::extensions) { @@ -47,19 +38,19 @@ foreach my $extension (@Support::Files::extensions) { } # Files which are referenced in the cgi files -@referenced_files = (); +our @referenced_files = (); # All files sorted by include_path -%actual_files = (); +our %actual_files = (); # total number of actual_files -$num_actual_files = 0; +our $num_actual_files = 0; # Set the template available languages and include paths -@languages = @{ Bugzilla->languages }; -@include_paths = @{ template_include_path({ language => Bugzilla->languages }) }; +our @languages = @{ Bugzilla->languages }; +our @include_paths = @{ template_include_path({ language => Bugzilla->languages }) }; -my @files; +our @files; # Local subroutine used with File::Find sub find_templates { |