From: Mattias EngdegÄrd Date: Fri, 28 Jul 2023 09:12:09 +0000 (+0200) Subject: Make uniquify-tests work with out-of-tree builds and clean up X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=0ecf2549a2443a9211b59d33dab83e00a51e8bfd;p=emacs.git 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. --- 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 @@ ;;; Code: (require 'ert) +(require 'ert-x) (ert-deftest uniquify-basic () (let (bufs old-names) @@ -58,35 +59,35 @@ (ert-deftest uniquify-dirs () "Check strip-common-suffix and trailing-separator-p work together; bug#47132" - (let* ((root (make-temp-file "emacs-uniquify-tests" 'dir)) - (a-path (file-name-concat root "a/x/y/dir")) - (b-path (file-name-concat root "b/x/y/dir"))) - (make-directory a-path 'parents) - (make-directory b-path 'parents) - (let ((uniquify-buffer-name-style 'forward) - (uniquify-strip-common-suffix t) - (uniquify-trailing-separator-p nil)) - (let ((bufs (list (find-file-noselect a-path) - (find-file-noselect b-path)))) - (should (equal (mapcar #'buffer-name bufs) - '("a/dir" "b/dir"))) - (mapc #'kill-buffer bufs))) - (let ((uniquify-buffer-name-style 'forward) - (uniquify-strip-common-suffix nil) - (uniquify-trailing-separator-p t)) - (let ((bufs (list (find-file-noselect a-path) - (find-file-noselect b-path)))) - (should (equal (mapcar #'buffer-name bufs) - '("a/x/y/dir/" "b/x/y/dir/"))) - (mapc #'kill-buffer bufs))) - (let ((uniquify-buffer-name-style 'forward) - (uniquify-strip-common-suffix t) - (uniquify-trailing-separator-p t)) - (let ((bufs (list (find-file-noselect a-path) - (find-file-noselect b-path)))) - (should (equal (mapcar #'buffer-name bufs) - '("a/dir/" "b/dir/"))) - (mapc #'kill-buffer bufs))))) + (ert-with-temp-directory root + (let ((a-path (file-name-concat root "a/x/y/dir")) + (b-path (file-name-concat root "b/x/y/dir"))) + (make-directory a-path 'parents) + (make-directory b-path 'parents) + (let ((uniquify-buffer-name-style 'forward) + (uniquify-strip-common-suffix t) + (uniquify-trailing-separator-p nil)) + (let ((bufs (list (find-file-noselect a-path) + (find-file-noselect b-path)))) + (should (equal (mapcar #'buffer-name bufs) + '("a/dir" "b/dir"))) + (mapc #'kill-buffer bufs))) + (let ((uniquify-buffer-name-style 'forward) + (uniquify-strip-common-suffix nil) + (uniquify-trailing-separator-p t)) + (let ((bufs (list (find-file-noselect a-path) + (find-file-noselect b-path)))) + (should (equal (mapcar #'buffer-name bufs) + '("a/x/y/dir/" "b/x/y/dir/"))) + (mapc #'kill-buffer bufs))) + (let ((uniquify-buffer-name-style 'forward) + (uniquify-strip-common-suffix t) + (uniquify-trailing-separator-p t)) + (let ((bufs (list (find-file-noselect a-path) + (find-file-noselect b-path)))) + (should (equal (mapcar #'buffer-name bufs) + '("a/dir/" "b/dir/"))) + (mapc #'kill-buffer bufs)))))) (ert-deftest uniquify-home () "uniquify works, albeit confusingly, in the presence of directories named \"~\"" @@ -147,16 +148,18 @@ uniquify-trailing-separator-p is ignored" (project-vc-name "foo1/bar") bufs) (save-excursion - (should (file-exists-p "../README")) - (push (find-file-noselect "../README") bufs) - (push (find-file-noselect "other/README") bufs) - (should (equal (mapcar #'buffer-name bufs) - '("README" "README"))) - (push (find-file-noselect "foo2/bar/README") bufs) - (should (equal (mapcar #'buffer-name bufs) - '("README" "README" "README"))) - (while bufs - (kill-buffer (pop bufs)))))) + (let ((default-directory (expand-file-name "test/" source-directory))) + (should (file-exists-p "../README")) + (push (find-file-noselect "../README") bufs) + (push (find-file-noselect "other/README") bufs) + (should (equal (mapcar #'buffer-name bufs) + '("README" "README"))) + (push (find-file-noselect "foo2/bar/README") bufs) + (should (equal (mapcar #'buffer-name bufs) + '("README" "README" + "README"))) + (while bufs + (kill-buffer (pop bufs))))))) (provide 'uniquify-tests) ;;; uniquify-tests.el ends here