From 7fb53e418a48b8baa7bcab89967a0755f2230162 Mon Sep 17 00:00:00 2001 From: "Christopher R. Nelson" Date: Sun, 1 Nov 2026 00:16:04 -0400 Subject: Show subdirectories as nested submenus Each subdirectory of the wallpaper directory becomes an inline Openbox submenu, recursively, listed before the files at that level. A directory with no wallpapers and no subdirectories gets the same "No wallpapers in ..." header as an empty root. Hidden directories are skipped, and symlinks pointing back up the tree are not followed. Co-Authored-By: Claude Opus 5.5 --- t/tests.lisp | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) (limited to 't') diff --git a/t/tests.lisp b/t/tests.lisp index 6baf5ed..bdb109f 100644 --- a/t/tests.lisp +++ b/t/tests.lisp @@ -138,3 +138,72 @@ extensions = .PNG, jpg webp"))) (render-menu (make-config :directory (namestring dir)) s)))) (check (search "" xml :from-end t))) + (check (not (search "No wallpapers" xml)))))) + +(deftest test-render-empty-subdirectory + (with-temp-dir (dir) + (touch dir "top.png") + (let ((empty (subdir dir "empty"))) + (touch empty "readme.txt") + (let ((xml (render-to-string dir))) + (check (search "label=\"empty\"" xml)) + (check (search (format nil "" + (uiop:native-namestring empty)) + xml)))))) + +(deftest test-render-root-with-only-subdirectories + (with-temp-dir (dir) + (touch (subdir dir "only") "a.png") + (let ((xml (render-to-string dir))) + (check (search "label=\"a\"" xml)) + (check (not (search "No wallpapers" xml)))))) + +(deftest test-render-skips-hidden-directories + (with-temp-dir (dir) + (touch (subdir dir ".thumbnails") "a.png") + (let ((xml (render-to-string dir))) + (check (not (search "thumbnails" xml))) + (check (search "No wallpapers in" xml))))) + +(deftest test-render-symlink-loop + (with-temp-dir (dir) + (let ((sub (subdir dir "sub"))) + (touch sub "a.png") + (uiop:run-program (list "ln" "-s" (uiop:native-namestring dir) + (uiop:native-namestring (merge-pathnames "loop" sub)))) + (let ((xml (render-to-string dir))) + (check (search "label=\"a\"" xml)) + (check (not (search "label=\"loop\"" xml))))))) -- cgit v1.2.3