]> git.eshelyaron.com Git - emacs.git/commitdiff
Ensure return value of ert-with-temp-directory
authorStefan Kangas <stefan@marxist.se>
Sat, 6 Nov 2021 23:41:14 +0000 (00:41 +0100)
committerStefan Kangas <stefan@marxist.se>
Sun, 7 Nov 2021 00:54:31 +0000 (01:54 +0100)
* lisp/emacs-lisp/ert-x.el (ert-with-temp-file): Ensure return
value when :directory is t is the directory name.
* test/lisp/emacs-lisp/ert-x-tests.el
(ert-x-tests-with-temp-directory): Extend test for the above.

lisp/emacs-lisp/ert-x.el
test/lisp/emacs-lisp/ert-x-tests.el

index 752ac3bfdd48067edd8a04627a723c62c8dda10a..ffeead4179d9d0ba740b8f941ae2defa0edd52e6 100644 (file)
@@ -445,7 +445,9 @@ See also `ert-with-temp-directory'."
                        (or (macroexp-file-name) buffer-file-name)))))
       `(let* ((,temp-file (,(if directory 'file-name-as-directory 'identity)
                            (make-temp-file ,prefix ,directory ,suffix ,text)))
-              (,name ,temp-file))
+              (,name ,(if directory
+                          `(file-name-as-directory ,temp-file)
+                        temp-file)))
          (unwind-protect
              (progn ,@body)
            (ignore-errors
index d7c0985b13e24dfe5dfde47151eb5094a51a1628..9baa9941586574ec0dd350a94d086f45e03a6187 100644 (file)
@@ -320,7 +320,8 @@ desired effect."
     (ert-with-temp-directory dir
       (setq saved dir)
       (should (file-exists-p dir))
-      (should (file-directory-p dir)))
+      (should (file-directory-p dir))
+      (should (equal dir (file-name-as-directory dir))))
     (should-not (file-exists-p saved))))
 
 (ert-deftest ert-x-tests-with-temp-directory/text-signals-error ()