[Libreoffice-commits] .: bug/Makefile bug/query.pl bug/sanity-components.xhtml bug/sanity.pl bug/sanity-query.xhtml

Loic Dachary loic at kemper.freedesktop.org
Fri Oct 7 03:22:16 PDT 2011


 bug/Makefile                |    6 +-
 bug/query.pl                |    7 +-
 bug/sanity-components.xhtml |   22 ++++++++
 bug/sanity-query.xhtml      |    4 +
 bug/sanity.pl               |  113 ++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 147 insertions(+), 5 deletions(-)

New commits:
commit 92f485d622ae0d0d454f3b3d6e0dd00f4363f73b
Author: Loic Dachary <loic at dachary.org>
Date:   Fri Oct 7 12:21:56 2011 +0200

    The sanity.pl script is added to detect inconsistencies in the data extracted from the wiki and the data extracted from bugzilla. It is run each time the Bug Submission Assistant is created and will exit on error if an inconsistency is found. It checks if a) a component is found in the wiki and not in bugzilla and vice versa, b) if a component shows multiple times in the wiki.

diff --git a/bug/Makefile b/bug/Makefile
index 60359d8..56665d7 100644
--- a/bug/Makefile
+++ b/bug/Makefile
@@ -23,9 +23,13 @@ extract:
 	xsltproc --encoding UTF-8 --novalid subcomponents.xsl BugReport_Details.xhtml > subcomponents.xhtml
 	xsltproc --encoding UTF-8 --novalid components.xsl BugReport_Details.xhtml > components.xhtml
 	curl --silent 'https://bugs.freedesktop.org/query.cgi?product=LibreOffice&query_format=advanced' > query.xhtml
-	perl query.pl versions < query.xhtml > versions.xhtml
+	perl query.pl < query.xhtml > versions.xhtml
+	perl sanity.pl query.xhtml components.xhtml
 
 compose:
 	xsltproc --encoding UTF-8 --novalid \
 		--stringparam serial `date +%s` \
 		bug.xsl bug.xhtml > bug/bug.html
+
+check:
+	perl sanity.pl TEST
diff --git a/bug/query.pl b/bug/query.pl
index d9abde2..ad79e00 100644
--- a/bug/query.pl
+++ b/bug/query.pl
@@ -30,9 +30,8 @@ while(<STDIN>) {
 
 print "<?xml version='1.0' encoding='ISO-8859-1'?>\n";
 
-if($ARGV[0] eq 'versions') {
-    @versions = sort(@{$vers[$libreoffice]});
-    print <<EOF;
+ at versions = sort(@{$vers[$libreoffice]});
+print <<EOF;
 	  <div class="versions select">
             <div class="select-header">
               <div class="chosen">(chose one)</div>
@@ -62,4 +61,4 @@ EOF
             </div>
 	  </div>
 EOF
-}
+
diff --git a/bug/sanity-components.xhtml b/bug/sanity-components.xhtml
new file mode 100644
index 0000000..72956ca
--- /dev/null
+++ b/bug/sanity-components.xhtml
@@ -0,0 +1,22 @@
+                <li data="BASIC" class="choice">BASIC</li>
+                <li data="Chart" class="choice">Chart</li>
+                <li data="contrib" class="choice">contrib</li>
+                <li data="Database" class="choice">Database</li>
+                <li data="Database" class="choice">Database</li>
+                <li data="Documentation" class="choice">Documentation</li>
+                <li data="Drawing" class="choice">Drawing</li>
+                <li data="Extensions" class="choice">Extensions</li>
+                <li data="UI" class="choice">UI</li>
+                <li data="Formula_editor" class="choice">Formula
+editor</li>
+                <li data="Installation" class="choice">Installation</li>
+                <li data="Libreoffice" class="choice">Libreoffice</li>
+                <li data="Linguistic_component" class="choice">Linguistic
+component</li>
+                <li data="Localization" class="choice">Localization</li>
+                <li data="PDF_export" class="choice">PDF
+export</li>
+                <li data="Presentation" class="choice">Presentation</li>
+                <li data="Spreadsheet" class="choice">Spreadsheet</li>
+                <li data="Writer" class="choice">Writer</li>
+                <li data="WWW" class="choice">WWW</li>
diff --git a/bug/sanity-query.xhtml b/bug/sanity-query.xhtml
new file mode 100644
index 0000000..e1b3679
--- /dev/null
+++ b/bug/sanity-query.xhtml
@@ -0,0 +1,4 @@
+cpts[0] = ['BASIC', 'BugAssistant', 'Chart', 'contrib', 'Database', 'Documentation', 'Drawing', 'Extensions', 'Formula editor', 'Installation', 'Libreoffice', 'Linguistic component', 'Localisation', 'PDF export', 'Presentation', 'Spreadsheet', 'UI', 'Writer', 'WWW' ];
+<select name="product" multiple="multiple" size="5" id="product"
+                      <option value="LibreOffice" selected>LibreOffice</option>
+</select>
diff --git a/bug/sanity.pl b/bug/sanity.pl
new file mode 100644
index 0000000..54a931c
--- /dev/null
+++ b/bug/sanity.pl
@@ -0,0 +1,113 @@
+#
+#     Copyright (C) 2011 Loic Dachary <loic at dachary.org>
+#
+#     This program is free software: you can redistribute it and/or modify
+#     it under the terms of the GNU General Public License as published by
+#     the Free Software Foundation, either version 3 of the License, or
+#     (at your option) any later version.
+#
+#     This program is distributed in the hope that it will be useful,
+#     but WITHOUT ANY WARRANTY; without even the implied warranty of
+#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#     GNU General Public License for more details.
+#
+#     You should have received a copy of the GNU General Public License
+#     along with this program.  If not, see <http:www.gnu.org/licenses/>.
+#
+sub parse {
+    my($query_path, $components_path) = @_;
+    my($key, $value) = @_;
+
+    open(QUERY, $query_path) or die "$query_path: $!";
+    while(<QUERY>) {
+        eval $_ if(s/(cpts|vers)\[(\d+)\]\s+=/\$$1\[$2\]=/);
+        if(/<select\s+name="product"/../<\/select/) {
+            if(/libreoffice/i) {
+                $libreoffice = $count;
+            }
+            if(/<select\s+name="product"/) {
+                $count = 0;
+            } elsif(/<option/) {
+                $count++;
+            }
+        }
+    }
+    close(QUERY);
+
+    foreach (@{$cpts[$libreoffice]}) {
+        # 
+        next if($_ eq 'BugAssistantTest');
+        $bugzilla2wiki{$_} = 0;
+    }
+
+    open(COMPONENTS, $components_path) or die "$components_path: $!";
+    while(<COMPONENTS>) {
+        if(/data="(.*?)"/) {
+            $component = $1;
+            $component =~ s/_/ /g;
+            if(exists $bugzilla2wiki{$component}) {
+                $bugzilla2wiki{$component}++;
+            } else {
+                $bugzilla2wiki{$component} = -1;
+            }
+        }
+    }
+    close(COMPONENTS);
+
+    return \%bugzilla2wiki;
+}
+
+sub analyze {
+    my($bugzilla2wiki, $query_path, $components_path) = @_;
+
+    my($status) = 0;
+
+    while ( my ($key, $value) = each(%$bugzilla2wiki) ) {
+        if($value == -1) {
+            print "component $key found in the wiki but not in the bugzilla\n";
+            $status++;
+        } elsif($value == 0) {
+            print "component $key found in bugzilla but not in the wiki\n";
+            $status++;
+        } elsif($value > 1) {
+            print "component $key found $value times in the wiki\n";
+            $status++;
+        }
+    }
+    if($status > 0) {
+        print "wiki URL http://wiki.documentfoundation.org/BugReport_Details\n";
+        print "components extracted with components.xsl from the wiki are in $components_path\n";
+        print "bugzilla URL https://bugassistant.libreoffice.org/enter_bug.cgi?product=LibreOffice\n";
+        print "bugzilla information retrieved from $query_path\n";
+    }
+    return $status;
+}
+
+sub tests {
+    use Test::More;
+
+    my($bugzilla2wiki) = parse('sanity-query.xhtml', 'sanity-components.xhtml');
+
+    while ( my ($key, $value) = each(%$bugzilla2wiki) ) {
+        if($key eq "BugAssistant" || $key eq "Localisation") {
+            ok($value == 0, "$key $value");
+        } elsif($key eq 'Localization') {
+            ok($value == -1, "$key $value");
+        } elsif($key eq 'Database') {
+            ok($value == 2, "$key $value");
+        } else {
+            ok($value == 1, "$key $value");
+        }
+    }
+
+    my($status) = analyze($bugzilla2wiki, 'sanity-query.xhtml', 'sanity-components.xhtml');
+    ok($status == 4, "analyze $status");
+
+    done_testing(21);
+}
+
+if($ARGV[0] eq 'TEST') {
+    tests();
+} else {
+    exit(analyze(parse($ARGV[0], $ARGV[1]), $ARGV[0], $ARGV[1]));
+}


More information about the Libreoffice-commits mailing list