emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 0ecf2549a24 1/2: Make uniquify-tests work with out-of-tree builds


From: Mattias Engdegård
Subject: master 0ecf2549a24 1/2: Make uniquify-tests work with out-of-tree builds and clean up
Date: Fri, 28 Jul 2023 05:33:44 -0400 (EDT)

branch: master
commit 0ecf2549a2443a9211b59d33dab83e00a51e8bfd
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>

    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.
---
 test/lisp/uniquify-tests.el | 81 +++++++++++++++++++++++----------------------
 1 file 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 @@
 ;;; 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]