emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/compat 009e33bbc9: Add test for file-has-changed-p


From: ELPA Syncer
Subject: [elpa] externals/compat 009e33bbc9: Add test for file-has-changed-p
Date: Mon, 16 Jan 2023 08:57:26 -0500 (EST)

branch: externals/compat
commit 009e33bbc9084c63ad3e81b778855025826a0845
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    Add test for file-has-changed-p
---
 compat-29.el    |  8 ++++----
 compat-tests.el | 26 ++++++++++++++++++++++++--
 2 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/compat-29.el b/compat-29.el
index 7b53d59d5c..f8a6630f95 100644
--- a/compat-29.el
+++ b/compat-29.el
@@ -410,11 +410,11 @@ to `default-directory', and the result will also be 
relative."
      (t
       parent))))
 
-(compat-defvar file-has-changed-p--hash-table ;; <UNTESTED>
+(compat-defvar file-has-changed-p--hash-table ;; 
<compat-tests:file-has-changed-p>
                (make-hash-table :test #'equal)
   "Internal variable used by `file-has-changed-p'.")
 
-(compat-defun file-has-changed-p (file &optional tag) ;; <UNTESTED>
+(compat-defun file-has-changed-p (file &optional tag) ;; 
<compat-tests:file-has-changed-p>
   "Return non-nil if FILE has changed.
 The size and modification time of FILE are compared to the size
 and modification time of the same FILE during a previous
@@ -431,8 +431,8 @@ the symbol of the calling function, for example."
                           (file-attribute-modification-time fileattr))))
          (sym (concat (symbol-name tag) "@" file))
          (cachedattr (gethash sym file-has-changed-p--hash-table)))
-     (when (not (equal attr cachedattr))
-       (puthash sym attr file-has-changed-p--hash-table))))
+    (when (not (equal attr cachedattr))
+      (puthash sym attr file-has-changed-p--hash-table))))
 
 ;;;; Defined in keymap.el
 
diff --git a/compat-tests.el b/compat-tests.el
index 93288c08f3..e79cff2187 100644
--- a/compat-tests.el
+++ b/compat-tests.el
@@ -1215,7 +1215,7 @@
   (should-not (directory-name-p "dir/subdir")))
 
 (ert-deftest directory-empty-p ()
-  (let ((name (make-temp-name "compat-tests")))
+  (let ((name (make-temp-name "/tmp/compat-tests")))
     (make-directory name)
     (should (directory-empty-p name))
     (make-empty-file (file-name-concat name "file"))
@@ -1224,7 +1224,7 @@
     (delete-directory name)))
 
 (ert-deftest make-empty-file ()
-  (let ((name (make-temp-name "compat-tests")))
+  (let ((name (make-temp-name "/tmp/compat-tests")))
     (should-not (file-exists-p name))
     (make-empty-file name)
     (should-equal 0 (file-attribute-size (file-attributes name)))
@@ -1252,6 +1252,28 @@
   (should-equal (expand-file-name "bar/.#b") (make-lock-file-name "bar/b"))
   (should-equal (expand-file-name "bar/.#foo") (make-lock-file-name 
"bar/foo")))
 
+(ert-deftest file-has-changed-p ()
+  (let ((name (make-temp-file "/tmp/compat-tests")))
+    (should (file-has-changed-p name))
+    (should-not (file-has-changed-p name))
+    (should-not (file-has-changed-p name))
+    (should (file-has-changed-p name 'tag1))
+    (should-not (file-has-changed-p name 'tag1))
+    (should-not (file-has-changed-p name 'tag1))
+    (with-temp-buffer
+      (insert "changed")
+      (write-region (point-min) (point-max) name))
+    (should (file-has-changed-p name))
+    (should-not (file-has-changed-p name))
+    (should-not (file-has-changed-p name))
+    (should (file-has-changed-p name 'tag1))
+    (should-not (file-has-changed-p name 'tag1))
+    (should-not (file-has-changed-p name 'tag1))
+    (should (file-has-changed-p name 'tag2))
+    (should-not (file-has-changed-p name 'tag2))
+    (should-not (file-has-changed-p name 'tag2))
+    (delete-file name)))
+
 (ert-deftest file-attribute-getters ()
   (let ((attrs '(type link-number user-id group-id access-time 
modification-time
                  status-change-time size modes unspecified inode-number 
device-number)))



reply via email to

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