Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 8332f181

Von Sven Schöling vor fast 15 Jahren hinzugefügt

  • ID 8332f18114bf31468d886c634cfc889647bae8ef
  • Vorgänger 3a33f5d3
  • Nachfolger c3a2f815

Neuer Subtest in 002goodperl.t: .pl und .pm Dateien sollen keine HTML Tags enthalten.

Test ist recht simpel, funktioniert aber um das meiste aufzudenken.

Unterschiede anzeigen:

t/002goodperl.t
32 32

  
33 33
use Support::Files;
34 34

  
35
use Test::More tests => scalar @Support::Files::testitems * 2;
35
use Test::More tests => scalar @Support::Files::testitems * 3;
36 36

  
37 37
my @testitems = @Support::Files::testitems; # get the files to test.
38 38

  
......
103 103
    }
104 104
}
105 105

  
106

  
107
# note, the html checker is not really thorough.
108
# in particular it will not find standard tags with parameters.
109
# the estimate wether a file is dirty or not is still pretty helpful, as it will catch most of the closing tags.
110
# if you are in doubt about a specific file, you still have to check it manually.
111
my $tags = qr/b|i|u|h[1-6]|a href.*|input|form|br|textarea|table|tr|td|th|body|head|html|p|button|select|option|script/;
112
foreach my $file (@testitems) {
113
    my $found_html_count = 0;
114
    my $found_html       = '';
115
    $file =~ s/\s.*$//; # nuke everything after the first space (#comment)
116
    next if (!$file); # skip null entries
117
    if (! open (FILE, $file)) {
118
        ok(0,"could not open $file --WARNING");
119
        next;
120
    }
121
    while (my $file_line = <FILE>) {
122
        if ($file_line =~ m/(<\/?$tags>)/) {
123
            $found_html_count++;
124
            $found_html .= $1;
125
        }
126
    }
127
    close (FILE);
128
    if (!$found_html_count) {
129
        ok(1,"$file does not contain HTML");
130
    } else {
131
    TODO: { local $TODO = q(Templating is not final.);
132
        ok(0,"$file contains at least $found_html_count html tags.");
133
      }
134
    }
135
}
136

  
106 137
exit 0;

Auch abrufbar als: Unified diff