diff options
| -rw-r--r-- | test/automated/file-notify-tests.el | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/test/automated/file-notify-tests.el b/test/automated/file-notify-tests.el index 18e1b939a72..3ade9980d6b 100644 --- a/test/automated/file-notify-tests.el +++ b/test/automated/file-notify-tests.el | |||
| @@ -372,6 +372,65 @@ This test is skipped in batch mode." | |||
| 372 | "Check autorevert via file notification for remote files. | 372 | "Check autorevert via file notification for remote files. |
| 373 | This test is skipped in batch mode.") | 373 | This test is skipped in batch mode.") |
| 374 | 374 | ||
| 375 | (ert-deftest file-notify-test04-file-validity () | ||
| 376 | "Check `file-notify-valid-p'." | ||
| 377 | (skip-unless (file-notify--test-local-enabled)) | ||
| 378 | (unwind-protect | ||
| 379 | (progn | ||
| 380 | (setq file-notify--test-tmpfile (file-notify--test-make-temp-name)) | ||
| 381 | (setq file-notify--test-desc (file-notify-add-watch | ||
| 382 | file-notify--test-tmpfile | ||
| 383 | '(change) | ||
| 384 | #'file-notify--test-event-handler)) | ||
| 385 | |||
| 386 | (file-notify--test-with-events | ||
| 387 | 3 3 (lambda (events) | ||
| 388 | (should (equal '(created changed deleted) | ||
| 389 | (mapcar #'cadr events)))) | ||
| 390 | (should (file-notify-valid-p file-notify--test-desc)) | ||
| 391 | (write-region | ||
| 392 | "any text" nil file-notify--test-tmpfile nil 'no-message) | ||
| 393 | (should (file-notify-valid-p file-notify--test-desc)) | ||
| 394 | (delete-file file-notify--test-tmpfile) | ||
| 395 | ;; TODO: Even after deletion, the descriptor stays valid. | ||
| 396 | ;; Is that intended? | ||
| 397 | (should (file-notify-valid-p file-notify--test-desc)))) | ||
| 398 | |||
| 399 | ;; Exit. | ||
| 400 | (file-notify--test-cleanup))) | ||
| 401 | |||
| 402 | (file-notify--deftest-remote file-notify-test04-file-validity | ||
| 403 | "Check `file-notify-valid-p' via file notification for remote | ||
| 404 | files.") | ||
| 405 | |||
| 406 | (ert-deftest file-notify-test05-dir-validity () | ||
| 407 | "Check `file-notify-valid-p' for directories." | ||
| 408 | (skip-unless (file-notify--test-local-enabled)) | ||
| 409 | (unwind-protect | ||
| 410 | (progn | ||
| 411 | (setq dir (file-name-as-directory | ||
| 412 | (file-notify--test-make-temp-name))) | ||
| 413 | (make-directory dir) | ||
| 414 | (setq file-notify--test-desc (file-notify-add-watch | ||
| 415 | dir | ||
| 416 | '(change) | ||
| 417 | #'file-notify--test-event-handler)) | ||
| 418 | |||
| 419 | (should (file-notify-valid-p file-notify--test-desc)) | ||
| 420 | (delete-directory dir) | ||
| 421 | ;; TODO: Even after deletion, the descriptor stays valid. Is | ||
| 422 | ;; that intended? | ||
| 423 | (should (file-notify-valid-p file-notify--test-desc))) | ||
| 424 | |||
| 425 | ;; FIXME: This signals an exception which indicates that | ||
| 426 | ;; file-notify--test-desc shouldn't really be valid anymore. | ||
| 427 | (ignore-errors | ||
| 428 | (file-notify-rm-watch file-notify--test-desc)))) | ||
| 429 | |||
| 430 | (file-notify--deftest-remote file-notify-test05-dir-validity | ||
| 431 | "Check `file-notify-valid-p' via file notification for remote | ||
| 432 | directories.") | ||
| 433 | |||
| 375 | (defun file-notify-test-all (&optional interactive) | 434 | (defun file-notify-test-all (&optional interactive) |
| 376 | "Run all tests for \\[file-notify]." | 435 | "Run all tests for \\[file-notify]." |
| 377 | (interactive "p") | 436 | (interactive "p") |