aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias EngdegÄrd2023-07-28 11:12:09 +0200
committerMattias EngdegÄrd2023-07-28 11:31:58 +0200
commit0ecf2549a2443a9211b59d33dab83e00a51e8bfd (patch)
tree7c3b351344499fe540068295e66bcb5b95b21430
parent5efc7b22cecc0cf1e7dd2bbbc26400dba35e33ea (diff)
downloademacs-0ecf2549a2443a9211b59d33dab83e00a51e8bfd.tar.gz
emacs-0ecf2549a2443a9211b59d33dab83e00a51e8bfd.zip
Make uniquify-tests work with out-of-tree builds and clean up
* test/lisp/uniquify-tests.el (uniquify-project-transform): Set an explicit default-directory. * test/lisp/uniquify-tests.el (uniquify-dirs): Remove temporary directory after test.
-rw-r--r--test/lisp/uniquify-tests.el81
1 files changed, 42 insertions, 39 deletions
diff --git a/test/lisp/uniquify-tests.el b/test/lisp/uniquify-tests.el
index e533c4b644c..224991cb048 100644
--- a/test/lisp/uniquify-tests.el
+++ b/test/lisp/uniquify-tests.el
@@ -22,6 +22,7 @@
22;;; Code: 22;;; Code:
23 23
24(require 'ert) 24(require 'ert)
25(require 'ert-x)
25 26
26(ert-deftest uniquify-basic () 27(ert-deftest uniquify-basic ()
27 (let (bufs old-names) 28 (let (bufs old-names)
@@ -58,35 +59,35 @@
58 59
59(ert-deftest uniquify-dirs () 60(ert-deftest uniquify-dirs ()
60 "Check strip-common-suffix and trailing-separator-p work together; bug#47132" 61 "Check strip-common-suffix and trailing-separator-p work together; bug#47132"
61 (let* ((root (make-temp-file "emacs-uniquify-tests" 'dir)) 62 (ert-with-temp-directory root
62 (a-path (file-name-concat root "a/x/y/dir")) 63 (let ((a-path (file-name-concat root "a/x/y/dir"))
63 (b-path (file-name-concat root "b/x/y/dir"))) 64 (b-path (file-name-concat root "b/x/y/dir")))
64 (make-directory a-path 'parents) 65 (make-directory a-path 'parents)
65 (make-directory b-path 'parents) 66 (make-directory b-path 'parents)
66 (let ((uniquify-buffer-name-style 'forward) 67 (let ((uniquify-buffer-name-style 'forward)
67 (uniquify-strip-common-suffix t) 68 (uniquify-strip-common-suffix t)
68 (uniquify-trailing-separator-p nil)) 69 (uniquify-trailing-separator-p nil))
69 (let ((bufs (list (find-file-noselect a-path) 70 (let ((bufs (list (find-file-noselect a-path)
70 (find-file-noselect b-path)))) 71 (find-file-noselect b-path))))
71 (should (equal (mapcar #'buffer-name bufs) 72 (should (equal (mapcar #'buffer-name bufs)
72 '("a/dir" "b/dir"))) 73 '("a/dir" "b/dir")))
73 (mapc #'kill-buffer bufs))) 74 (mapc #'kill-buffer bufs)))
74 (let ((uniquify-buffer-name-style 'forward) 75 (let ((uniquify-buffer-name-style 'forward)
75 (uniquify-strip-common-suffix nil) 76 (uniquify-strip-common-suffix nil)
76 (uniquify-trailing-separator-p t)) 77 (uniquify-trailing-separator-p t))
77 (let ((bufs (list (find-file-noselect a-path) 78 (let ((bufs (list (find-file-noselect a-path)
78 (find-file-noselect b-path)))) 79 (find-file-noselect b-path))))
79 (should (equal (mapcar #'buffer-name bufs) 80 (should (equal (mapcar #'buffer-name bufs)
80 '("a/x/y/dir/" "b/x/y/dir/"))) 81 '("a/x/y/dir/" "b/x/y/dir/")))
81 (mapc #'kill-buffer bufs))) 82 (mapc #'kill-buffer bufs)))
82 (let ((uniquify-buffer-name-style 'forward) 83 (let ((uniquify-buffer-name-style 'forward)
83 (uniquify-strip-common-suffix t) 84 (uniquify-strip-common-suffix t)
84 (uniquify-trailing-separator-p t)) 85 (uniquify-trailing-separator-p t))
85 (let ((bufs (list (find-file-noselect a-path) 86 (let ((bufs (list (find-file-noselect a-path)
86 (find-file-noselect b-path)))) 87 (find-file-noselect b-path))))
87 (should (equal (mapcar #'buffer-name bufs) 88 (should (equal (mapcar #'buffer-name bufs)
88 '("a/dir/" "b/dir/"))) 89 '("a/dir/" "b/dir/")))
89 (mapc #'kill-buffer bufs))))) 90 (mapc #'kill-buffer bufs))))))
90 91
91(ert-deftest uniquify-home () 92(ert-deftest uniquify-home ()
92 "uniquify works, albeit confusingly, in the presence of directories named \"~\"" 93 "uniquify works, albeit confusingly, in the presence of directories named \"~\""
@@ -147,16 +148,18 @@ uniquify-trailing-separator-p is ignored"
147 (project-vc-name "foo1/bar") 148 (project-vc-name "foo1/bar")
148 bufs) 149 bufs)
149 (save-excursion 150 (save-excursion
150 (should (file-exists-p "../README")) 151 (let ((default-directory (expand-file-name "test/" source-directory)))
151 (push (find-file-noselect "../README") bufs) 152 (should (file-exists-p "../README"))
152 (push (find-file-noselect "other/README") bufs) 153 (push (find-file-noselect "../README") bufs)
153 (should (equal (mapcar #'buffer-name bufs) 154 (push (find-file-noselect "other/README") bufs)
154 '("README<other>" "README<bar>"))) 155 (should (equal (mapcar #'buffer-name bufs)
155 (push (find-file-noselect "foo2/bar/README") bufs) 156 '("README<other>" "README<bar>")))
156 (should (equal (mapcar #'buffer-name bufs) 157 (push (find-file-noselect "foo2/bar/README") bufs)
157 '("README<foo2/bar>" "README<other>" "README<foo1/bar>"))) 158 (should (equal (mapcar #'buffer-name bufs)
158 (while bufs 159 '("README<foo2/bar>" "README<other>"
159 (kill-buffer (pop bufs)))))) 160 "README<foo1/bar>")))
161 (while bufs
162 (kill-buffer (pop bufs)))))))
160 163
161(provide 'uniquify-tests) 164(provide 'uniquify-tests)
162;;; uniquify-tests.el ends here 165;;; uniquify-tests.el ends here