]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 224913 - Need tests to check whether any templates uses the bareword "bug" or...
authorgerv%gerv.net <>
Sun, 9 Nov 2003 02:09:22 +0000 (02:09 +0000)
committergerv%gerv.net <>
Sun, 9 Nov 2003 02:09:22 +0000 (02:09 +0000)
t/009bugwords.t [new file with mode: 0644]
template/en/default/attachment/diff-header.html.tmpl
template/en/default/global/messages.html.tmpl
template/en/default/global/user-error.html.tmpl
template/en/default/search/search-advanced.html.tmpl
template/en/default/search/search-create-series.html.tmpl
template/en/default/search/search-specific.html.tmpl
template/en/default/search/search.html.tmpl

diff --git a/t/009bugwords.t b/t/009bugwords.t
new file mode 100644 (file)
index 0000000..564e7f6
--- /dev/null
@@ -0,0 +1,118 @@
+# -*- Mode: perl; indent-tabs-mode: nil -*-
+#
+# The contents of this file are subject to the Mozilla Public
+# License Version 1.1 (the "License"); you may not use this file
+# except in compliance with the License. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS
+# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# rights and limitations under the License.
+#
+# The Original Code are the Bugzilla tests.
+#
+# The Initial Developer of the Original Code is Jacob Steenhagen.
+# Portions created by Jacob Steenhagen are
+# Copyright (C) 2001 Jacob Steenhagen. All
+# Rights Reserved.
+#
+# Contributor(s): Gervase Markham <gerv@gerv.net>
+#
+
+#################
+#Bugzilla Test 9#
+####bugwords#####
+
+# Bugzilla has a mechanism for taking various words, including "bug", "bugs", 
+# and "a bug" and automatically replacing them in the templates with the local
+# terminology. It does this by using the 'terms' hash, so "bug" becomes 
+# "[% terms.bug %]". This test makes sure the relevant words aren't used
+# bare.
+
+use strict;
+
+use lib 't';
+
+use Support::Files;
+use Support::Templates;
+use Bugzilla::Util;
+
+use File::Spec 0.82;
+
+# We have a list of templates to exclude, if present. This allows us to exclude
+# sample and b.m.o.-specific templates. Do _not_ add a template to this list
+# without checking with developers@bugzilla.org first.
+my @exclude;
+
+BEGIN {
+    @exclude = (
+        'template/en/default/pages/etiquette.html.tmpl'
+    );
+}
+
+use Test::More tests => ($Support::Templates::num_actual_files - 
+                         scalar(@exclude)); 
+
+# Find all the templates (except those in @exclude)
+my @testitems;
+for my $path (@Support::Templates::include_paths) {
+    my @items = map(File::Spec->catfile($path, $_),
+                    Support::Templates::find_actual_files($path));
+    foreach my $item (@items) {              
+        if (lsearch(\@exclude, $item) == -1) {
+            push(@testitems, $item);
+        }
+    }
+}
+
+foreach my $file (@testitems) {
+    my @errors;
+    
+    # Read the entire file into a string
+    local $/;
+    open (FILE, "<$file") || die "Can't open $file: $!\n";    
+    my $slurp = <FILE>;
+    close (FILE);
+
+    # /g means we execute this loop for every match
+    # /s means we ignore linefeeds in the regexp matches
+    # This extracts everything which is _not_ a directive.
+    while ($slurp =~ /%\](.*?)(\[%|$)/gs) {
+        my $text = $1;
+
+        my @lineno = ($` =~ m/\n/gs);
+        my $lineno = scalar(@lineno) + 1;
+    
+        # "a bug", "bug", "bugs"
+        if (grep /(a?[\s>]bugs?[\s.:;])/i, $text) {
+            # Exclude variable assignment.
+            unless (grep /bugs =/, $text) {
+                push(@errors, [$lineno, $text]);
+                next;
+            }
+        }
+
+        # "Bugzilla"
+        if (grep /Bugzilla[^_]/, $text) {
+            # Exclude JS comments, hyperlinks, USE and variable assignment.
+            unless (grep /(\/\/.*|org.*>|USE |= )Bugzilla/, $text) {
+                push(@errors, [$lineno, $text]);
+                next;
+            }
+        }
+    }
+        
+    if (scalar(@errors)) {
+      ok(0, "$file contains invalid bare words (e.g. 'bug') --WARNING");
+      
+      foreach my $error (@errors) {
+        print "$error->[0]: $error->[1]\n";
+      }
+    } 
+    else {
+      ok(1, "$file has no invalid barewords");
+    }
+}
+
+exit 0;
index c1b70173e5486f145e9650b6965843114143c254..4069cc21bdc84ab4afc7f931e00ad40d8a5045b1 100644 (file)
 
 [%# Define strings that will serve as the title and header of this page %]
 
-[% title = BLOCK %]Attachment #[% attachid %] for Bug #[% bugid %][% END %]
+[% PROCESS global/variables.none.tmpl %]
+
+[% title = BLOCK %]
+  Attachment #[% attachid %] for [% terms.Bug %] #[% bugid %]
+[% END %]
 
 [% style = BLOCK %]
 .file_head {
@@ -192,7 +196,7 @@ tbody.file pre:empty {
       <a href="[% new_url %]">[% new_desc FILTER html %]</a>
       (<a href="[% new_url %]">#[% newid %]</a>)
     [% END %]
-    for <a href="show_bug.cgi?id=[% bugid %]">Bug #[% bugid %]</a>
+    for <a href="show_bug.cgi?id=[% bugid %]">[% terms.Bug %] #[% bugid %]</a>
   [% END %]
   [% h2 = BLOCK %]
     [% bugsummary FILTER html %]
@@ -290,12 +294,12 @@ tbody.file pre:empty {
 <h2 class="warning">Warning: 
   [% IF warning == "interdiff1" %]
   this difference between two patches may show things in the wrong places due
-  to a limitation in Bugzilla when comparing patches with different sets of
-  files.
+  to a limitation in [% terms.Bugzilla %] when comparing patches with different
+  sets of files.
   [% END %]
   [% IF warning == "interdiff2" %]
   this difference between two patches may be inaccurate due to a limitation in
-  Bugzilla when comparing patches made against different revisions.
+  [% terms.Bugzilla %] when comparing patches made against different revisions.
   [% END %]
 </h2>
 [% END %]
index 41dd71f6cf6a55c0424b9b225459bef769cf3afd..750bc5cfaa8da64c0293117bc5bb14902f7c46a5 100644 (file)
@@ -54,8 +54,9 @@
     OK, the <b>[% namedcmd FILTER html %]</b> query is gone.
 
   [% ELSIF message_tag == "buglist_sorted_by_relevance" %]
-    Bugs on this list are sorted by relevance, with the most relevant bugs
-    at the top.  Only the 200 most relevant bugs are shown.
+    [% terms.Bugs %] on this list are sorted by relevance, with the most
+    relevant [% terms.bugs %] at the top.  Only the 200 most relevant 
+    [%+ terms.bugs %] are shown.
 
   [% ELSIF message_tag == "change_columns" %]
     [% title = "Change columns" %]
index a988102a8177240ee51dfa2a56dd2119d92f4b8f..1bbd00efcbc7d05e43b34b13b2865788133527e2 100644 (file)
 
   [% ELSIF error == "dupe_invalid_bug_id" %]
     [% title = BLOCK %]Valid [% terms.Bug %] Number Required[% END %]
-    You must specify a valid bug number of which this [% terms.bug %]
-    is a duplicate.  The [% terms.bug %] has not been changed.
+    You must specify a valid [% terms.bug %] number of which this 
+    [%+ terms.bug %] is a duplicate.  The [% terms.bug %] has not been changed.
 
   [% ELSIF error == "dupe_of_self_disallowed" %]
     [% title = "Nice Try..." %]
 
   [% ELSIF error == "entry_access_denied" %]
     [% title = "Permission Denied" %]
-    Sorry; you do not have the permissions necessary to enter [% terms.abug %] against
-    the [% product FILTER html %] product.
+    Sorry; you do not have the permissions necessary to enter [% terms.abug %]
+    against the [% product FILTER html %] product.
 
   [% ELSIF error == "file_not_specified" %]
     [% title = "No File Specified" %]
 
     You asked [% requestee.identity FILTER html %]
     for <code>[% flag_type.name FILTER html %]</code> on 
-    [% terms.bug %]&nbsp;[% bug_id FILTER html %],
+    [%+ terms.bug %]&nbsp;[% bug_id FILTER html %],
     attachment [% attach_id FILTER html %], but that attachment is restricted 
     to users
     in the [% Param("insidergroup") FILTER html %] group, and the user
     [% title = "Invalid Email Address" %]
     The e-mail address you entered(<b>[% addr FILTER html %]</b>) 
     didn't pass our syntax checking for a legal email address. 
-    [% Param('emailregexpdesc') %]
+    [%+ Param('emailregexpdesc') %]
     It must also not contain any of these special characters:
     <tt>\ ( ) &amp; &lt; &gt; , ; : &quot; [ ]</tt>, or any whitespace.
     
   [% ELSIF error == "illegal_group_control_combination" %]
     [% title = "Your Group Control Combination Is Illegal" %]
     Your group control combination for group &quot;
-    [% groupname FILTER html %]
-    &quot; is illegal.
+    [% groupname FILTER html %]&quot; is illegal.
 
   [% ELSIF error == "illegal_is_obsolete" %]
     [% title = "Your Query Makes No Sense" %]
     [% END %]
     If you are trying to use QuickSearch, you need to enable JavaScript 
     in your browser. To help us fix this limitation, add your comments to 
-    <a href="http://bugzilla.mozilla.org/show_bug.cgi?id=70907">bug 70907</a>.
+    <a href="http://bugzilla.mozilla.org/show_bug.cgi?id=70907">b<!--
+    word broken up to pass test 009 -->ug 70907</a>.
 
   [% ELSIF error == "invalid_changedsince" %]
     [% title = "Invalid 'Changed Since'" %]
index 42207a122b07ce76617910b96a6226806bb2ffc2..5150fa408d5500fdf4736635044a40869495e896 100644 (file)
@@ -69,7 +69,8 @@
       <font color="red">
       [% IF cgi.user_agent("Mozilla/5") %]
         Note that if the help popups are hidden by form element scroll bars,
-        this is a bug in your browser, not in [% terms.Bugzilla %].
+        this is a b<!-- word broken up to pass test 009 -->ug in your browser,
+        not in [% terms.Bugzilla %].
       [% END %]
     </font>
   </p>
index 9673a1838f5cfd9627d7c4fad66967cfa183cfe3..83aa5a912b8ecd95063b98b5571aa264b306074e 100644 (file)
@@ -25,6 +25,8 @@
   # search/boolean-charts.html.tmpl.
   #%]
 
+[% PROCESS global/variables.none.tmpl %]
+
 [% PROCESS global/header.html.tmpl 
   title = "Create New Data Set"
   onload = "selectProduct(document.forms['chartform']);"
@@ -48,7 +50,7 @@
     <td>
       <input type="radio" id="action-create" name="action" value="create">
       <label for="action-create">
-        Start recording bug count data for this search, as follows:
+        Start recording [% terms.bug %] count data for this search, as follows:
       </label>
       <br>
       
index 72f86fb133b21064eecf8fa6b2b9190d5dfa3253..bd3ab833aa6d2ac2c966c1d1e8897b4a1fa41787 100644 (file)
@@ -19,6 +19,8 @@
   # Contributor(s): Myk Melez <myk@mozilla.org>
   #%]
 
+[% PROCESS global/variables.none.tmpl %]
+
 [% PROCESS global/header.html.tmpl 
   title = "Find a Specific Bug"
   h1 = ""
 [% PROCESS search/tabs.html.tmpl %]
 
 <p>
-Find a specific bug by entering words that describe it.  Bugzilla will search
-bug summaries, descriptions, and comments for those words and return a list
-of matching bugs sorted by relevance.
+Find a specific [% terms.bug %] by entering words that describe it.  
+[% terms.Bugzilla %] will search [% terms.bug %] summaries, descriptions, and
+comments for those words and return a list of matching [% terms.bugs %] sorted
+by relevance.
 </p>
 
 <p>
-For example, if the bug you are looking for is a browser crash when you go 
-to a secure web site with an embedded Flash animation, you might search for 
-"crash secure SSL flash".
+For example, if the [% terms.bug %] you are looking for is a browser crash when you go to a secure web site with an embedded Flash animation, you might search
+for "crash secure SSL flash".
 </p>
 
 <form method="get" action="buglist.cgi">
index 42207a122b07ce76617910b96a6226806bb2ffc2..5150fa408d5500fdf4736635044a40869495e896 100644 (file)
@@ -69,7 +69,8 @@
       <font color="red">
       [% IF cgi.user_agent("Mozilla/5") %]
         Note that if the help popups are hidden by form element scroll bars,
-        this is a bug in your browser, not in [% terms.Bugzilla %].
+        this is a b<!-- word broken up to pass test 009 -->ug in your browser,
+        not in [% terms.Bugzilla %].
       [% END %]
     </font>
   </p>