summaryrefslogtreecommitdiff
path: root/test/lisp/files-tests.el
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2017-09-10 20:37:17 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2017-09-10 20:38:19 -0700
commitcf9891e14e48a93bca2065fdd7998f5f677786dc (patch)
treea4d310f7868b010342634c45f36964af33c91af7 /test/lisp/files-tests.el
parent01c885f21f343045783eb9ad1ff5f9b83d6cd789 (diff)
downloademacs-cf9891e14e48a93bca2065fdd7998f5f677786dc.tar.gz
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/files-tests.el')
-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."
(cdr path-res)
(insert-directory-wildcard-in-dir-p (car path-res)))))))
+(ert-deftest files-tests--make-directory ()
+ (let* ((dir (make-temp-file "files-mkdir-test" t))
+ (dirname (file-name-as-directory dir))
+ (file (concat dirname "file"))
+ (subdir1 (concat dirname "subdir1"))
+ (subdir2 (concat dirname "subdir2"))
+ (a/b (concat dirname "a/b")))
+ (write-region "" nil file)
+ (should-error (make-directory "/"))
+ (should-not (make-directory "/" t))
+ (should-error (make-directory dir))
+ (should-not (make-directory dir t))
+ (should-error (make-directory dirname))
+ (should-not (make-directory dirname t))
+ (should-error (make-directory file))
+ (should-error (make-directory file t))
+ (should-not (make-directory subdir1))
+ (should-not (make-directory subdir2 t))
+ (should-error (make-directory a/b))
+ (should-not (make-directory a/b t))))
+
(provide 'files-tests)
;;; files-tests.el ends here