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.
This commit is contained in:
parent
5efc7b22ce
commit
0ecf2549a2
1 changed files with 42 additions and 39 deletions
|
@ -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<other>" "README<bar>")))
|
||||
(push (find-file-noselect "foo2/bar/README") bufs)
|
||||
(should (equal (mapcar #'buffer-name bufs)
|
||||
'("README<foo2/bar>" "README<other>" "README<foo1/bar>")))
|
||||
(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<other>" "README<bar>")))
|
||||
(push (find-file-noselect "foo2/bar/README") bufs)
|
||||
(should (equal (mapcar #'buffer-name bufs)
|
||||
'("README<foo2/bar>" "README<other>"
|
||||
"README<foo1/bar>")))
|
||||
(while bufs
|
||||
(kill-buffer (pop bufs)))))))
|
||||
|
||||
(provide 'uniquify-tests)
|
||||
;;; uniquify-tests.el ends here
|
||||
|
|
Loading…
Add table
Reference in a new issue