aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMichael Albinus2017-03-22 14:15:45 +0100
committerMichael Albinus2017-03-22 14:15:45 +0100
commit716b46848989bc343797d98488a7a0cc33ed3179 (patch)
tree3bcba3da0a6ffae8973d9477e06c0a8e722ddc15 /test
parent0b60d7657a2d9e5f9a233032643b0f3ce55420ee (diff)
downloademacs-716b46848989bc343797d98488a7a0cc33ed3179.tar.gz
emacs-716b46848989bc343797d98488a7a0cc33ed3179.zip
Extend `file-notify-test02-rm-watch'
* test/lisp/filenotify-tests.el (file-notify-test02-rm-watch): Expect it failed for inotify. Divide tests into different `unwind-protect' clauses. Check, that removing watch descriptors out of order do not harm. (Bug#26126)
Diffstat (limited to 'test')
-rw-r--r--test/lisp/filenotify-tests.el55
1 files changed, 51 insertions, 4 deletions
diff --git a/test/lisp/filenotify-tests.el b/test/lisp/filenotify-tests.el
index 72080322379..654e1af1123 100644
--- a/test/lisp/filenotify-tests.el
+++ b/test/lisp/filenotify-tests.el
@@ -340,20 +340,24 @@ This returns only for the local case and gfilenotify; otherwise it is nil.
340 (expand-file-name 340 (expand-file-name
341 (make-temp-name "file-notify-test") temporary-file-directory)) 341 (make-temp-name "file-notify-test") temporary-file-directory))
342 342
343;; This test is inspired by Bug#26127. 343;; This test is inspired by Bug#26126 and Bug#26127.
344(ert-deftest file-notify-test02-rm-watch () 344(ert-deftest file-notify-test02-rm-watch ()
345 "Check `file-notify-rm-watch'." 345 "Check `file-notify-rm-watch'."
346 ;; There is a problem with inotify removing watch descriptors out of
347 ;; order. Temporarily, we expect to fail this test until it is
348 ;; fixed.
349 :expected-result
350 (if (string-equal (file-notify--test-library) "inotify") :failed :passed)
346 (skip-unless (file-notify--test-local-enabled)) 351 (skip-unless (file-notify--test-local-enabled))
347 352
348 (unwind-protect 353 (unwind-protect
354 ;; Check, that `file-notify-rm-watch' works.
349 (progn 355 (progn
350 ;; Check, that `file-notify-rm-watch' works.
351 (should 356 (should
352 (setq file-notify--test-desc 357 (setq file-notify--test-desc
353 (file-notify-add-watch 358 (file-notify-add-watch
354 temporary-file-directory '(change) #'ignore))) 359 temporary-file-directory '(change) #'ignore)))
355 (file-notify-rm-watch file-notify--test-desc) 360 (file-notify-rm-watch file-notify--test-desc)
356
357 ;; Check, that any parameter is accepted. 361 ;; Check, that any parameter is accepted.
358 (condition-case err 362 (condition-case err
359 (progn 363 (progn
@@ -363,7 +367,15 @@ This returns only for the local case and gfilenotify; otherwise it is nil.
363 (file-notify-rm-watch 'foo)) 367 (file-notify-rm-watch 'foo))
364 (error (ert-fail err))) 368 (error (ert-fail err)))
365 369
366 ;; Check, that no error is returned removing a watch descriptor twice. 370 ;; The environment shall be cleaned up.
371 (file-notify--test-cleanup-p))
372
373 ;; Cleanup.
374 (file-notify--test-cleanup))
375
376 (unwind-protect
377 ;; Check, that no error is returned removing a watch descriptor twice.
378 (progn
367 (setq file-notify--test-tmpfile (file-notify--test-make-temp-name) 379 (setq file-notify--test-tmpfile (file-notify--test-make-temp-name)
368 file-notify--test-tmpfile1 (file-notify--test-make-temp-name)) 380 file-notify--test-tmpfile1 (file-notify--test-make-temp-name))
369 (should 381 (should
@@ -374,6 +386,7 @@ This returns only for the local case and gfilenotify; otherwise it is nil.
374 (setq file-notify--test-desc1 386 (setq file-notify--test-desc1
375 (file-notify-add-watch 387 (file-notify-add-watch
376 file-notify--test-tmpfile1 '(change) #'ignore))) 388 file-notify--test-tmpfile1 '(change) #'ignore)))
389 ;; Remove `file-notify--test-desc' twice.
377 (file-notify-rm-watch file-notify--test-desc) 390 (file-notify-rm-watch file-notify--test-desc)
378 (file-notify-rm-watch file-notify--test-desc) 391 (file-notify-rm-watch file-notify--test-desc)
379 (file-notify-rm-watch file-notify--test-desc1) 392 (file-notify-rm-watch file-notify--test-desc1)
@@ -382,6 +395,40 @@ This returns only for the local case and gfilenotify; otherwise it is nil.
382 (file-notify--test-cleanup-p)) 395 (file-notify--test-cleanup-p))
383 396
384 ;; Cleanup. 397 ;; Cleanup.
398 (file-notify--test-cleanup))
399
400 (unwind-protect
401 ;; Check, that removing watch descriptors out of order do not harm.
402 (let (results)
403 (cl-flet ((first-callback (event)
404 (when (eq (nth 1 event) 'deleted) (push 1 results)))
405 (second-callback (event)
406 (when (eq (nth 1 event) 'deleted) (push 2 results))))
407 (setq file-notify--test-tmpfile (file-notify--test-make-temp-name))
408 (write-region
409 "any text" nil file-notify--test-tmpfile nil 'no-message)
410 (should
411 (setq file-notify--test-desc
412 (file-notify-add-watch
413 file-notify--test-tmpfile
414 '(change) #'first-callback)))
415 (should
416 (setq file-notify--test-desc1
417 (file-notify-add-watch
418 file-notify--test-tmpfile
419 '(change) #'second-callback)))
420 ;; Remove first watch.
421 (file-notify-rm-watch file-notify--test-desc)
422 ;; Only the second callback shall run.
423 (delete-file file-notify--test-tmpfile)
424 (file-notify--wait-for-events
425 (file-notify--test-timeout) results)
426 (should (equal results (list 2)))
427
428 ;; The environment shall be cleaned up.
429 (file-notify--test-cleanup-p)))
430
431 ;; Cleanup.
385 (file-notify--test-cleanup))) 432 (file-notify--test-cleanup)))
386 433
387(file-notify--deftest-remote file-notify-test02-rm-watch 434(file-notify--deftest-remote file-notify-test02-rm-watch