aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2014-01-21 14:31:39 +0100
committerMichael Albinus2014-01-21 14:31:39 +0100
commit63389c254e73b53a253676ff45e8b089e45c1f31 (patch)
treedd57a72e17a9b4c3e4eff6518e609ac7960033de
parentdd9d2e9d1ee663f5c068715923a2a84fbb55c08e (diff)
downloademacs-63389c254e73b53a253676ff45e8b089e45c1f31.tar.gz
emacs-63389c254e73b53a253676ff45e8b089e45c1f31.zip
* automated/file-notify-tests.el
(file-notify--test-local-enabled): Fix error in logic. (file-notify--wait-for-events): New defmacro. (file-notify-test02-events): Make short breaks between file operations. Use `file-notify--wait-for-events'. Check, that events have arrived. (file-notify-test03-autorevert): Use `file-notify--wait-for-events'.
-rw-r--r--test/ChangeLog7
-rw-r--r--test/automated/file-notify-tests.el32
2 files changed, 28 insertions, 11 deletions
diff --git a/test/ChangeLog b/test/ChangeLog
index e4cabe0032f..21d3e54af80 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,5 +1,12 @@
12014-01-21 Michael Albinus <michael.albinus@gmx.de> 12014-01-21 Michael Albinus <michael.albinus@gmx.de>
2 2
3 * automated/file-notify-tests.el
4 (file-notify--test-local-enabled): Fix error in logic.
5 (file-notify--wait-for-events): New defmacro.
6 (file-notify-test02-events): Make short breaks between file operations.
7 Use `file-notify--wait-for-events'. Check, that events have arrived.
8 (file-notify-test03-autorevert): Use `file-notify--wait-for-events'.
9
3 * automated/comint-testsuite.el 10 * automated/comint-testsuite.el
4 (comint-testsuite-password-strings): Add localized examples. 11 (comint-testsuite-password-strings): Add localized examples.
5 12
diff --git a/test/automated/file-notify-tests.el b/test/automated/file-notify-tests.el
index 9d901e04d44..4845b62d04b 100644
--- a/test/automated/file-notify-tests.el
+++ b/test/automated/file-notify-tests.el
@@ -67,7 +67,7 @@
67This is needed for local `temporary-file-directory' only, in the 67This is needed for local `temporary-file-directory' only, in the
68remote case we return always `t'." 68remote case we return always `t'."
69 (or file-notify--library 69 (or file-notify--library
70 (not (file-remote-p temporary-file-directory)))) 70 (file-remote-p temporary-file-directory)))
71 71
72(defvar file-notify--test-remote-enabled-checked nil 72(defvar file-notify--test-remote-enabled-checked nil
73 "Cached result of `file-notify--test-remote-enabled'. 73 "Cached result of `file-notify--test-remote-enabled'.
@@ -187,6 +187,16 @@ Save the result in `file-notify--test-results', for later analysis."
187 (expand-file-name 187 (expand-file-name
188 (make-temp-name "file-notify-test") temporary-file-directory)) 188 (make-temp-name "file-notify-test") temporary-file-directory))
189 189
190(defmacro file-notify--wait-for-events (timeout until)
191 "Wait for file notification events until form UNTIL is true.
192TIMEOUT is the maximum time to wait for."
193 `(with-timeout (,timeout (ignore))
194 (while (null ,until)
195 ;; glib events, and remote events.
196 (accept-process-output nil 0.1)
197 ;; inotify events.
198 (read-event nil nil 0.1))))
199
190(ert-deftest file-notify-test02-events () 200(ert-deftest file-notify-test02-events ()
191 "Check file creation/removal notifications." 201 "Check file creation/removal notifications."
192 (skip-unless (file-notify--test-local-enabled)) 202 (skip-unless (file-notify--test-local-enabled))
@@ -205,6 +215,7 @@ Save the result in `file-notify--test-results', for later analysis."
205 (write-region 215 (write-region
206 "any text" nil file-notify--test-tmpfile nil 'no-message) 216 "any text" nil file-notify--test-tmpfile nil 'no-message)
207 (delete-file file-notify--test-tmpfile) 217 (delete-file file-notify--test-tmpfile)
218 (sit-for 0.1 'nodisplay)
208 219
209 ;; Check copy and rename. 220 ;; Check copy and rename.
210 (write-region 221 (write-region
@@ -212,18 +223,21 @@ Save the result in `file-notify--test-results', for later analysis."
212 (copy-file file-notify--test-tmpfile file-notify--test-tmpfile1) 223 (copy-file file-notify--test-tmpfile file-notify--test-tmpfile1)
213 (delete-file file-notify--test-tmpfile) 224 (delete-file file-notify--test-tmpfile)
214 (delete-file file-notify--test-tmpfile1) 225 (delete-file file-notify--test-tmpfile1)
226 (sit-for 0.1 'nodisplay)
215 227
216 (write-region 228 (write-region
217 "any text" nil file-notify--test-tmpfile nil 'no-message) 229 "any text" nil file-notify--test-tmpfile nil 'no-message)
218 (rename-file file-notify--test-tmpfile file-notify--test-tmpfile1) 230 (rename-file file-notify--test-tmpfile file-notify--test-tmpfile1)
219 (delete-file file-notify--test-tmpfile1)) 231 (delete-file file-notify--test-tmpfile1)
232 (sit-for 0.1 'nodisplay))
220 233
221 ;; Wait for events, and exit. 234 ;; Wait for events, and exit.
222 (sit-for 5 'nodisplay) 235 (file-notify--wait-for-events 5 file-notify--test-results)
223 (file-notify-rm-watch desc) 236 (file-notify-rm-watch desc)
224 (ignore-errors (delete-file file-notify--test-tmpfile)) 237 (ignore-errors (delete-file file-notify--test-tmpfile))
225 (ignore-errors (delete-file file-notify--test-tmpfile1)))) 238 (ignore-errors (delete-file file-notify--test-tmpfile1))))
226 239
240 (should file-notify--test-results)
227 (dolist (result file-notify--test-results) 241 (dolist (result file-notify--test-results)
228 ;(message "%s" (ert-test-result-messages result)) 242 ;(message "%s" (ert-test-result-messages result))
229 (when (ert-test-failed-p result) 243 (when (ert-test-failed-p result)
@@ -278,14 +292,10 @@ This test is skipped in batch mode."
278 292
279 ;; Check, that the buffer has been reverted. 293 ;; Check, that the buffer has been reverted.
280 (with-current-buffer (get-buffer-create "*Messages*") 294 (with-current-buffer (get-buffer-create "*Messages*")
281 (with-timeout (timeout (ignore)) 295 (file-notify--wait-for-events
282 (while 296 timeout
283 (null (string-match 297 (string-match (format "Reverting buffer `%s'." (buffer-name buf))
284 (format "Reverting buffer `%s'." (buffer-name buf)) 298 (buffer-string))))
285 (buffer-string)))
286 ;; We must trigger the process filter to run.
287 (when remote (accept-process-output nil 1))
288 (sit-for 1 'nodisplay))))
289 (should (string-match "another text" (buffer-string))))) 299 (should (string-match "another text" (buffer-string)))))
290 300
291 ;; Exit. 301 ;; Exit.