From 42aa391ee8148131cc31fc62ec34be345ce9dcd9 Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" Date: Mon, 3 Dec 2012 18:15:51 +0000 Subject: [PATCH] Bug 817634: Tests in t/ should also check themselves where appropriate r=glob a=LpSolit git-svn-id: svn://10.0.0.236/trunk@264523 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/webtools/bugzilla/.bzrrev | 2 +- mozilla/webtools/bugzilla/t/001compile.t | 5 ++- mozilla/webtools/bugzilla/t/005whitespace.t | 5 ++- mozilla/webtools/bugzilla/t/006spellcheck.t | 47 +++++++++++--------- mozilla/webtools/bugzilla/t/Support/Files.pm | 2 + 5 files changed, 34 insertions(+), 27 deletions(-) diff --git a/mozilla/webtools/bugzilla/.bzrrev b/mozilla/webtools/bugzilla/.bzrrev index 480077787b9..d8d6472c70b 100644 --- a/mozilla/webtools/bugzilla/.bzrrev +++ b/mozilla/webtools/bugzilla/.bzrrev @@ -1 +1 @@ -8507 \ No newline at end of file +8508 \ No newline at end of file diff --git a/mozilla/webtools/bugzilla/t/001compile.t b/mozilla/webtools/bugzilla/t/001compile.t index 186e2a8eef9..af779309381 100644 --- a/mozilla/webtools/bugzilla/t/001compile.t +++ b/mozilla/webtools/bugzilla/t/001compile.t @@ -15,7 +15,8 @@ use 5.10.1; use lib qw(. lib t); use Config; use Support::Files; -use Test::More tests => scalar(@Support::Files::testitems); +use Test::More tests => scalar(@Support::Files::testitems) + + scalar(@Support::Files::test_files); BEGIN { use_ok('Bugzilla::Constants'); @@ -59,7 +60,7 @@ sub compile_file { ok(!$return_val, $file) or diag('--ERROR'); } -my @testitems = @Support::Files::testitems; +my @testitems = (@Support::Files::testitems, @Support::Files::test_files); my $file_features = map_files_to_features(); # Test the scripts by compiling them diff --git a/mozilla/webtools/bugzilla/t/005whitespace.t b/mozilla/webtools/bugzilla/t/005whitespace.t index 624df69f62e..8cb2f7e8f01 100644 --- a/mozilla/webtools/bugzilla/t/005whitespace.t +++ b/mozilla/webtools/bugzilla/t/005whitespace.t @@ -17,10 +17,11 @@ use Support::Files; use Support::Templates; use File::Spec; -use Test::More tests => ( scalar(@Support::Files::testitems) +use Test::More tests => (scalar(@Support::Files::testitems) + + scalar(@Support::Files::test_files) + $Support::Templates::num_actual_files) * 3; -my @testitems = @Support::Files::testitems; +my @testitems = (@Support::Files::testitems, @Support::Files::test_files); for my $path (@Support::Templates::include_paths) { push(@testitems, map(File::Spec->catfile($path, $_), Support::Templates::find_actual_files($path))); diff --git a/mozilla/webtools/bugzilla/t/006spellcheck.t b/mozilla/webtools/bugzilla/t/006spellcheck.t index 07cd3ea8c42..7f17c5169a2 100644 --- a/mozilla/webtools/bugzilla/t/006spellcheck.t +++ b/mozilla/webtools/bugzilla/t/006spellcheck.t @@ -13,29 +13,29 @@ use lib 't'; use Support::Files; -BEGIN { # yes the indenting is off, deal with it -#add the words to check here: -@evilwords = qw( -anyways -appearence -arbitary -cancelled -critera -databasa -dependan -existance -existant -paramater -refered -repsentation -suported -varsion -); - -$testcount = scalar(@Support::Files::testitems); +BEGIN { + #add the words to check here: + @evilwords = qw( + anyways + appearence + arbitary + cancelled + critera + databasa + dependan + existance + existant + paramater + refered + repsentation + suported + varsion + ); } -use Test::More tests => $testcount; +# -1 because 006spellcheck.t must not be checked. +use Test::More tests => scalar(@Support::Files::testitems) + + scalar(@Support::Files::test_files) - 1; # Capture the TESTOUT from Test::More or Test::Builder for printing errors. # This will handle verbosity for us automatically. @@ -51,7 +51,7 @@ my $fh; } } -my @testitems = @Support::Files::testitems; +my @testitems = (@Support::Files::testitems, @Support::Files::test_files); # at last, here we actually run the test... my $evilwordsregexp = join('|', @evilwords); @@ -59,6 +59,9 @@ my $evilwordsregexp = join('|', @evilwords); foreach my $file (@testitems) { $file =~ s/\s.*$//; # nuke everything after the first space (#comment) next if (!$file); # skip null entries + # Do not try to validate this file as it obviously contains a list + # of wrongly spelled words. + next if ($file eq 't/006spellcheck.t'); if (open (FILE, $file)) { # open the file for reading diff --git a/mozilla/webtools/bugzilla/t/Support/Files.pm b/mozilla/webtools/bugzilla/t/Support/Files.pm index 4b629785265..ed011a374c5 100644 --- a/mozilla/webtools/bugzilla/t/Support/Files.pm +++ b/mozilla/webtools/bugzilla/t/Support/Files.pm @@ -24,6 +24,8 @@ foreach my $extension (@extensions) { find(sub { push(@files, $File::Find::name) if $_ =~ /\.pm$/;}, $extension); } +@test_files = glob('t/*.t'); + sub isTestingFile { my ($file) = @_; my $exclude;