diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2017-08-12 20:04:43 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2017-08-12 20:05:23 -0700 |
commit | ebf53ed4f6469d24c3a76835eab014d82aed551c (patch) | |
tree | 6a5f10abdc9c59f02910cde7e5f4e479d4835d1d /test/lisp/files-tests.el | |
parent | a6ad98ad66e1d0c0dac5f25ba91e11d0cf9da725 (diff) | |
download | emacs-ebf53ed4f6469d24c3a76835eab014d82aed551c.tar.gz |
Fix make-temp-file bug with ""/"."/".." prefix
The bug with "." and ".." has been present for a while; I
introduced the bug with "" earlier today in my patch for Bug#28023.
* lisp/files.el (make-temp-file): Do not use expand-file-name if
PREFIX is empty or "." or "..", as it does the wrong thing.
Compute absolute-prefix here ...
(files--make-magic-temp-file): ... instead of here ...
* src/fileio.c (Fmake_temp_file_internal): ... or here.
* lisp/files.el (make-temp-file): If the prefix is empty, append
"/" to the absolute prefix so that the new files are children
rather than siblings of temporary-file-directory. This fixes a
bug introduced in the previous change.
* test/lisp/files-tests.el (files-test-make-temp-file-empty-prefix):
New test, for the bug.
Diffstat (limited to 'test/lisp/files-tests.el')
-rw-r--r-- | test/lisp/files-tests.el | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el index 7bfdca53e08..4a17e0d4697 100644 --- a/test/lisp/files-tests.el +++ b/test/lisp/files-tests.el @@ -166,6 +166,20 @@ form.") (should (eq buffer-file-coding-system 'iso-2022-7bit-unix)))) (delete-file tempfile)))) +(ert-deftest files-test-make-temp-file-empty-prefix () + "Test make-temp-file with an empty prefix." + (let ((tempfile (make-temp-file "")) + (tempdir (make-temp-file "" t)) + (tempfile-. (make-temp-file ".")) + (tempdir-. (make-temp-file "." t)) + (tempfile-.. (make-temp-file "..")) + (tempdir-.. (make-temp-file ".." t))) + (dolist (file (list tempfile tempfile-. tempfile-..)) + (should file) + (delete-file file)) + (dolist (dir (list tempdir tempdir-. tempdir-..)) + (should dir) + (delete-directory dir)))) ;; Stop the above "Local Var..." confusing Emacs. |