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.
This commit is contained in:
Stefan Kangas 2021-11-07 00:41:14 +01:00
parent 385741fae2
commit 0cac4598a7
2 changed files with 5 additions and 2 deletions

View 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

View 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 ()