summaryrefslogtreecommitdiffstats
path: root/t/006spellcheck.t
blob: 7f17c5169a239785fbbd38ecea47813a51dfe854 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This Source Code Form is "Incompatible With Secondary Licenses", as
# defined by the Mozilla Public License, v. 2.0.


#################
#Bugzilla Test 6#
####Spelling#####

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;

# Capture the TESTOUT from Test::More or Test::Builder for printing errors.
# This will handle verbosity for us automatically.
my $fh;
{
    local $^W = 0;  # Don't complain about non-existent filehandles
    if (-e \*Test::More::TESTOUT) {
        $fh = \*Test::More::TESTOUT;
    } elsif (-e \*Test::Builder::TESTOUT) {
        $fh = \*Test::Builder::TESTOUT;
    } else {
        $fh = \*STDOUT;
    }
}

my @testitems = (@Support::Files::testitems, @Support::Files::test_files);

# at last, here we actually run the test...
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

        my $found_word = '';

        while (my $file_line = <FILE>) { # and go through the file line by line
            if ($file_line =~ /($evilwordsregexp)/i) { # found an evil word
                $found_word = $1;
                last;
            }
        }
            
        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 {
        ok(0,"could not open $file for spellcheck --WARNING");
    }
} 

exit 0;