emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] scratch/nonspecial-handlers 8ac0c29 2/2: Make individual t


From: Noam Postavsky
Subject: [Emacs-diffs] scratch/nonspecial-handlers 8ac0c29 2/2: Make individual tests per-file handler
Date: Sun, 28 Jan 2018 09:50:16 -0500 (EST)

branch: scratch/nonspecial-handlers
commit 8ac0c297db9ca16743c2b46e32d2288a6f38793e
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>

    Make individual tests per-file handler
    
    * test/lisp/files-tests.el
    (files-tests-file-name-non-special-access-file)
    (files-tests-file-name-non-special-add-name-to-file)
    (files-tests-file-name-non-special-byte-compiler-base-file-name)
    (files-tests-file-name-non-special-copy-directory)
    (files-tests-file-name-non-special-copy-file)
    (files-tests-file-name-non-special-delete-directory)
    (files-tests-file-name-non-special-delete-file)
    (files-tests-file-name-non-special-diff-latest-backup-file)
    (files-tests-file-name-non-special-directory-file-name)
    (files-tests-file-name-non-special-directory-files)
    (files-tests-file-name-non-special-directory-files-and-attributes)
    (files-tests-file-name-non-special-dired-uncache)
    (files-tests-file-name-non-special-dired-compress-handler)
    (files-tests-file-name-non-special-expand-file-name)
    (files-tests-file-name-non-special-file-accessible-directory-p)
    (files-tests-file-name-non-special-file-acl)
    (files-tests-file-name-non-special-file-attributes)
    (files-tests-file-name-non-special-file-directory-p)
    (files-tests-file-name-non-special-file-equal-p)
    (files-tests-file-name-non-special-file-executable-p)
    (files-tests-file-name-non-special-file-exists-p)
    (files-tests-file-name-non-special-file-in-directory-p)
    (files-tests-file-name-non-special-file-local-copy)
    (files-tests-file-name-non-special-file-modes)
    (files-tests-file-name-non-special-file-name-all-completions)
    (files-tests-file-name-non-special-file-name-as-directory)
    (files-tests-file-name-non-special-file-name-case-insensitive-p)
    (files-tests-file-name-non-special-file-name-completion)
    (files-tests-file-name-non-special-file-name-directory)
    (files-tests-file-name-non-special-file-name-nondirectory)
    (files-tests-file-name-non-special-file-name-sans-versions)
    (files-tests-file-name-non-special-file-newer-than-file-p)
    (files-tests-file-name-non-special-file-ownership-preserved-p)
    (files-tests-file-name-non-special-file-readable-p)
    (files-tests-file-name-non-special-file-regular-p)
    (files-tests-file-name-non-special-file-remote-p)
    (files-tests-file-name-non-special-file-selinux-context)
    (files-tests-file-name-non-special-file-symlink-p)
    (files-tests-file-name-non-special-file-truename)
    (files-tests-file-name-non-special-file-writable-p)
    (files-tests-file-name-non-special-find-backup-file-name)
    (files-tests-file-name-non-special-get-file-buffer)
    (files-tests-file-name-non-special-insert-directory)
    (files-tests-file-name-non-special-insert-file-contents)
    (files-tests-file-name-non-special-load)
    (files-tests-file-name-non-special-make-auto-save-file-name)
    (files-tests-file-name-non-special-make-directory)
    (files-tests-file-name-non-special-make-directory-internal)
    (files-tests-file-name-non-special-make-nearby-temp-file)
    (files-tests-file-name-non-special-make-symbolic-link)
    (files-tests-file-name-non-special-rename-file)
    (files-tests-file-name-non-special-set-file-acl)
    (files-tests-file-name-non-special-set-file-modes)
    (files-tests-file-name-non-special-set-file-selinux-context)
    (files-tests-file-name-non-special-set-file-times)
    (files-tests-file-name-non-special-set-visited-file-modtime)
    (files-tests-file-name-non-special-shell-command)
    (files-tests-file-name-non-special-start-file-process)
    (files-tests-file-name-non-special-substitute-in-file-name)
    (files-tests-file-name-non-special-temporary-file-directory)
    (files-tests-file-name-non-special-unhandled-file-name-directory)
    (files-tests-file-name-non-special-vc-registered)
    (files-tests-file-name-non-special-write-region): New tests.
---
 test/lisp/files-tests.el | 566 +++++++++++++++++++++++++++++++----------------
 1 file changed, 381 insertions(+), 185 deletions(-)

diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el
index 56bef24..86ecb29 100644
--- a/test/lisp/files-tests.el
+++ b/test/lisp/files-tests.el
@@ -21,6 +21,7 @@
 
 (require 'ert)
 (require 'nadvice)
+(eval-when-compile (require 'cl-lib))
 (require 'bytecomp) ; `byte-compiler-base-file-name'.
 (require 'dired) ; `dired-uncache'.
 (require 'filenotify) ; `file-notify-add-watch'.
@@ -289,14 +290,6 @@ be $HOME."
          (progn ,@body)
        (delete-file ,name))))
 
-(defmacro files-tests--with-temp-dir (name &rest body)
-  (declare (indent 1) (debug (symbolp body)))
-  (cl-check-type name symbol)
-  `(let ((,name (make-temp-file "emacs" t)))
-     (unwind-protect
-         (progn ,@body)
-       (delete-directory ,name t))))
-
 (ert-deftest files-tests--file-name-non-special--buffers ()
   "Check that Bug#25951 is fixed.
 We call `verify-visited-file-modtime' on a buffer visiting a file
@@ -338,15 +331,82 @@ be invoked with the right arguments."
                       `((verify-visited-file-modtime ,buffer-visiting-file)
                         (verify-visited-file-modtime nil))))))))
 
-(ert-deftest files-file-name-non-special-notify-handlers ()
-  (files-tests--with-temp-file tmpfile
-    (let* ((nospecial (concat "/:" tmpfile))
-           (watch (file-notify-add-watch nospecial '(change) #'ignore)))
-      (should (file-notify-valid-p watch))
-      (file-notify-rm-watch watch)
-      (should-not (file-notify-valid-p watch)))))
+(cl-defmacro files-tests--with-temp-non-special
+    ((name non-special-name &optional dir-flag) &rest body)
+  (declare (indent 1) (debug ((symbolp symbolp &optional form) body)))
+  (cl-check-type name symbol)
+  (cl-check-type non-special-name symbol)
+  `(let* ((,name (make-temp-file "files-tests" ,dir-flag))
+          (,non-special-name (concat "/:" ,name)))
+     (unwind-protect
+         (progn ,@body)
+       (when (file-exists-p ,name)
+         (if ,dir-flag (delete-directory ,name t)
+           (delete-file ,name))))))
+
+(ert-deftest files-tests-file-name-non-special-access-file ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (should (null (access-file nospecial "test")))))
 
-(ert-deftest files-file-name-non-special-dired-compress-handler ()
+(ert-deftest files-tests-file-name-non-special-add-name-to-file ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (let ((newname (concat nospecial "add-name")))
+      (add-name-to-file nospecial newname)
+      (should (file-exists-p newname))
+      (delete-file newname))))
+
+(ert-deftest files-tests-file-name-non-special-byte-compiler-base-file-name ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (should (equal (byte-compiler-base-file-name nospecial)
+                   (byte-compiler-base-file-name tmpfile)))))
+
+(ert-deftest files-tests-file-name-non-special-copy-directory ()
+  (files-tests--with-temp-non-special (tmpdir nospecial-dir t)
+    (let ((newname (concat (directory-file-name nospecial-dir)
+                           "copy-dir")))
+      (copy-directory nospecial-dir newname)
+      (should (file-directory-p newname))
+      (delete-directory newname)
+      (should-not (file-directory-p newname)))))
+
+(ert-deftest files-tests-file-name-non-special-copy-file ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (let ((newname (concat (directory-file-name nospecial)
+                           "copy-file")))
+      (copy-file nospecial newname)
+      (should (file-exists-p newname))
+      (delete-file newname)
+      (should-not (file-exists-p newname)))))
+
+(ert-deftest files-tests-file-name-non-special-delete-directory ()
+  (files-tests--with-temp-non-special (tmpdir nospecial-dir t)
+    (delete-directory nospecial-dir)))
+
+(ert-deftest files-tests-file-name-non-special-delete-file ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (delete-file nospecial)))
+
+(ert-deftest files-tests-file-name-non-special-diff-latest-backup-file ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (should (equal (diff-latest-backup-file nospecial)
+                   (diff-latest-backup-file tmpfile)))))
+
+(ert-deftest files-tests-file-name-non-special-directory-file-name ()
+  (files-tests--with-temp-non-special (tmpdir nospecial-dir t)
+    (should (equal (directory-file-name nospecial-dir)
+                   (concat "/:" (directory-file-name tmpdir))))))
+
+(ert-deftest files-tests-file-name-non-special-directory-files ()
+  (files-tests--with-temp-non-special (tmpdir nospecial-dir t)
+    (should (equal (directory-files nospecial-dir)
+                   (directory-files tmpdir)))))
+
+(ert-deftest files-tests-file-name-non-special-directory-files-and-attributes 
()
+  (files-tests--with-temp-non-special (tmpdir nospecial-dir t)
+    (should (equal (directory-files-and-attributes nospecial-dir)
+                   (directory-files-and-attributes tmpdir)))))
+
+(ert-deftest files-tests-file-name-non-special-dired-compress-handler ()
   ;; `dired-compress-file' can get confused by filenames with ":" in
   ;; them, which causes this to fail on `windows-nt' systems.
   (when (string-match-p ":" (expand-file-name temporary-file-directory))
@@ -357,176 +417,312 @@ be invoked with the right arguments."
         ;; FIXME: Should it return a still-quoted name?
         (should (file-equal-p nospecial (dired-compress-file compressed)))))))
 
-(ert-deftest files-file-name-non-special-handlers ()
-  (files-tests--with-temp-file tmpfile
-    (files-tests--with-temp-dir tmpdir
-      (let ((nospecial (concat "/:" tmpfile))
-            (nospecial-dir (concat "/:" tmpdir)))
-        (should (null (access-file nospecial "test")))
-        (let ((newname (concat nospecial "add-name")))
-          (add-name-to-file nospecial newname)
-          (should (file-exists-p newname))
-          (delete-file newname))
-        (should (equal (byte-compiler-base-file-name nospecial)
-                       (byte-compiler-base-file-name tmpfile)))
-        (let ((newname (concat (directory-file-name nospecial-dir)
-                               "copy-dir")))
-          (copy-directory nospecial-dir newname)
-          (should (file-directory-p newname))
-          (delete-directory newname)
-          (should-not (file-directory-p newname)))
-        (let ((newname (concat (directory-file-name nospecial)
-                               "copy-file")))
-          (copy-file nospecial newname)
-          (should (file-exists-p newname))
-          (delete-file newname)
-          (should-not (file-exists-p newname)))
-        (should (equal (diff-latest-backup-file nospecial)
-                       (diff-latest-backup-file tmpfile)))
-        (should (equal (directory-file-name nospecial-dir)
-                       (concat "/:" (directory-file-name tmpdir))))
-        (should (equal (directory-files nospecial-dir)
-                       (directory-files tmpdir)))
-        (should (equal (directory-files-and-attributes nospecial-dir)
-                       (directory-files-and-attributes tmpdir)))
-        (dired-uncache nospecial-dir)
-        (should (equal (expand-file-name nospecial)
-                       nospecial))
-        (should (file-accessible-directory-p nospecial-dir))
-        (should (equal (file-acl nospecial)
-                       (file-acl tmpfile)))
-        (should (equal (file-attributes nospecial)
-                       (file-attributes tmpfile)))
-        (should (equal (file-directory-p nospecial-dir)
-                       (file-directory-p tmpdir)))
-        (should (file-equal-p nospecial tmpfile))
-        (should (file-equal-p tmpfile nospecial))
-        (should (file-equal-p nospecial nospecial))
-        (should-not (file-executable-p nospecial))
-        (should (file-exists-p nospecial))
-        (should (file-in-directory-p nospecial temporary-file-directory))
-        (should-not (file-in-directory-p nospecial nospecial-dir))
-        (should-not (file-in-directory-p tmpfile nospecial-dir))
-        (should-not (file-in-directory-p nospecial nospecial-dir))
-        (should-not (file-local-copy nospecial)) ; Already local.
-        (should (equal (file-modes nospecial)
-                       (file-modes tmpfile)))
-        (should (equal (file-name-all-completions nospecial nospecial-dir)
-                       (file-name-all-completions tmpfile tmpdir)))
-        (file-name-as-directory nospecial)
-        (should (equal (file-name-case-insensitive-p nospecial)
-                       (file-name-case-insensitive-p tmpfile)))
-        (should (equal (file-name-completion nospecial nospecial-dir)
-                       (file-name-completion tmpfile tmpdir)))
-        (should (equal (file-name-directory nospecial)
-                       (concat "/:" temporary-file-directory)))
-        (should (equal (file-name-nondirectory nospecial)
-                       (file-name-nondirectory tmpfile)))
-        (should (equal (file-name-sans-versions nospecial)
-                       nospecial))
-        (should-not (file-newer-than-file-p nospecial tmpfile))
-        (should-not (file-newer-than-file-p tmpfile nospecial))
-        (should-not (file-newer-than-file-p nospecial nospecial))
-        (should (equal (file-ownership-preserved-p nospecial)
-                       (file-ownership-preserved-p tmpfile)))
-        (should (file-readable-p nospecial))
-        (should (file-regular-p nospecial))
-        (should-not (file-remote-p nospecial))
-        (should (equal (file-selinux-context nospecial)
-                       (file-selinux-context tmpfile)))
-        (should-not (file-symlink-p nospecial))
-        (file-truename nospecial)
-        (should (file-writable-p nospecial))
-        (should (equal (find-backup-file-name nospecial)
-                       (mapcar (lambda (f) (concat "/:" f))
-                               (find-backup-file-name tmpfile))))
-        (should-not (get-file-buffer nospecial))
-        (should (equal (with-temp-buffer
-                         (insert-directory nospecial-dir "")
-                         (buffer-string))
-                       (with-temp-buffer
-                         (insert-directory tmpdir "")
-                         (buffer-string))))
-        (with-temp-buffer
-          (insert-file-contents nospecial)
-          (should (zerop (buffer-size))))
-        (should (load nospecial))
-        (save-current-buffer
-          (should (equal (prog2 (set-buffer (find-file-noselect nospecial))
-                             (make-auto-save-file-name)
-                           (kill-buffer))
-                         (prog2 (set-buffer (find-file-noselect tmpfile))
-                             (make-auto-save-file-name)
-                           (kill-buffer)))))
-        (let ((default-directory nospecial-dir))
-          (make-directory "dir")
-          (should (file-directory-p "dir"))
-          (delete-directory "dir")
-          (make-directory-internal "dir")
-          (should (file-directory-p "dir"))
-          (delete-directory "dir")
-          (let ((near-tmpfile (make-nearby-temp-file "file")))
-            (should (file-exists-p near-tmpfile))
-            (delete-file near-tmpfile)))
-        (let* ((linkname (expand-file-name "link" tmpdir))
-               (may-symlink (ignore-errors (make-symbolic-link tmpfile 
linkname)
-                                           t)))
-          (when may-symlink
+(ert-deftest files-tests-file-name-non-special-dired-uncache ()
+  (files-tests--with-temp-non-special (tmpdir nospecial-dir t)
+    (dired-uncache nospecial-dir)))
+
+(ert-deftest files-tests-file-name-non-special-expand-file-name ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (should (equal (expand-file-name nospecial) nospecial))))
+
+(ert-deftest files-tests-file-name-non-special-file-accessible-directory-p ()
+  (files-tests--with-temp-non-special (tmpdir nospecial-dir t)
+    (should (file-accessible-directory-p nospecial-dir))))
+
+(ert-deftest files-tests-file-name-non-special-file-acl ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (should (equal (file-acl nospecial) (file-acl tmpfile)))))
+
+(ert-deftest files-tests-file-name-non-special-file-attributes ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (should (equal (file-attributes nospecial) (file-attributes tmpfile)))))
+
+(ert-deftest files-tests-file-name-non-special-file-directory-p ()
+  (files-tests--with-temp-non-special (tmpdir nospecial-dir t)
+    (should (file-directory-p nospecial-dir))))
+
+(ert-deftest files-tests-file-name-non-special-file-equal-p ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (should (file-equal-p nospecial tmpfile))
+    (should (file-equal-p tmpfile nospecial))
+    (should (file-equal-p nospecial nospecial))))
+
+(ert-deftest files-tests-file-name-non-special-file-executable-p ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (should-not (file-executable-p nospecial))))
+
+(ert-deftest files-tests-file-name-non-special-file-exists-p ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (should (file-exists-p nospecial))))
+
+(ert-deftest files-tests-file-name-non-special-file-in-directory-p ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (let ((nospecial-tempdir (concat "/:" temporary-file-directory)))
+      (should (file-in-directory-p nospecial temporary-file-directory))
+      (should (file-in-directory-p tmpfile nospecial-tempdir))
+      (should (file-in-directory-p nospecial nospecial-tempdir)))))
+
+(ert-deftest files-tests-file-name-non-special-file-local-copy ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (should-not (file-local-copy nospecial)))) ; Already local.
+
+(ert-deftest files-tests-file-name-non-special-file-modes ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (should (equal (file-modes nospecial) (file-modes tmpfile)))))
+
+(ert-deftest files-tests-file-name-non-special-file-name-all-completions ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (let ((nospecial-tempdir (concat "/:" temporary-file-directory))
+          (tmpdir temporary-file-directory))
+      (should (equal (file-name-all-completions nospecial nospecial-tempdir)
+                     (file-name-all-completions tmpfile tmpdir)))
+      (should (equal (file-name-all-completions tmpfile nospecial-tempdir)
+                     (file-name-all-completions tmpfile tmpdir)))
+      (should (equal (file-name-all-completions nospecial tmpdir)
+                     (file-name-all-completions tmpfile tmpdir))))))
+
+(ert-deftest files-tests-file-name-non-special-file-name-as-directory ()
+  (files-tests--with-temp-non-special (tmpdir nospecial-dir t)
+    (should (equal (file-name-as-directory nospecial-dir)
+                   (concat "/:" (file-name-as-directory tmpdir))))))
+
+(ert-deftest files-tests-file-name-non-special-file-name-case-insensitive-p ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (should (equal (file-name-case-insensitive-p nospecial)
+                   (file-name-case-insensitive-p tmpfile)))))
+
+(ert-deftest files-tests-file-name-non-special-file-name-completion ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (let ((nospecial-tempdir (concat "/:" temporary-file-directory))
+          (tmpdir temporary-file-directory))
+      (should (equal (file-name-completion nospecial nospecial-tempdir)
+                     (file-name-completion tmpfile tmpdir)))
+      (should (equal (file-name-completion tmpfile nospecial-tempdir)
+                     (file-name-completion tmpfile tmpdir)))
+      (should (equal (file-name-completion nospecial tmpdir)
+                     (file-name-completion tmpfile tmpdir))))))
+
+(ert-deftest files-tests-file-name-non-special-file-name-directory ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (should (equal (file-name-directory nospecial)
+                   (concat "/:" temporary-file-directory)))))
+
+(ert-deftest files-tests-file-name-non-special-file-name-nondirectory ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (should (equal (file-name-nondirectory nospecial)
+                   (file-name-nondirectory tmpfile)))))
+
+(ert-deftest files-tests-file-name-non-special-file-name-sans-versions ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (should (equal (file-name-sans-versions nospecial) nospecial))))
+
+(ert-deftest files-tests-file-name-non-special-file-newer-than-file-p ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (should-not (file-newer-than-file-p nospecial tmpfile))
+    (should-not (file-newer-than-file-p tmpfile nospecial))
+    (should-not (file-newer-than-file-p nospecial nospecial))))
+
+(ert-deftest files-file-name-non-special-notify-handlers ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (let ((watch (file-notify-add-watch nospecial '(change) #'ignore)))
+      (should (file-notify-valid-p watch))
+      (file-notify-rm-watch watch)
+      (should-not (file-notify-valid-p watch)))))
+
+(ert-deftest files-tests-file-name-non-special-file-ownership-preserved-p ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (should (equal (file-ownership-preserved-p nospecial)
+                   (file-ownership-preserved-p tmpfile)))))
+
+(ert-deftest files-tests-file-name-non-special-file-readable-p ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (should (file-readable-p nospecial))))
+
+(ert-deftest files-tests-file-name-non-special-file-regular-p ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (should (file-regular-p nospecial))))
+
+(ert-deftest files-tests-file-name-non-special-file-remote-p ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (should-not (file-remote-p nospecial))))
+
+(ert-deftest files-tests-file-name-non-special-file-selinux-context ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (should (equal (file-selinux-context nospecial)
+                   (file-selinux-context tmpfile)))))
+
+(ert-deftest files-tests-file-name-non-special-file-symlink-p ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (should-not (file-symlink-p nospecial))))
+
+(ert-deftest files-tests-file-name-non-special-file-truename ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (should (equal nospecial (file-truename nospecial)))))
+
+(ert-deftest files-tests-file-name-non-special-file-writable-p ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (should (file-writable-p nospecial))))
+
+(ert-deftest files-tests-file-name-non-special-find-backup-file-name ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (should (equal (find-backup-file-name nospecial)
+                   (mapcar (lambda (f) (concat "/:" f))
+                           (find-backup-file-name tmpfile))))))
+
+(ert-deftest files-tests-file-name-non-special-get-file-buffer ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (should-not (get-file-buffer nospecial))))
+
+(ert-deftest files-tests-file-name-non-special-insert-directory ()
+  (files-tests--with-temp-non-special (tmpdir nospecial-dir t)
+    (should (equal (with-temp-buffer
+                     (insert-directory nospecial-dir "")
+                     (buffer-string))
+                   (with-temp-buffer
+                     (insert-directory tmpdir "")
+                     (buffer-string))))))
+
+(ert-deftest files-tests-file-name-non-special-insert-file-contents ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (with-temp-buffer
+      (insert-file-contents nospecial)
+      (should (zerop (buffer-size))))))
+
+(ert-deftest files-tests-file-name-non-special-load ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (should (load nospecial nil t))))
+
+(ert-deftest files-tests-file-name-non-special-make-auto-save-file-name ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (save-current-buffer
+      (should (equal (prog2 (set-buffer (find-file-noselect nospecial))
+                         (make-auto-save-file-name)
+                       (kill-buffer))
+                     (prog2 (set-buffer (find-file-noselect tmpfile))
+                         (make-auto-save-file-name)
+                       (kill-buffer)))))))
+
+(ert-deftest files-tests-file-name-non-special-make-directory ()
+  (files-tests--with-temp-non-special (tmpdir nospecial-dir t)
+    (let ((default-directory nospecial-dir))
+      (make-directory "dir")
+      (should (file-directory-p "dir"))
+      (delete-directory "dir"))))
+
+(ert-deftest files-tests-file-name-non-special-make-directory-internal ()
+  (files-tests--with-temp-non-special (tmpdir nospecial-dir t)
+    (let ((default-directory nospecial-dir))
+      (make-directory-internal "dir")
+      (should (file-directory-p "dir"))
+      (delete-directory "dir"))))
+
+(ert-deftest files-tests-file-name-non-special-make-nearby-temp-file ()
+  (let* ((default-directory (concat "/:" temporary-file-directory))
+         (near-tmpfile (make-nearby-temp-file "file")))
+    (should (file-exists-p near-tmpfile))
+    (delete-file near-tmpfile)))
+
+(ert-deftest files-tests-file-name-non-special-make-symbolic-link ()
+  (files-tests--with-temp-non-special (tmpdir nospecial-dir t)
+    (files-tests--with-temp-non-special (tmpfile _nospecial)
+      (let* ((linkname (expand-file-name "link" tmpdir))
+             (may-symlink (ignore-errors (make-symbolic-link tmpfile linkname)
+                                         t)))
+        (when may-symlink
+          (should (file-symlink-p linkname))
+          (delete-file linkname)
+          (let ((linkname (expand-file-name "link" nospecial-dir)))
+            (make-symbolic-link tmpfile linkname)
             (should (file-symlink-p linkname))
-            (delete-file linkname)
-            (let ((linkname (expand-file-name "link" nospecial-dir)))
-              (make-symbolic-link tmpfile linkname)
-              (should (file-symlink-p linkname))
-              (delete-file linkname))))
-        ;; `files-tests--file-name-non-special--subprocess' already
-        ;; tests `process-file'.
-        (rename-file nospecial (concat nospecial "x"))
-        (rename-file (concat nospecial "x") nospecial)
-        (rename-file tmpfile (concat nospecial "x"))
-        (rename-file (concat nospecial "x") nospecial)
-        (rename-file nospecial (concat tmpfile "x"))
-        (rename-file (concat nospecial "x") nospecial)
-        (set-file-acl nospecial (file-acl nospecial))
-        (set-file-modes nospecial (file-modes nospecial))
-        (set-file-selinux-context nospecial (file-selinux-context nospecial))
-        (set-file-times nospecial)
-        ;; `files-tests--file-name-non-special--buffers' already tests
-        ;; `verify-visited-file-modtime'.
-        (with-temp-buffer
-          (write-region nil nil nospecial nil :visit))
-        (save-current-buffer
-          (set-buffer (find-file-noselect nospecial))
-          (set-visited-file-modtime)
-          (kill-buffer))
-        (with-temp-buffer
-          (let ((default-directory nospecial-dir))
-            (shell-command (concat (shell-quote-argument
-                                    (concat invocation-directory 
invocation-name))
-                                   " --version")
-                           (current-buffer))
-            (goto-char (point-min))
-            (should (search-forward emacs-version nil t))))
-        (with-temp-buffer
-          (let ((default-directory nospecial-dir))
-            (let ((proc (start-file-process
-                         "emacs" (current-buffer)
-                         (concat invocation-directory invocation-name)
-                         "--version")))
-              (accept-process-output proc)
-              (goto-char (point-min))
-              (should (search-forward emacs-version nil t))
-              (kill-process proc)
-              (accept-process-output proc ))))
-        (let ((process-environment (cons "FOO=foo" process-environment))
-              (nospecial-foo (concat nospecial "$FOO")))
-          ;; The "/:" prevents substitution.
-          (equal (substitute-in-file-name nospecial-foo) nospecial-foo))
-        (let ((default-directory nospecial-dir))
-          (equal (temporary-file-directory) temporary-file-directory))
-        (equal (unhandled-file-name-directory nospecial-dir)
-               (file-name-as-directory tmpdir))
-        (should (equal (vc-registered nospecial)
-                       (vc-registered tmpfile)))))))
+            (delete-file linkname)))))))
+
+;; See `files-tests--file-name-non-special--subprocess'.
+;; (ert-deftest files-tests-file-name-non-special-process-file ())
+
+(ert-deftest files-tests-file-name-non-special-rename-file ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (rename-file nospecial (concat nospecial "x"))
+    (rename-file (concat nospecial "x") nospecial)
+    (rename-file tmpfile (concat nospecial "x"))
+    (rename-file (concat nospecial "x") nospecial)
+    (rename-file nospecial (concat tmpfile "x"))
+    (rename-file (concat nospecial "x") nospecial)))
+
+(ert-deftest files-tests-file-name-non-special-set-file-acl ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (set-file-acl nospecial (file-acl nospecial))))
+
+(ert-deftest files-tests-file-name-non-special-set-file-modes ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (set-file-modes nospecial (file-modes nospecial))))
+
+(ert-deftest files-tests-file-name-non-special-set-file-selinux-context ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (set-file-selinux-context nospecial (file-selinux-context nospecial))))
+
+(ert-deftest files-tests-file-name-non-special-set-file-times ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (set-file-times nospecial)))
+
+(ert-deftest files-tests-file-name-non-special-set-visited-file-modtime ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (save-current-buffer
+      (set-buffer (find-file-noselect nospecial))
+      (set-visited-file-modtime)
+      (kill-buffer))))
+
+(ert-deftest files-tests-file-name-non-special-shell-command ()
+  (files-tests--with-temp-non-special (tmpdir nospecial-dir t)
+    (with-temp-buffer
+      (let ((default-directory nospecial-dir))
+        (shell-command (concat (shell-quote-argument
+                                (concat invocation-directory invocation-name))
+                               " --version")
+                       (current-buffer))
+        (goto-char (point-min))
+        (should (search-forward emacs-version nil t))))))
+
+(ert-deftest files-tests-file-name-non-special-start-file-process ()
+  (files-tests--with-temp-non-special (tmpdir nospecial-dir t)
+    (with-temp-buffer
+      (let ((default-directory nospecial-dir))
+        (let ((proc (start-file-process
+                     "emacs" (current-buffer)
+                     (concat invocation-directory invocation-name)
+                     "--version")))
+          (accept-process-output proc)
+          (goto-char (point-min))
+          (should (search-forward emacs-version nil t))
+          (kill-process proc)
+          (accept-process-output proc ))))))
+
+(ert-deftest files-tests-file-name-non-special-substitute-in-file-name ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (let ((process-environment (cons "FOO=foo" process-environment))
+          (nospecial-foo (concat nospecial "$FOO")))
+      ;; The "/:" prevents substitution.
+      (equal (substitute-in-file-name nospecial-foo) nospecial-foo))))
+(ert-deftest files-tests-file-name-non-special-temporary-file-directory ()
+  (files-tests--with-temp-non-special (tmpdir nospecial-dir t)
+    (let ((default-directory nospecial-dir))
+      (equal (temporary-file-directory) temporary-file-directory))))
+
+(ert-deftest files-tests-file-name-non-special-unhandled-file-name-directory ()
+  (files-tests--with-temp-non-special (tmpdir nospecial-dir t)
+    (equal (unhandled-file-name-directory nospecial-dir)
+           (file-name-as-directory tmpdir))))
+
+(ert-deftest files-tests-file-name-non-special-vc-registered ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (should (equal (vc-registered nospecial) (vc-registered tmpfile)))))
+
+;; See test `files-tests--file-name-non-special--buffers'.
+;; (ert-deftest files-tests-file-name-non-special-verify-visited-file-modtime 
())
+
+(ert-deftest files-tests-file-name-non-special-write-region ()
+  (files-tests--with-temp-non-special (tmpfile nospecial)
+    (with-temp-buffer
+      (write-region nil nil nospecial nil :visit))))
 
 (ert-deftest files-tests--insert-directory-wildcard-in-dir-p ()
   (let ((alist (list (cons "/home/user/*/.txt" (cons "/home/user/" "*/.txt"))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]