[Libreoffice-commits] core.git: bin/gla11y solenv/gbuild solenv/sanitizers

Samuel Thibault sthibault at hypra.fr
Tue Mar 27 13:28:57 UTC 2018


 bin/gla11y                                 |   38 +++++++++++++++++++++++++----
 solenv/gbuild/UIConfig.mk                  |    3 +-
 solenv/sanitizers/ui/modules/swriter.false |    1 
 3 files changed, 36 insertions(+), 6 deletions(-)

New commits:
commit 8b9075f8f4f47c469dd63c3a3bc2d55d41f5e735
Author: Samuel Thibault <sthibault at hypra.fr>
Date:   Wed Mar 14 13:09:55 2018 +0100

    gla11y: add support for marking false positives
    
    Change-Id: I62c24f0aa20dea1cca4ba77a71dbb247bc37a5b5
    Reviewed-on: https://gerrit.libreoffice.org/51545
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/bin/gla11y b/bin/gla11y
index e19e580d0d4f..8b2746fb4a98 100755
--- a/bin/gla11y
+++ b/bin/gla11y
@@ -248,6 +248,7 @@ widgets_labels = [
 progname = os.path.basename(sys.argv[0])
 
 suppressions = {}
+false_positives = {}
 ids = {}
 ids_dup = {}
 labelled_by_elm = {}
@@ -422,12 +423,12 @@ def elm_suppr(filename, tree, elm, msgtype, dogen):
     """
     global gen_suppr, gen_supprfile, suppr_prefix, pflag
 
-    if suppressions or gen_suppr is not None or pflag:
+    if suppressions or false_positives or gen_suppr is not None or pflag:
         prefix = errpath(filename, tree, elm)
         if prefix[0:len(suppr_prefix)] == suppr_prefix:
             prefix = prefix[len(suppr_prefix):]
 
-    if suppressions or gen_suppr is not None:
+    if suppressions or false_positives or gen_suppr is not None:
         suppr = '%s %s' % (prefix, msgtype)
 
         if gen_suppr is not None and msgtype is not None and dogen:
@@ -476,6 +477,9 @@ def err(filename, tree, elm, msgtype, msg, error = True):
         return
 
     (prefix, suppr) = elm_suppr(filename, tree, elm, msgtype, True)
+    if suppr in false_positives:
+        # That was actually expected
+        return
     if suppr in suppressions:
         # Suppressed
         suppressions[suppr] = False
@@ -668,6 +672,9 @@ def is_orphan_label(filename, tree, root, obj, orphan_root, doprint = False):
 
     # No label-for, no mnemonic-for, no labelled-by, we are orphan.
     (_, suppr) = elm_suppr(filename, tree, obj, "orphan-label", False)
+    if suppr in false_positives:
+        # That was actually expected
+        return False
     if suppr in suppressions:
         # Warning suppressed for this label
         if suppressions[suppr]:
@@ -774,6 +781,9 @@ def is_orphan_widget(filename, tree, root, obj, orphan, orphan_root, doprint = F
             # Warnings disabled
             return False
         (_, suppr) = elm_suppr(filename, tree, obj, "button-no-label", False)
+        if suppr in false_positives:
+            # That was actually expected
+            return False
         if suppr in suppressions:
             # Warning suppressed for this widget
             if suppressions[suppr]:
@@ -818,6 +828,9 @@ def is_orphan_widget(filename, tree, root, obj, orphan, orphan_root, doprint = F
         # Warnings disabled for this class of widgets
         return False
     (_, suppr) = elm_suppr(filename, tree, obj, "no-labelled-by", False)
+    if suppr in false_positives:
+        # That was actually expected
+        return False
     if suppr in suppressions:
         # Warning suppressed for this widget
         if suppressions[suppr]:
@@ -1041,12 +1054,13 @@ def check_a11y_relation(filename, tree):
 #
 
 def usage():
-    print("%s [-p] [-g SUPPR_FILE] [-s SUPPR_FILE] [-i WIDGET1,WIDGET2[,...]] [-o LOG_FILE] [file ...]" % progname,
+    print("%s [-p] [-g SUPPR_FILE] [-s SUPPR_FILE] [-f SUPPR_FILE] [-i WIDGET1,WIDGET2[,...]] [-o LOG_FILE] [file ...]" % progname,
           file=sys.stderr)
     print("")
     print("  -p Print XML class path instead of line number")
     print("  -g Generate suppression file SUPPR_FILE")
     print("  -s Suppress warnings given by file SUPPR_FILE")
+    print("  -f Suppress warnings given by file SUPPR_FILE completely")
     print("  -i Ignore warnings for widgets of a given class")
     print("  -o Also prints errors and warnings to given file")
     print("")
@@ -1109,12 +1123,12 @@ def widgets_opt(widgets_list, arg):
 
 
 def main():
-    global pflag, gen_suppr, gen_supprfile, suppressions, suppr_prefix, dofatals, enables, dofatals, warn_orphan_labels
+    global pflag, gen_suppr, gen_supprfile, suppressions, suppr_prefix, false_positives, dofatals, enables, dofatals, warn_orphan_labels
     global widgets_toplevel, widgets_ignored, widgets_suffixignored, widgets_needlabel, widgets_buttons, widgets_labels
     global outfile
 
     try:
-        opts, args = getopt.getopt(sys.argv[1:], "piIg:s:P:o:L:", [
+        opts, args = getopt.getopt(sys.argv[1:], "piIg:s:f:P:o:L:", [
                 "widgets-toplevel=",
                 "widgets-ignored=",
                 "widgets-suffixignored=",
@@ -1149,6 +1163,7 @@ def main():
         usage()
 
     suppr = None
+    false = None
     out = None
     filelist = None
 
@@ -1159,6 +1174,8 @@ def main():
             gen_suppr = a
         elif o == "-s":
             suppr = a
+        elif o == "-f":
+            false = a
         elif o == "-P":
             suppr_prefix = a
         elif o == "-o":
@@ -1241,6 +1258,17 @@ def main():
         except IOError:
             pass
 
+    # Read false positives file
+    if false is not None:
+        try:
+            falsefile = open(false, 'r')
+            for line in falsefile.readlines():
+                prefix = line.rstrip()
+                false_positives[prefix] = True
+            falsefile.close()
+        except IOError:
+            pass
+
     if out is not None:
         outfile = open(out, 'w')
 
diff --git a/solenv/gbuild/UIConfig.mk b/solenv/gbuild/UIConfig.mk
index fb3d82d0b912..4923dd26e431 100644
--- a/solenv/gbuild/UIConfig.mk
+++ b/solenv/gbuild/UIConfig.mk
@@ -125,7 +125,7 @@ $(call gb_UIConfig_get_clean_target,%) :
 	$(call gb_Output_announce,$*,$(false),UIA,2)
 	rm -f $(call gb_UIConfig_get_a11yerrors_target,$*)
 
-gb_UIConfig_gla11y_PARAMETERS = -P $(SRCDIR)/
+gb_UIConfig_gla11y_PARAMETERS = -P $(SRCDIR)/ -f $(UI_A11YFALSE)
 
 # Disable this to see suppressed warnings
 ifeq (1,1)
@@ -226,6 +226,7 @@ $(call gb_UIConfig_get_target,$(1)) :| $(dir $(call gb_UIConfig_get_target,$(1))
 $(call gb_UIConfig_get_imagelist_target,$(1)) :| $(dir $(call gb_UIConfig_get_imagelist_target,$(1))).dir
 $(call gb_UIConfig_get_a11yerrors_target,$(1)) :| $(dir $(call gb_UIConfig_get_a11yerrors_target,$(1))).dir
 $(call gb_UIConfig_get_a11yerrors_target,$(1)) : UI_A11YSUPPRS := $(SRCDIR)/solenv/sanitizers/ui/$(1).suppr
+$(call gb_UIConfig_get_a11yerrors_target,$(1)) : UI_A11YFALSE := $(SRCDIR)/solenv/sanitizers/ui/$(1).false
 $(call gb_UIConfig_get_target,$(1)) : $(call gb_PackageSet_get_target,$(call gb_UIConfig_get_packagesetname,$(1)))
 $(call gb_UIConfig_get_clean_target,$(1)) : $(call gb_PackageSet_get_clean_target,$(call gb_UIConfig_get_packagesetname,$(1)))
 
diff --git a/solenv/sanitizers/ui/modules/swriter.false b/solenv/sanitizers/ui/modules/swriter.false
new file mode 100644
index 000000000000..bbba7d731c7e
--- /dev/null
+++ b/solenv/sanitizers/ui/modules/swriter.false
@@ -0,0 +1 @@
+sw/uiconfig/swriter/ui/sortdialog.ui://GtkLabel[@id='order'] orphan-label


More information about the Libreoffice-commits mailing list