diff options
| author | Paul Eggert | 2017-08-12 20:04:43 -0700 |
|---|---|---|
| committer | Paul Eggert | 2017-08-12 20:05:23 -0700 |
| commit | ebf53ed4f6469d24c3a76835eab014d82aed551c (patch) | |
| tree | 6a5f10abdc9c59f02910cde7e5f4e479d4835d1d /test/lisp | |
| parent | a6ad98ad66e1d0c0dac5f25ba91e11d0cf9da725 (diff) | |
| download | emacs-ebf53ed4f6469d24c3a76835eab014d82aed551c.tar.gz emacs-ebf53ed4f6469d24c3a76835eab014d82aed551c.zip | |
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')
| -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.") | |||
| 166 | (should (eq buffer-file-coding-system 'iso-2022-7bit-unix)))) | 166 | (should (eq buffer-file-coding-system 'iso-2022-7bit-unix)))) |
| 167 | (delete-file tempfile)))) | 167 | (delete-file tempfile)))) |
| 168 | 168 | ||
| 169 | (ert-deftest files-test-make-temp-file-empty-prefix () | ||
| 170 | "Test make-temp-file with an empty prefix." | ||
| 171 | (let ((tempfile (make-temp-file "")) | ||
| 172 | (tempdir (make-temp-file "" t)) | ||
| 173 | (tempfile-. (make-temp-file ".")) | ||
| 174 | (tempdir-. (make-temp-file "." t)) | ||
| 175 | (tempfile-.. (make-temp-file "..")) | ||
| 176 | (tempdir-.. (make-temp-file ".." t))) | ||
| 177 | (dolist (file (list tempfile tempfile-. tempfile-..)) | ||
| 178 | (should file) | ||
| 179 | (delete-file file)) | ||
| 180 | (dolist (dir (list tempdir tempdir-. tempdir-..)) | ||
| 181 | (should dir) | ||
| 182 | (delete-directory dir)))) | ||
| 169 | 183 | ||
| 170 | ;; Stop the above "Local Var..." confusing Emacs. | 184 | ;; Stop the above "Local Var..." confusing Emacs. |
| 171 | 185 | ||