aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJim Porter2022-06-25 18:19:01 -0700
committerLars Ingebrigtsen2022-06-26 16:52:38 +0200
commit7fc3f1b0d14ad390ca361a40ecf02eaa9f1b202a (patch)
treec2e0e4641a6ead3b72a8f0d5534299833cf6d568 /test
parentea3681575f24ab6766931d0c86f080c52f2ce2d7 (diff)
downloademacs-7fc3f1b0d14ad390ca361a40ecf02eaa9f1b202a.tar.gz
emacs-7fc3f1b0d14ad390ca361a40ecf02eaa9f1b202a.zip
Make Eshell globs ending in "/" match directories only
* lisp/eshell/em-glob.el (eshell-glob-convert): Return whether to match directories only. (eshell-glob-entries): Add ONLY-DIRS argument. * test/lisp/eshell/em-glob-tests.el (em-glob-test/match-any-directory): New test. (em-glob-test/match-recursive) (em-glob-test/match-recursive-follow-symlinks): Add test cases for when "**/" or "***/" are the last components in a glob. * etc/NEWS: Announce this change (bug#56227).
Diffstat (limited to 'test')
-rw-r--r--test/lisp/eshell/em-glob-tests.el15
1 files changed, 13 insertions, 2 deletions
diff --git a/test/lisp/eshell/em-glob-tests.el b/test/lisp/eshell/em-glob-tests.el
index 65f340a8dad..b733be35d9a 100644
--- a/test/lisp/eshell/em-glob-tests.el
+++ b/test/lisp/eshell/em-glob-tests.el
@@ -60,6 +60,12 @@ component ending in \"symlink\" is treated as a symbolic link."
60 (should (equal (eshell-extended-glob "*.el") 60 (should (equal (eshell-extended-glob "*.el")
61 '("a.el" "b.el"))))) 61 '("a.el" "b.el")))))
62 62
63(ert-deftest em-glob-test/match-any-directory ()
64 "Test that \"*/\" pattern matches any directory."
65 (with-fake-files '("a.el" "b.el" "dir/a.el" "dir/sub/a.el" "symlink/")
66 (should (equal (eshell-extended-glob "*/")
67 '("dir/" "symlink/")))))
68
63(ert-deftest em-glob-test/match-any-character () 69(ert-deftest em-glob-test/match-any-character ()
64 "Test that \"?\" pattern matches any character." 70 "Test that \"?\" pattern matches any character."
65 (with-fake-files '("a.el" "b.el" "ccc.el" "d.txt" "dir/a.el") 71 (with-fake-files '("a.el" "b.el" "ccc.el" "d.txt" "dir/a.el")
@@ -71,7 +77,9 @@ component ending in \"symlink\" is treated as a symbolic link."
71 (with-fake-files '("a.el" "b.el" "ccc.el" "d.txt" "dir/a.el" "dir/sub/a.el" 77 (with-fake-files '("a.el" "b.el" "ccc.el" "d.txt" "dir/a.el" "dir/sub/a.el"
72 "dir/symlink/a.el" "symlink/a.el" "symlink/sub/a.el") 78 "dir/symlink/a.el" "symlink/a.el" "symlink/sub/a.el")
73 (should (equal (eshell-extended-glob "**/a.el") 79 (should (equal (eshell-extended-glob "**/a.el")
74 '("a.el" "dir/a.el" "dir/sub/a.el"))))) 80 '("a.el" "dir/a.el" "dir/sub/a.el")))
81 (should (equal (eshell-extended-glob "**/")
82 '("dir/" "dir/sub/")))))
75 83
76(ert-deftest em-glob-test/match-recursive-follow-symlinks () 84(ert-deftest em-glob-test/match-recursive-follow-symlinks ()
77 "Test that \"***/\" recursively matches directories, following symlinks." 85 "Test that \"***/\" recursively matches directories, following symlinks."
@@ -79,7 +87,10 @@ component ending in \"symlink\" is treated as a symbolic link."
79 "dir/symlink/a.el" "symlink/a.el" "symlink/sub/a.el") 87 "dir/symlink/a.el" "symlink/a.el" "symlink/sub/a.el")
80 (should (equal (eshell-extended-glob "***/a.el") 88 (should (equal (eshell-extended-glob "***/a.el")
81 '("a.el" "dir/a.el" "dir/sub/a.el" "dir/symlink/a.el" 89 '("a.el" "dir/a.el" "dir/sub/a.el" "dir/symlink/a.el"
82 "symlink/a.el" "symlink/sub/a.el"))))) 90 "symlink/a.el" "symlink/sub/a.el")))
91 (should (equal (eshell-extended-glob "***/")
92 '("dir/" "dir/sub/" "dir/symlink/" "symlink/"
93 "symlink/sub/")))))
83 94
84(ert-deftest em-glob-test/match-recursive-mixed () 95(ert-deftest em-glob-test/match-recursive-mixed ()
85 "Test combination of \"**/\" and \"***/\"." 96 "Test combination of \"**/\" and \"***/\"."