;;; Code:
(require 'ert)
+(require 'ert-x)
(ert-deftest uniquify-basic ()
(let (bufs old-names)
(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 \"~\""
(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