Commit 3a37c595 authored by jouni%heikniemi.net's avatar jouni%heikniemi.net

Bug 257111: t/006spellcheck.t should check each file only once.

Patch by Marc Schumann <marcschum@web.de> r=jouni, a=myk
parent fcd317ee
...@@ -37,7 +37,7 @@ existance ...@@ -37,7 +37,7 @@ existance
existant existant
); );
$testcount = scalar(@Support::Files::testitems) * scalar(@evilwords); $testcount = scalar(@Support::Files::testitems);
} }
use Test::More tests => $testcount; use Test::More tests => $testcount;
...@@ -59,36 +59,33 @@ my $fh; ...@@ -59,36 +59,33 @@ my $fh;
my @testitems = @Support::Files::testitems; my @testitems = @Support::Files::testitems;
# at last, here we actually run the test... # at last, here we actually run the test...
my $evilwordsregexp = join('|', @evilwords);
foreach my $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
foreach my $word (@evilwords) { # go through the evilwords
if (open (FILE, $file)) { # open the file for reading if (open (FILE, $file)) { # open the file for reading
my $found_word = 0;
my $found_word = '';
while (my $file_line = <FILE>) { # and go through the file line by line while (my $file_line = <FILE>) { # and go through the file line by line
if ($file_line =~ /$word/i) { # found an evil word if ($file_line =~ /($evilwordsregexp)/i) { # found an evil word
$found_word = 1; $found_word = $1;
last; last;
} }
} }
if ($found_word) {
ok(0,"$file: found SPELLING ERROR $word --WARNING");
}
else {
ok(1,"$file does not contain the spelling error $word");
}
close (FILE); close (FILE);
if ($found_word) {
ok(0,"$file: found SPELLING ERROR $found_word --WARNING");
} else {
ok(1,"$file does not contain registered spelling errors");
} }
else { } else {
ok(0,"could not open $file for spellcheck --WARNING"); ok(0,"could not open $file for spellcheck --WARNING");
} }
}
} }
exit 0; exit 0;
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