aboutsummaryrefslogtreecommitdiffstats
path: root/test/lisp
diff options
context:
space:
mode:
authorPaul Eggert2017-09-10 20:37:17 -0700
committerPaul Eggert2017-09-10 20:38:19 -0700
commitcf9891e14e48a93bca2065fdd7998f5f677786dc (patch)
treea4d310f7868b010342634c45f36964af33c91af7 /test/lisp
parent01c885f21f343045783eb9ad1ff5f9b83d6cd789 (diff)
downloademacs-cf9891e14e48a93bca2065fdd7998f5f677786dc.tar.gz
emacs-cf9891e14e48a93bca2065fdd7998f5f677786dc.zip
Fix some make-directory bugs
* lisp/files.el (files--ensure-directory): New function. (make-directory): Use it to avoid bugs when (make-directory FOO t) is invoked on a non-directory, or on a directory hierarchy that is being built by some other process while Emacs is running. * test/lisp/files-tests.el (files-tests--make-directory): New test.
Diffstat (limited to 'test/lisp')
-rw-r--r--test/lisp/files-tests.el21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el
index a2f2b74312f..b52965a02b4 100644
--- a/test/lisp/files-tests.el
+++ b/test/lisp/files-tests.el
@@ -344,6 +344,27 @@ be invoked with the right arguments."
344 (cdr path-res) 344 (cdr path-res)
345 (insert-directory-wildcard-in-dir-p (car path-res))))))) 345 (insert-directory-wildcard-in-dir-p (car path-res)))))))
346 346
347(ert-deftest files-tests--make-directory ()
348 (let* ((dir (make-temp-file "files-mkdir-test" t))
349 (dirname (file-name-as-directory dir))
350 (file (concat dirname "file"))
351 (subdir1 (concat dirname "subdir1"))
352 (subdir2 (concat dirname "subdir2"))
353 (a/b (concat dirname "a/b")))
354 (write-region "" nil file)
355 (should-error (make-directory "/"))
356 (should-not (make-directory "/" t))
357 (should-error (make-directory dir))
358 (should-not (make-directory dir t))
359 (should-error (make-directory dirname))
360 (should-not (make-directory dirname t))
361 (should-error (make-directory file))
362 (should-error (make-directory file t))
363 (should-not (make-directory subdir1))
364 (should-not (make-directory subdir2 t))
365 (should-error (make-directory a/b))
366 (should-not (make-directory a/b t))))
367
347 368
348(provide 'files-tests) 369(provide 'files-tests)
349;;; files-tests.el ends here 370;;; files-tests.el ends here