aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2025-03-01 10:12:21 +0200
committerEli Zaretskii2025-03-01 10:12:21 +0200
commit61320784ed2a8f5f3dcdeb401579d220e5dc05da (patch)
treeb9e94af76e1c4d8df777e56ae1e4dc90ee83ddb1
parentbc33b70b280933470b252f2a877fd50e4aed42ba (diff)
downloademacs-61320784ed2a8f5f3dcdeb401579d220e5dc05da.tar.gz
emacs-61320784ed2a8f5f3dcdeb401579d220e5dc05da.zip
Add a portable test for ffap parsing path-style directory lists
* test/lisp/ffap-tests.el (ffap-test-path-unix): Renamed from 'ffap-test-path'. (ffap-test-path-portable): New test, which should work on all systems.
-rw-r--r--test/lisp/ffap-tests.el28
1 files changed, 27 insertions, 1 deletions
diff --git a/test/lisp/ffap-tests.el b/test/lisp/ffap-tests.el
index b07a4c4fbc6..3c6e1e8e18e 100644
--- a/test/lisp/ffap-tests.el
+++ b/test/lisp/ffap-tests.el
@@ -165,7 +165,7 @@ left alone when opening a URL in an external browser."
165 (let (kill-buffer-query-functions) 165 (let (kill-buffer-query-functions)
166 (kill-buffer (call-interactively #'find-file-at-point))))))) 166 (kill-buffer (call-interactively #'find-file-at-point)))))))
167 167
168(ert-deftest ffap-test-path () 168(ert-deftest ffap-test-path-unix ()
169 (skip-unless (file-exists-p "/bin")) 169 (skip-unless (file-exists-p "/bin"))
170 (skip-unless (file-exists-p "/usr/bin")) 170 (skip-unless (file-exists-p "/usr/bin"))
171 (with-temp-buffer 171 (with-temp-buffer
@@ -182,6 +182,32 @@ left alone when opening a URL in an external browser."
182 (goto-char (point-min)) 182 (goto-char (point-min))
183 (should (equal (ffap-file-at-point) nil)))) 183 (should (equal (ffap-file-at-point) nil))))
184 184
185(ert-deftest ffap-test-path-portable ()
186 ;; Why 'load-path' and not 'exec-path'? Because there are various
187 ;; complications when the test is run on Windows from MSYS Bash: the
188 ;; few first directories MSYS adds to the system PATH may not exist,
189 ;; and the very first one is ".", which ffap-file-at-point doesn't
190 ;; recognize as a file.
191 (skip-unless (> (length load-path) 2))
192 (let ((dir1 (expand-file-name (car load-path)))
193 (dir2 (expand-file-name (nth 1 load-path))))
194 (skip-unless (and (file-exists-p dir1) (file-exists-p dir2)))
195 (with-temp-buffer
196 (insert (format "%s%s%s" dir1 path-separator dir2))
197 (goto-char (point-min))
198 ;; Use 'file-equal-p' because PATH could have backslashes, "~",
199 ;; and other constructs that will make 'equal' fail.
200 (should (file-equal-p (ffap-file-at-point) dir1)))
201 (with-temp-buffer
202 (insert (format "%s%s%s" dir1 path-separator dir2))
203 (goto-char (point-min))
204 (search-forward path-separator)
205 (should (file-equal-p (ffap-file-at-point) dir2)))
206 (with-temp-buffer
207 (insert "%s%s" path-separator dir2)
208 (goto-char (point-min))
209 (should (equal (ffap-file-at-point) nil)))))
210
185(ert-deftest ffap-tests--c-path () 211(ert-deftest ffap-tests--c-path ()
186 (should (seq-every-p #'stringp (ffap--c-path))) 212 (should (seq-every-p #'stringp (ffap--c-path)))
187 (should (locate-file "stdio.h" (ffap--c-path))) 213 (should (locate-file "stdio.h" (ffap--c-path)))