Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision f1a3e8eb

Von Sven Schöling vor mehr als 14 Jahren hinzugefügt

  • ID f1a3e8eb41c882a85a995d620544852ca11d1708
  • Vorgänger 0d6c1280
  • Nachfolger 29889ce3

Test um <translate> tags in tempaltes zu finden.

Unterschiede anzeigen:

t/004template.t
33 33

  
34 34
use Support::Templates;
35 35

  
36
# Bug 137589 - Disable command-line input of CGI.pm when testing
37
use CGI qw(-no_debug);
38

  
39 36
use File::Spec;
37
use File::Slurp;
40 38
use Template;
41
use Test::More tests => ( scalar(@referenced_files) * scalar(@languages)
42
                        + $num_actual_files  );
39
use Test::More tests => ( scalar(@referenced_files));
40

  
41
my $template_path = 'templates/webpages/';
43 42

  
44 43
# Capture the TESTOUT from Test::More or Test::Builder for printing errors.
45 44
# This will handle verbosity for us automatically.
......
55 54
    }
56 55
}
57 56

  
58
# Checks whether one of the passed files exists
59
sub existOnce {
60
  foreach my $file (@_) {
61
    return $file  if -e $file;
62
  }
63
  return 0;
64
}
65

  
66
# Check to make sure all templates that are referenced in
67
# Bugzilla exist in the proper place.
68

  
69
foreach my $lang (@languages) {
70
    foreach my $file (@referenced_files) {
71
        my @path = map(File::Spec->catfile($_, $file),
72
                       split(':', $include_path{$lang} . ":" . $include_path{"en"}));
73
        if (my $path = existOnce(@path)) {
74
            ok(1, "$path exists");
75
        } else {
76
            ok(0, "$file cannot be located --ERROR");
77
            print $fh "Looked in:\n  " . join("\n  ", @path) . "\n";
78
        }
79
    }
80
}
81

  
82
foreach my $include_path (@include_paths) {
83
    # Processes all the templates to make sure they have good syntax
84
    my $provider = Template::Provider->new(
85
    {
86
        INCLUDE_PATH => $include_path ,
87
        # Need to define filters used in the codebase, they don't
88
        # actually have to function in this test, just be defined.
89
        # See Template.pm for the actual codebase definitions.
90

  
91
        # Initialize templates (f.e. by loading plugins like Hook).
92
        PRE_PROCESS => "global/initialize.none.tmpl",
93

  
94
        FILTERS =>
95
        {
96
            html_linebreak => sub { return $_; },
97
            no_break => sub { return $_; } ,
98
            js        => sub { return $_ } ,
99
            base64   => sub { return $_ } ,
100
            inactive => [ sub { return sub { return $_; } }, 1] ,
101
            closed => [ sub { return sub { return $_; } }, 1] ,
102
            obsolete => [ sub { return sub { return $_; } }, 1] ,
103
            url_quote => sub { return $_ } ,
104
            css_class_quote => sub { return $_ } ,
105
            xml       => sub { return $_ } ,
106
            quoteUrls => sub { return $_ } ,
107
            bug_link => [ sub { return sub { return $_; } }, 1] ,
108
            csv       => sub { return $_ } ,
109
            unitconvert => sub { return $_ },
110
            time      => sub { return $_ } ,
111
            wrap_comment => sub { return $_ },
112
            none      => sub { return $_ } ,
113
            ics       => [ sub { return sub { return $_; } }, 1] ,
114
        },
115
    }
116
    );
117

  
118
    foreach my $file (@{$actual_files{$include_path}}) {
119
        my $path = File::Spec->catfile($include_path, $file);
120
        if (-e $path) {
121
            my ($data, $err) = $provider->fetch($file);
122

  
123
            if (!$err) {
124
                ok(1, "$file syntax ok");
125
            }
126
            else {
127
                ok(0, "$file has bad syntax --ERROR");
128
                print $fh $data . "\n";
129
            }
130
        }
131
        else {
132
            ok(1, "$path doesn't exist, skipping test");
133
        }
57
# test master files for <translate> tag
58
foreach my $ref (@Support::Templates::referenced_files) {
59
    my $file = "${template_path}${ref}_master.html";
60
    my $data = read_file($file) || die "??? couldn't open $file";
61
    if ($data =~ /<translate>/) {
62
        ok(0, "$file uses deprecated <translate> tags.");
63
    } else {
64
        ok(1, "$file does not use <translate> tags.");
134 65
    }
135

  
136
    # check to see that all templates have a version string:
137
    # disabled for lx-office
138

  
139
#    foreach my $file (@{$actual_files{$include_path}}) {
140
#        my $path = File::Spec->catfile($include_path, $file);
141
#        open(TMPL, $path);
142
#        my $firstline = <TMPL>;
143
#        if ($firstline =~ /\d+\.\d+\@[\w\.-]+/) {
144
#            ok(1,"$file has a version string");
145
#        } else {
146
#            ok(0,"$file does not have a version string --ERROR");
147
#        }
148
#        close(TMPL);
149
#    }
150 66
}
151 67

  
152 68
exit 0;

Auch abrufbar als: Unified diff