aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2024-02-07 11:20:46 -0500
committerStefan Monnier2024-02-07 11:20:46 -0500
commitf9ffa0148c3fb9e07671fae8f8ca72dd2d403163 (patch)
treeb545b6ad5f86c1a75a9d206960bf5b86a730cb54
parent12fb298e21d877c772a19fc8f2fec68a40bcda14 (diff)
downloademacs-f9ffa0148c3fb9e07671fae8f8ca72dd2d403163.tar.gz
emacs-f9ffa0148c3fb9e07671fae8f8ca72dd2d403163.zip
(file-notify--test-wait-event): Rename from `file-notify--test-read-event`
* test/lisp/filenotify-tests.el (file-notify--test-wait-event): Rename to better reflect its purpose rather than its implementation. Also make it return nil so callers won't be tempted to use the return value.
-rw-r--r--test/lisp/filenotify-tests.el53
1 files changed, 27 insertions, 26 deletions
diff --git a/test/lisp/filenotify-tests.el b/test/lisp/filenotify-tests.el
index 11af1f75574..28f4d5fa181 100644
--- a/test/lisp/filenotify-tests.el
+++ b/test/lisp/filenotify-tests.el
@@ -74,8 +74,8 @@
74(defvar file-notify--test-events nil) 74(defvar file-notify--test-events nil)
75(defvar file-notify--test-monitors nil) 75(defvar file-notify--test-monitors nil)
76 76
77(defun file-notify--test-read-event () 77(defun file-notify--test-wait-event ()
78 "Read one event. 78 "Wait for one event.
79There are different timeouts for local and remote file notification libraries." 79There are different timeouts for local and remote file notification libraries."
80 (read-event 80 (read-event
81 nil nil 81 nil nil
@@ -87,7 +87,8 @@ There are different timeouts for local and remote file notification libraries."
87 ;; for any monitor. 87 ;; for any monitor.
88 ((file-notify--test-monitor) 7) 88 ((file-notify--test-monitor) 7)
89 ((file-remote-p temporary-file-directory) 0.1) 89 ((file-remote-p temporary-file-directory) 0.1)
90 (t 0.01)))) 90 (t 0.01)))
91 nil)
91 92
92(defun file-notify--test-timeout () 93(defun file-notify--test-timeout ()
93 "Timeout to wait for arriving a bunch of events, in seconds." 94 "Timeout to wait for arriving a bunch of events, in seconds."
@@ -103,7 +104,7 @@ There are different timeouts for local and remote file notification libraries."
103TIMEOUT is the maximum time to wait for, in seconds." 104TIMEOUT is the maximum time to wait for, in seconds."
104 `(with-timeout (,timeout (ignore)) 105 `(with-timeout (,timeout (ignore))
105 (while (null ,until) 106 (while (null ,until)
106 (file-notify--test-read-event)))) 107 (file-notify--test-wait-event))))
107 108
108(defun file-notify--test-no-descriptors () 109(defun file-notify--test-no-descriptors ()
109 "Check that `file-notify-descriptors' is an empty hash table. 110 "Check that `file-notify-descriptors' is an empty hash table.
@@ -452,7 +453,7 @@ If UNSTABLE is non-nil, the test is tagged as `:unstable'."
452 ;; Check, that removing watch descriptors out of order do not 453 ;; Check, that removing watch descriptors out of order do not
453 ;; harm. This fails on cygwin because of timing issues unless a 454 ;; harm. This fails on cygwin because of timing issues unless a
454 ;; long `sit-for' is added before the call to 455 ;; long `sit-for' is added before the call to
455 ;; `file-notify--test-read-event'. 456 ;; `file-notify--test-wait-event'.
456 (unless (eq system-type 'cygwin) 457 (unless (eq system-type 'cygwin)
457 (let (results) 458 (let (results)
458 (cl-flet ((first-callback (event) 459 (cl-flet ((first-callback (event)
@@ -480,7 +481,7 @@ If UNSTABLE is non-nil, the test is tagged as `:unstable'."
480 ;; Remove first watch. 481 ;; Remove first watch.
481 (file-notify-rm-watch file-notify--test-desc) 482 (file-notify-rm-watch file-notify--test-desc)
482 ;; Only the second callback shall run. 483 ;; Only the second callback shall run.
483 (file-notify--test-read-event) 484 (file-notify--test-wait-event)
484 (delete-file file-notify--test-tmpfile) 485 (delete-file file-notify--test-tmpfile)
485 (file-notify--test-wait-for-events 486 (file-notify--test-wait-for-events
486 (file-notify--test-timeout) results) 487 (file-notify--test-timeout) results)
@@ -622,7 +623,7 @@ delivered."
622 (cons 'file-notify while-no-input-ignore-events)) 623 (cons 'file-notify while-no-input-ignore-events))
623 create-lockfiles) 624 create-lockfiles)
624 ;; Flush pending actions. 625 ;; Flush pending actions.
625 (file-notify--test-read-event) 626 (file-notify--test-wait-event)
626 (file-notify--test-wait-for-events 627 (file-notify--test-wait-for-events
627 (file-notify--test-timeout) 628 (file-notify--test-timeout)
628 (not (input-pending-p))) 629 (not (input-pending-p)))
@@ -671,7 +672,7 @@ delivered."
671 (t '(created changed deleted stopped))) 672 (t '(created changed deleted stopped)))
672 (write-region 673 (write-region
673 "another text" nil file-notify--test-tmpfile nil 'no-message) 674 "another text" nil file-notify--test-tmpfile nil 'no-message)
674 (file-notify--test-read-event) 675 (file-notify--test-wait-event)
675 (delete-file file-notify--test-tmpfile)) 676 (delete-file file-notify--test-tmpfile))
676 (file-notify-rm-watch file-notify--test-desc) 677 (file-notify-rm-watch file-notify--test-desc)
677 678
@@ -707,7 +708,7 @@ delivered."
707 (changed changed deleted stopped)))) 708 (changed changed deleted stopped))))
708 (write-region 709 (write-region
709 "another text" nil file-notify--test-tmpfile nil 'no-message) 710 "another text" nil file-notify--test-tmpfile nil 'no-message)
710 (file-notify--test-read-event) 711 (file-notify--test-wait-event)
711 (delete-file file-notify--test-tmpfile)) 712 (delete-file file-notify--test-tmpfile))
712 (file-notify-rm-watch file-notify--test-desc) 713 (file-notify-rm-watch file-notify--test-desc)
713 714
@@ -755,7 +756,7 @@ delivered."
755 (t '(created changed deleted deleted stopped))) 756 (t '(created changed deleted deleted stopped)))
756 (write-region 757 (write-region
757 "any text" nil file-notify--test-tmpfile nil 'no-message) 758 "any text" nil file-notify--test-tmpfile nil 'no-message)
758 (file-notify--test-read-event) 759 (file-notify--test-wait-event)
759 (delete-directory file-notify--test-tmpdir 'recursive)) 760 (delete-directory file-notify--test-tmpdir 'recursive))
760 (file-notify-rm-watch file-notify--test-desc) 761 (file-notify-rm-watch file-notify--test-desc)
761 762
@@ -805,14 +806,14 @@ delivered."
805 deleted deleted deleted stopped))) 806 deleted deleted deleted stopped)))
806 (write-region 807 (write-region
807 "any text" nil file-notify--test-tmpfile nil 'no-message) 808 "any text" nil file-notify--test-tmpfile nil 'no-message)
808 (file-notify--test-read-event) 809 (file-notify--test-wait-event)
809 (copy-file file-notify--test-tmpfile file-notify--test-tmpfile1) 810 (copy-file file-notify--test-tmpfile file-notify--test-tmpfile1)
810 ;; The next two events shall not be visible. 811 ;; The next two events shall not be visible.
811 (file-notify--test-read-event) 812 (file-notify--test-wait-event)
812 (set-file-modes file-notify--test-tmpfile 000 'nofollow) 813 (set-file-modes file-notify--test-tmpfile 000 'nofollow)
813 (file-notify--test-read-event) 814 (file-notify--test-wait-event)
814 (set-file-times file-notify--test-tmpfile '(0 0) 'nofollow) 815 (set-file-times file-notify--test-tmpfile '(0 0) 'nofollow)
815 (file-notify--test-read-event) 816 (file-notify--test-wait-event)
816 (delete-directory file-notify--test-tmpdir 'recursive)) 817 (delete-directory file-notify--test-tmpdir 'recursive))
817 (file-notify-rm-watch file-notify--test-desc) 818 (file-notify-rm-watch file-notify--test-desc)
818 819
@@ -860,10 +861,10 @@ delivered."
860 (t '(created changed renamed deleted deleted stopped))) 861 (t '(created changed renamed deleted deleted stopped)))
861 (write-region 862 (write-region
862 "any text" nil file-notify--test-tmpfile nil 'no-message) 863 "any text" nil file-notify--test-tmpfile nil 'no-message)
863 (file-notify--test-read-event) 864 (file-notify--test-wait-event)
864 (rename-file file-notify--test-tmpfile file-notify--test-tmpfile1) 865 (rename-file file-notify--test-tmpfile file-notify--test-tmpfile1)
865 ;; After the rename, we won't get events anymore. 866 ;; After the rename, we won't get events anymore.
866 (file-notify--test-read-event) 867 (file-notify--test-wait-event)
867 (delete-directory file-notify--test-tmpdir 'recursive)) 868 (delete-directory file-notify--test-tmpdir 'recursive))
868 (file-notify-rm-watch file-notify--test-desc) 869 (file-notify-rm-watch file-notify--test-desc)
869 870
@@ -912,11 +913,11 @@ delivered."
912 (t '(attribute-changed attribute-changed))) 913 (t '(attribute-changed attribute-changed)))
913 (write-region 914 (write-region
914 "any text" nil file-notify--test-tmpfile nil 'no-message) 915 "any text" nil file-notify--test-tmpfile nil 'no-message)
915 (file-notify--test-read-event) 916 (file-notify--test-wait-event)
916 (set-file-modes file-notify--test-tmpfile 000 'nofollow) 917 (set-file-modes file-notify--test-tmpfile 000 'nofollow)
917 (file-notify--test-read-event) 918 (file-notify--test-wait-event)
918 (set-file-times file-notify--test-tmpfile '(0 0) 'nofollow) 919 (set-file-times file-notify--test-tmpfile '(0 0) 'nofollow)
919 (file-notify--test-read-event) 920 (file-notify--test-wait-event)
920 (delete-file file-notify--test-tmpfile)) 921 (delete-file file-notify--test-tmpfile))
921 (file-notify-rm-watch file-notify--test-desc) 922 (file-notify-rm-watch file-notify--test-desc)
922 923
@@ -1087,7 +1088,7 @@ delivered."
1087 (changed changed deleted stopped)))) 1088 (changed changed deleted stopped))))
1088 (write-region 1089 (write-region
1089 "another text" nil file-notify--test-tmpfile nil 'no-message) 1090 "another text" nil file-notify--test-tmpfile nil 'no-message)
1090 (file-notify--test-read-event) 1091 (file-notify--test-wait-event)
1091 (delete-file file-notify--test-tmpfile)) 1092 (delete-file file-notify--test-tmpfile))
1092 ;; After deleting the file, the descriptor is not valid anymore. 1093 ;; After deleting the file, the descriptor is not valid anymore.
1093 (should-not (file-notify-valid-p file-notify--test-desc)) 1094 (should-not (file-notify-valid-p file-notify--test-desc))
@@ -1134,7 +1135,7 @@ delivered."
1134 (t '(created changed deleted deleted stopped))) 1135 (t '(created changed deleted deleted stopped)))
1135 (write-region 1136 (write-region
1136 "any text" nil file-notify--test-tmpfile nil 'no-message) 1137 "any text" nil file-notify--test-tmpfile nil 'no-message)
1137 (file-notify--test-read-event) 1138 (file-notify--test-wait-event)
1138 (delete-directory file-notify--test-tmpdir 'recursive)) 1139 (delete-directory file-notify--test-tmpdir 'recursive))
1139 ;; After deleting the parent directory, the descriptor must 1140 ;; After deleting the parent directory, the descriptor must
1140 ;; not be valid anymore. 1141 ;; not be valid anymore.
@@ -1247,9 +1248,9 @@ delivered."
1247 (let ((source-file-list source-file-list) 1248 (let ((source-file-list source-file-list)
1248 (target-file-list target-file-list)) 1249 (target-file-list target-file-list))
1249 (while (and source-file-list target-file-list) 1250 (while (and source-file-list target-file-list)
1250 (file-notify--test-read-event) 1251 (file-notify--test-wait-event)
1251 (write-region "" nil (pop source-file-list) nil 'no-message) 1252 (write-region "" nil (pop source-file-list) nil 'no-message)
1252 (file-notify--test-read-event) 1253 (file-notify--test-wait-event)
1253 (write-region "" nil (pop target-file-list) nil 'no-message)))) 1254 (write-region "" nil (pop target-file-list) nil 'no-message))))
1254 (file-notify--test-with-actions 1255 (file-notify--test-with-actions
1255 (cond 1256 (cond
@@ -1272,11 +1273,11 @@ delivered."
1272 (let ((source-file-list source-file-list) 1273 (let ((source-file-list source-file-list)
1273 (target-file-list target-file-list)) 1274 (target-file-list target-file-list))
1274 (while (and source-file-list target-file-list) 1275 (while (and source-file-list target-file-list)
1275 (file-notify--test-read-event) 1276 (file-notify--test-wait-event)
1276 (rename-file (pop source-file-list) (pop target-file-list) t)))) 1277 (rename-file (pop source-file-list) (pop target-file-list) t))))
1277 (file-notify--test-with-actions (make-list n 'deleted) 1278 (file-notify--test-with-actions (make-list n 'deleted)
1278 (dolist (file target-file-list) 1279 (dolist (file target-file-list)
1279 (file-notify--test-read-event) 1280 (file-notify--test-wait-event)
1280 (delete-file file))) 1281 (delete-file file)))
1281 (delete-directory file-notify--test-tmpfile) 1282 (delete-directory file-notify--test-tmpfile)
1282 (if (or (string-equal (file-notify--test-library) "w32notify") 1283 (if (or (string-equal (file-notify--test-library) "w32notify")
@@ -1464,7 +1465,7 @@ the file watch."
1464 ;; does not report the `changed' event. 1465 ;; does not report the `changed' event.
1465 (make-list (/ n 2) 'created))) 1466 (make-list (/ n 2) 'created)))
1466 (dotimes (i n) 1467 (dotimes (i n)
1467 (file-notify--test-read-event) 1468 (file-notify--test-wait-event)
1468 (if (zerop (mod i 2)) 1469 (if (zerop (mod i 2))
1469 (write-region 1470 (write-region
1470 "any text" nil file-notify--test-tmpfile1 t 'no-message) 1471 "any text" nil file-notify--test-tmpfile1 t 'no-message)