emacs-diffs
[Top][All Lists]
Advanced

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

master 0cac459 3/3: Ensure return value of ert-with-temp-directory


From: Stefan Kangas
Subject: master 0cac459 3/3: Ensure return value of ert-with-temp-directory
Date: Sat, 6 Nov 2021 21:20:31 -0400 (EDT)

branch: master
commit 0cac4598a77028a64dde9df74c76549cf48a19f2
Author: Stefan Kangas <stefan@marxist.se>
Commit: Stefan Kangas <stefan@marxist.se>

    Ensure return value of ert-with-temp-directory
    
    * 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            | 4 +++-
 test/lisp/emacs-lisp/ert-x-tests.el | 3 ++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/lisp/emacs-lisp/ert-x.el b/lisp/emacs-lisp/ert-x.el
index 752ac3b..ffeead4 100644
--- a/lisp/emacs-lisp/ert-x.el
+++ b/lisp/emacs-lisp/ert-x.el
@@ -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
diff --git a/test/lisp/emacs-lisp/ert-x-tests.el 
b/test/lisp/emacs-lisp/ert-x-tests.el
index d7c0985..9baa994 100644
--- a/test/lisp/emacs-lisp/ert-x-tests.el
+++ b/test/lisp/emacs-lisp/ert-x-tests.el
@@ -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 ()



reply via email to

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