aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMark Oteiza2017-09-09 11:55:09 -0400
committerMark Oteiza2017-09-09 12:26:50 -0400
commit4131f9785e30f2a31745125c714e922892113c62 (patch)
tree56858ce56448c799997008648b23e647cebd526d /test
parent68b7ecbac1dcb5bfcace5505a4d354777147dd54 (diff)
downloademacs-4131f9785e30f2a31745125c714e922892113c62.tar.gz
emacs-4131f9785e30f2a31745125c714e922892113c62.zip
Add function to read all entries in a group
Use that to extend xdg-desktop-read-file. Also fix a bug where all entries in all groups were read and returned by xdg-desktop-read-file. * lisp/xdg.el (xdg-desktop-read-group): New function. (xdg-desktop-read-file): Use it. * test/data/xdg/malformed.desktop: New file. * test/data/xdg/test.desktop: Add another section. * test/lisp/xdg-tests.el (xdg-desktop-parsing): Test presence of a key in another group. Test reading a prescribed group. Test detecting a malformed key=value.
Diffstat (limited to 'test')
-rw-r--r--test/data/xdg/malformed.desktop4
-rw-r--r--test/data/xdg/test.desktop2
-rw-r--r--test/lisp/xdg-tests.el16
3 files changed, 18 insertions, 4 deletions
diff --git a/test/data/xdg/malformed.desktop b/test/data/xdg/malformed.desktop
new file mode 100644
index 00000000000..144a3f719d5
--- /dev/null
+++ b/test/data/xdg/malformed.desktop
@@ -0,0 +1,4 @@
1# unacceptable key=value format
2[Desktop Entry]
3Key=value
4aowef faoweif of
diff --git a/test/data/xdg/test.desktop b/test/data/xdg/test.desktop
index b6dda62774a..b848cef5b0f 100644
--- a/test/data/xdg/test.desktop
+++ b/test/data/xdg/test.desktop
@@ -1,3 +1,5 @@
1# this is a comment 1# this is a comment
2[Desktop Entry] 2[Desktop Entry]
3Name=Test 3Name=Test
4[Another Section]
5Exec=frobnicate
diff --git a/test/lisp/xdg-tests.el b/test/lisp/xdg-tests.el
index 59c850b07af..4822a05c1e4 100644
--- a/test/lisp/xdg-tests.el
+++ b/test/lisp/xdg-tests.el
@@ -32,12 +32,20 @@
32 32
33(ert-deftest xdg-desktop-parsing () 33(ert-deftest xdg-desktop-parsing ()
34 "Test `xdg-desktop-read-file' parsing of .desktop files." 34 "Test `xdg-desktop-read-file' parsing of .desktop files."
35 (let ((tab (xdg-desktop-read-file 35 (let ((tab1 (xdg-desktop-read-file
36 (expand-file-name "test.desktop" xdg-tests-data-dir)))) 36 (expand-file-name "test.desktop" xdg-tests-data-dir)))
37 (should (equal (gethash "Name" tab) "Test"))) 37 (tab2 (xdg-desktop-read-file
38 (expand-file-name "test.desktop" xdg-tests-data-dir)
39 "Another Section")))
40 (should (equal (gethash "Name" tab1) "Test"))
41 (should (eq 'default (gethash "Exec" tab1 'default)))
42 (should (equal "frobnicate" (gethash "Exec" tab2))))
38 (should-error 43 (should-error
39 (xdg-desktop-read-file 44 (xdg-desktop-read-file
40 (expand-file-name "wrong.desktop" xdg-tests-data-dir)))) 45 (expand-file-name "wrong.desktop" xdg-tests-data-dir)))
46 (should-error
47 (xdg-desktop-read-file
48 (expand-file-name "malformed.desktop" xdg-tests-data-dir))))
41 49
42(ert-deftest xdg-desktop-strings-type () 50(ert-deftest xdg-desktop-strings-type ()
43 "Test desktop \"string(s)\" type: strings delimited by \";\"." 51 "Test desktop \"string(s)\" type: strings delimited by \";\"."