[Pkg-debile-commits] [debile-slave] 17/100: add desktop-file-validate
Sylvestre Ledru
sylvestre at alioth.debian.org
Mon Aug 19 14:53:00 UTC 2013
This is an automated email from the git hooks/post-receive script.
sylvestre pushed a commit to branch master
in repository debile-slave.
commit c8ca1ced6efed1581bcc76f024613a609ad7dd23
Author: Paul Tagliamonte <tag at pault.ag>
Date: Fri May 24 22:57:44 2013 -0400
add desktop-file-validate
---
ethel/wrappers/desktop_file_validate.py | 29 ++++++++++++++
tests/wrappers/test_desktop_file_validate.py | 52 ++++++++++++++++++++++++++
2 files changed, 81 insertions(+)
diff --git a/ethel/wrappers/desktop_file_validate.py b/ethel/wrappers/desktop_file_validate.py
new file mode 100644
index 0000000..6d7b6c8
--- /dev/null
+++ b/ethel/wrappers/desktop_file_validate.py
@@ -0,0 +1,29 @@
+from firehose.model import Issue, Message, File, Location, Point
+import re
+
+
+# screensaver.desktop: error: value "AWESOME" for string
+LINE_EXPR = re.compile(
+ r"(?P<path>.*): (?P<severity>.*): (?P<msg>.*)"
+)
+
+
+def parse_desktop_file_validate(lines):
+ for line in lines:
+
+ info = LINE_EXPR.match(line).groupdict()
+
+ path = info['path']
+ message = info['msg']
+ severity = info['severity']
+
+ yield Issue(cwe=None,
+ testid=None,
+ location=Location(
+ file=File(path, None),
+ function=None,
+ point=None),
+ severity=severity,
+ message=Message(text=message),
+ notes=None,
+ trace=None)
diff --git a/tests/wrappers/test_desktop_file_validate.py b/tests/wrappers/test_desktop_file_validate.py
new file mode 100644
index 0000000..1b8c9cc
--- /dev/null
+++ b/tests/wrappers/test_desktop_file_validate.py
@@ -0,0 +1,52 @@
+from ethel.wrappers.desktop_file_validate import parse_desktop_file_validate
+
+
+STRINGS = [
+ ('gsm.desktop: warning: value "GSM" for key "Comment" in group '
+ '"Desktop Entry" looks redundant with value "GSM" of key "Name"',
+ "warning"),
+
+ ('gsm.desktop: error: value "AWESOME" for string list key "OnlyShowIn" '
+ 'in group "Desktop Entry" does not have a semicolon (\';\') as '
+ 'trailing character',
+ "error"),
+
+ ('polkit.desktop: warning: value "polkit" for key "Comment" in group '
+ '"Desktop Entry" looks redundant with value "polkit" of key "Name"',
+ "warning"),
+
+ ('screensaver.desktop: warning: value "GSS" for key "Comment" in group '
+ '"Desktop Entry" looks redundant with value "GSS" of key "Name"',
+ "warning"),
+
+ ('screensaver.desktop: error: value "AWESOME" for string list key '
+ '"OnlyShowIn" in group "Desktop Entry" does not have a semicolon '
+ '(\';\') as trailing character',
+ "error"),
+
+ ('sound.desktop: warning: value "GSA" for key "Comment" in group '
+ '"Desktop Entry" looks redundant with value "GSA" of key "Name"',
+ "warning"),
+ ('update-notifier.desktop: warning: key "Encoding" in group '
+ '"Desktop Entry" is deprecated',
+ "warning"),
+ ('xfce4.desktop: warning: value "XSM" for key "Comment" in group '
+ '"Desktop Entry" looks redundant with value "XSM" of key "Name"',
+ "warning"),
+ ('xfce4.desktop: error: value "FLUXBOX" for string list key "OnlyShowIn" '
+ 'in group "Desktop Entry" does not have a semicolon (\';\') '
+ 'as trailing character',
+ "error"),
+ ('xfce4-settings-helper-autostart.desktop: error: required key "Type" in '
+ 'group "Desktop Entry" is not present',
+ "error"),
+ ('xfce4-settings-helper-autostart.desktop: error: required key "Name" in '
+ 'group "Desktop Entry" is not present',
+ "error"),
+]
+
+
+def test_desktop_file_validate():
+ for string, expected in STRINGS:
+ issue = next(parse_desktop_file_validate([string]))
+ assert issue.severity == expected
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-debile/debile-slave.git
More information about the Pkg-debile-commits
mailing list