f063c22b563f938304177730544dde5b42598380
[kivitendo-erp.git] / t / 006spellcheck.t
1 # -*- Mode: perl; indent-tabs-mode: nil -*-
2 #
3 # The contents of this file are subject to the Mozilla Public
4 # License Version 1.1 (the "License"); you may not use this file
5 # except in compliance with the License. You may obtain a copy of
6 # the License at http://www.mozilla.org/MPL/
7 #
8 # Software distributed under the License is distributed on an "AS
9 # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
10 # implied. See the License for the specific language governing
11 # rights and limitations under the License.
12 #
13 # The Original Code are the Bugzilla Tests.
14 #
15 # The Initial Developer of the Original Code is Zach Lipton
16 # Portions created by Zach Lipton are
17 # Copyright (C) 2002 Zach Lipton.  All
18 # Rights Reserved.
19 #
20 # Contributor(s): Zach Lipton <zach@zachlipton.com>
21
22
23 #################
24 #Bugzilla Test 6#
25 ####Spelling#####
26
27 use lib 't';
28 use Support::Files;
29
30 BEGIN { # yes the indenting is off, deal with it
31 #add the words to check here:
32 @evilwords = qw(
33 CONTANTS
34 anyways
35 arbitary
36 cofigur
37 custemer
38 databasa
39 dependan
40 execept
41 existance
42 existant
43 fomr
44 invoce
45 paramater
46 pirce
47 postition
48 primt
49 puchase
50 puhs
51 sekf
52 sucess
53 varsion
54 wether
55 );
56
57 $testcount = scalar(@Support::Files::files);
58 }
59
60 use Test::More tests => $testcount;
61
62 # Capture the TESTOUT from Test::More or Test::Builder for printing errors.
63 # This will handle verbosity for us automatically.
64 my $fh;
65 {
66     local $^W = 0;  # Don't complain about non-existent filehandles
67     if (-e \*Test::More::TESTOUT) {
68         $fh = \*Test::More::TESTOUT;
69     } elsif (-e \*Test::Builder::TESTOUT) {
70         $fh = \*Test::Builder::TESTOUT;
71     } else {
72         $fh = \*STDOUT;
73     }
74 }
75
76 my @testitems = @Support::Files::files;
77
78 # at last, here we actually run the test...
79 my $evilwordsregexp = join('|', @evilwords);
80
81 foreach my $file (@testitems) {
82     $file =~ s/\s.*$//; # nuke everything after the first space (#comment)
83     next if (!$file); # skip null entries
84
85     if (open (FILE, $file)) { # open the file for reading
86
87         my $found_word = '';
88
89         while (my $file_line = <FILE>) { # and go through the file line by line
90             if ($file_line =~ /($evilwordsregexp)/i) { # found an evil word
91                 $found_word = $1;
92                 last;
93             }
94         }
95
96         close (FILE);
97
98         if ($found_word) {
99             ok(0,"$file: found SPELLING ERROR $found_word --WARNING");
100         } else {
101             ok(1,"$file does not contain registered spelling errors");
102         }
103     } else {
104         ok(0,"could not open $file for spellcheck --WARNING");
105     }
106 }
107
108 exit 0;