diff options
| author | Michael Albinus | 2019-07-31 21:22:48 +0200 |
|---|---|---|
| committer | Michael Albinus | 2019-07-31 21:22:48 +0200 |
| commit | 794f8f25b505ab32c7e79d1d484fce22e85c0010 (patch) | |
| tree | bc96da03e39f1e472f758d9bcbe28506e8822f1c | |
| parent | 6da19c52446e5526fb2c82ac9c57a579f3170795 (diff) | |
| download | emacs-794f8f25b505ab32c7e79d1d484fce22e85c0010.tar.gz emacs-794f8f25b505ab32c7e79d1d484fce22e85c0010.zip | |
Call file notification actions properly in filenotify-tests.el
* test/lisp/filenotify-tests.el (file-notify--test-wait-for-events):
Rename from `file-notify--wait-for-events'. Adapt all callees.
(file-notify--test-cleanup): Reset also `file-notify--test-event'
and `file-notify--test-file nil'.
(file-notify--test-event-desc, file-notify--test-event-action):
New accessor functions.
(file-notify-test02-rm-watch, file-notify--test-event-test)
(file-notify--test-with-actions-check)
(file-notify--test-with-actions-explainer): Use them.
(file-notify--test-with-actions-check)
(file-notify--test-with-actions-explainer)
(file-notify--test-with-actions): Rename them from *-events-*.
Rename also internal variables accordingly. Adapt all callees.
| -rw-r--r-- | test/lisp/filenotify-tests.el | 125 |
1 files changed, 68 insertions, 57 deletions
diff --git a/test/lisp/filenotify-tests.el b/test/lisp/filenotify-tests.el index 7c8c1953c4f..3d2f6e6a73e 100644 --- a/test/lisp/filenotify-tests.el +++ b/test/lisp/filenotify-tests.el | |||
| @@ -123,7 +123,7 @@ There are different timeouts for local and remote file notification libraries." | |||
| 123 | ((eq system-type 'cygwin) 6) | 123 | ((eq system-type 'cygwin) 6) |
| 124 | (t 3))) | 124 | (t 3))) |
| 125 | 125 | ||
| 126 | (defmacro file-notify--wait-for-events (timeout until) | 126 | (defmacro file-notify--test-wait-for-events (timeout until) |
| 127 | "Wait for and return file notification events until form UNTIL is true. | 127 | "Wait for and return file notification events until form UNTIL is true. |
| 128 | TIMEOUT is the maximum time to wait for, in seconds." | 128 | TIMEOUT is the maximum time to wait for, in seconds." |
| 129 | `(with-timeout (,timeout (ignore)) | 129 | `(with-timeout (,timeout (ignore)) |
| @@ -134,7 +134,7 @@ TIMEOUT is the maximum time to wait for, in seconds." | |||
| 134 | "Check that `file-notify-descriptors' is an empty hash table. | 134 | "Check that `file-notify-descriptors' is an empty hash table. |
| 135 | Return nil when any other file notification watch is still active." | 135 | Return nil when any other file notification watch is still active." |
| 136 | ;; Give read events a last chance. | 136 | ;; Give read events a last chance. |
| 137 | (file-notify--wait-for-events | 137 | (file-notify--test-wait-for-events |
| 138 | (file-notify--test-timeout) | 138 | (file-notify--test-timeout) |
| 139 | (zerop (hash-table-count file-notify-descriptors))) | 139 | (zerop (hash-table-count file-notify-descriptors))) |
| 140 | ;; Now check. | 140 | ;; Now check. |
| @@ -193,6 +193,8 @@ Return nil when any other file notification watch is still active." | |||
| 193 | file-notify--test-desc1 nil | 193 | file-notify--test-desc1 nil |
| 194 | file-notify--test-desc2 nil | 194 | file-notify--test-desc2 nil |
| 195 | file-notify--test-results nil | 195 | file-notify--test-results nil |
| 196 | file-notify--test-event nil | ||
| 197 | file-notify--test-file nil | ||
| 196 | file-notify--test-events nil | 198 | file-notify--test-events nil |
| 197 | file-notify--test-monitors nil)) | 199 | file-notify--test-monitors nil)) |
| 198 | 200 | ||
| @@ -459,9 +461,11 @@ If UNSTABLE is non-nil, the test is tagged as `:unstable'." | |||
| 459 | (unless (eq system-type 'cygwin) | 461 | (unless (eq system-type 'cygwin) |
| 460 | (let (results) | 462 | (let (results) |
| 461 | (cl-flet ((first-callback (event) | 463 | (cl-flet ((first-callback (event) |
| 462 | (when (eq (nth 1 event) 'deleted) (push 1 results))) | 464 | (when (eq (file-notify--test-event-action event) 'deleted) |
| 465 | (push 1 results))) | ||
| 463 | (second-callback (event) | 466 | (second-callback (event) |
| 464 | (when (eq (nth 1 event) 'deleted) (push 2 results)))) | 467 | (when (eq (file-notify--test-event-action event) 'deleted) |
| 468 | (push 2 results)))) | ||
| 465 | (setq file-notify--test-tmpfile (file-notify--test-make-temp-name)) | 469 | (setq file-notify--test-tmpfile (file-notify--test-make-temp-name)) |
| 466 | (write-region | 470 | (write-region |
| 467 | "any text" nil file-notify--test-tmpfile nil 'no-message) | 471 | "any text" nil file-notify--test-tmpfile nil 'no-message) |
| @@ -480,7 +484,7 @@ If UNSTABLE is non-nil, the test is tagged as `:unstable'." | |||
| 480 | ;; Only the second callback shall run. | 484 | ;; Only the second callback shall run. |
| 481 | (file-notify--test-read-event) | 485 | (file-notify--test-read-event) |
| 482 | (delete-file file-notify--test-tmpfile) | 486 | (delete-file file-notify--test-tmpfile) |
| 483 | (file-notify--wait-for-events | 487 | (file-notify--test-wait-for-events |
| 484 | (file-notify--test-timeout) results) | 488 | (file-notify--test-timeout) results) |
| 485 | (should (equal results (list 2))) | 489 | (should (equal results (list 2))) |
| 486 | 490 | ||
| @@ -494,6 +498,8 @@ If UNSTABLE is non-nil, the test is tagged as `:unstable'." | |||
| 494 | "Check `file-notify-rm-watch' for remote files.") | 498 | "Check `file-notify-rm-watch' for remote files.") |
| 495 | 499 | ||
| 496 | ;; Accessors for the callback argument. | 500 | ;; Accessors for the callback argument. |
| 501 | (defun file-notify--test-event-desc (event) (car event)) | ||
| 502 | (defun file-notify--test-event-action (event) (nth 1 event)) | ||
| 497 | (defun file-notify--test-event-file (event) (nth 2 event)) | 503 | (defun file-notify--test-event-file (event) (nth 2 event)) |
| 498 | (defun file-notify--test-event-file1 (event) (nth 3 event)) | 504 | (defun file-notify--test-event-file1 (event) (nth 3 event)) |
| 499 | 505 | ||
| @@ -502,14 +508,15 @@ If UNSTABLE is non-nil, the test is tagged as `:unstable'." | |||
| 502 | We cannot pass arguments, so we assume that `file-notify--test-event' | 508 | We cannot pass arguments, so we assume that `file-notify--test-event' |
| 503 | and `file-notify--test-file' are bound somewhere." | 509 | and `file-notify--test-file' are bound somewhere." |
| 504 | ;; Check the descriptor. | 510 | ;; Check the descriptor. |
| 505 | (should (equal (car file-notify--test-event) file-notify--test-desc)) | 511 | (should (equal (file-notify--test-event-desc file-notify--test-event) |
| 512 | file-notify--test-desc)) | ||
| 506 | ;; Check the file name. | 513 | ;; Check the file name. |
| 507 | (should | 514 | (should |
| 508 | (string-prefix-p | 515 | (string-prefix-p |
| 509 | file-notify--test-file | 516 | file-notify--test-file |
| 510 | (file-notify--test-event-file file-notify--test-event))) | 517 | (file-notify--test-event-file file-notify--test-event))) |
| 511 | ;; Check the second file name if exists. | 518 | ;; Check the second file name if exists. |
| 512 | (when (eq (nth 1 file-notify--test-event) 'renamed) | 519 | (when (eq (file-notify--test-event-action file-notify--test-event) 'renamed) |
| 513 | (should | 520 | (should |
| 514 | (string-prefix-p | 521 | (string-prefix-p |
| 515 | file-notify--test-file | 522 | file-notify--test-file |
| @@ -535,68 +542,72 @@ and the event to `file-notify--test-events'." | |||
| 535 | file-notify--test-results | 542 | file-notify--test-results |
| 536 | (append file-notify--test-results `(,result)))))) | 543 | (append file-notify--test-results `(,result)))))) |
| 537 | 544 | ||
| 538 | (defun file-notify--test-with-events-check (events) | 545 | (defun file-notify--test-with-actions-check (actions) |
| 539 | "Check whether received events match one of the EVENTS alternatives." | 546 | "Check whether received actions match one of the ACTIONS alternatives." |
| 540 | (let (result) | 547 | (let (result) |
| 541 | (dolist (elt events result) | 548 | (dolist (elt actions result) |
| 542 | (setq result | 549 | (setq result |
| 543 | (or result | 550 | (or result |
| 544 | (if (eq (car elt) :random) | 551 | (if (eq (car elt) :random) |
| 545 | (equal (sort (cdr elt) 'string-lessp) | 552 | (equal (sort (cdr elt) 'string-lessp) |
| 546 | (sort (mapcar #'cadr file-notify--test-events) | 553 | (sort (mapcar #'file-notify--test-event-action |
| 554 | file-notify--test-events) | ||
| 547 | 'string-lessp)) | 555 | 'string-lessp)) |
| 548 | (equal elt (mapcar #'cadr file-notify--test-events)))))))) | 556 | (equal elt (mapcar #'file-notify--test-event-action |
| 549 | 557 | file-notify--test-events)))))))) | |
| 550 | (defun file-notify--test-with-events-explainer (events) | 558 | |
| 551 | "Explain why `file-notify--test-with-events-check' fails." | 559 | (defun file-notify--test-with-actions-explainer (actions) |
| 552 | (if (null (cdr events)) | 560 | "Explain why `file-notify--test-with-actions-check' fails." |
| 553 | (format "Received events do not match expected events\n%s\n%s" | 561 | (if (null (cdr actions)) |
| 554 | (mapcar #'cadr file-notify--test-events) (car events)) | 562 | (format "Received actions do not match expected actions\n%s\n%s" |
| 563 | (mapcar #'file-notify--test-event-action file-notify--test-events) | ||
| 564 | (car actions)) | ||
| 555 | (format | 565 | (format |
| 556 | "Received events do not match any sequence of expected events\n%s\n%s" | 566 | "Received actions do not match any sequence of expected actions\n%s\n%s" |
| 557 | (mapcar #'cadr file-notify--test-events) events))) | 567 | (mapcar #'file-notify--test-event-action file-notify--test-events) |
| 568 | actions))) | ||
| 558 | 569 | ||
| 559 | (put 'file-notify--test-with-events-check 'ert-explainer | 570 | (put 'file-notify--test-with-actions-check 'ert-explainer |
| 560 | 'file-notify--test-with-events-explainer) | 571 | 'file-notify--test-with-actions-explainer) |
| 561 | 572 | ||
| 562 | (defmacro file-notify--test-with-events (events &rest body) | 573 | (defmacro file-notify--test-with-actions (actions &rest body) |
| 563 | "Run BODY collecting events and then compare with EVENTS. | 574 | "Run BODY collecting actions and then compare with ACTIONS. |
| 564 | EVENTS is either a simple list of events, or a list of lists of | 575 | ACTIONS is either a simple list of actions, or a list of lists of |
| 565 | events, which represent different possible results. The first | 576 | actions, which represent different possible results. The first |
| 566 | event of a list could be the pseudo event `:random', which is | 577 | event of a list could be the pseudo event `:random', which is |
| 567 | just an indicator for comparison. | 578 | just an indicator for comparison. |
| 568 | 579 | ||
| 569 | Don't wait longer than timeout seconds for the events to be | 580 | Don't wait longer than timeout seconds for the actions to be |
| 570 | delivered." | 581 | delivered." |
| 571 | (declare (indent 1)) | 582 | (declare (indent 1) (debug (form body))) |
| 572 | `(let* ((events (if (consp (car ,events)) ,events (list ,events))) | 583 | `(let* ((actions (if (consp (car ,actions)) ,actions (list ,actions))) |
| 573 | (max-length | 584 | (max-length |
| 574 | (apply | 585 | (apply |
| 575 | 'max | 586 | 'max |
| 576 | (mapcar | 587 | (mapcar |
| 577 | (lambda (x) (length (if (eq (car x) :random) (cdr x) x))) | 588 | (lambda (x) (length (if (eq (car x) :random) (cdr x) x))) |
| 578 | events))) | 589 | actions))) |
| 579 | create-lockfiles) | 590 | create-lockfiles) |
| 580 | ;; Flush pending events. | 591 | ;; Flush pending actions. |
| 581 | (file-notify--test-read-event) | 592 | (file-notify--test-read-event) |
| 582 | (file-notify--wait-for-events | 593 | (file-notify--test-wait-for-events |
| 583 | (file-notify--test-timeout) | 594 | (file-notify--test-timeout) |
| 584 | (not (input-pending-p))) | 595 | (not (input-pending-p))) |
| 585 | (setq file-notify--test-events nil | 596 | (setq file-notify--test-events nil |
| 586 | file-notify--test-results nil) | 597 | file-notify--test-results nil) |
| 587 | ,@body | 598 | ,@body |
| 588 | (file-notify--wait-for-events | 599 | (file-notify--test-wait-for-events |
| 589 | ;; More events need more time. Use some fudge factor. | 600 | ;; More actions need more time. Use some fudge factor. |
| 590 | (* (ceiling max-length 100) (file-notify--test-timeout)) | 601 | (* (ceiling max-length 100) (file-notify--test-timeout)) |
| 591 | (= max-length (length file-notify--test-events))) | 602 | (= max-length (length file-notify--test-events))) |
| 592 | ;; Check the result sequence just to make sure that all events | 603 | ;; Check the result sequence just to make sure that all actions |
| 593 | ;; are as expected. | 604 | ;; are as expected. |
| 594 | (dolist (result file-notify--test-results) | 605 | (dolist (result file-notify--test-results) |
| 595 | (when (ert-test-failed-p result) | 606 | (when (ert-test-failed-p result) |
| 596 | (ert-fail | 607 | (ert-fail |
| 597 | (cadr (ert-test-result-with-condition-condition result))))) | 608 | (cadr (ert-test-result-with-condition-condition result))))) |
| 598 | ;; One of the possible event sequences shall match. | 609 | ;; One of the possible event sequences shall match. |
| 599 | (should (file-notify--test-with-events-check events)))) | 610 | (should (file-notify--test-with-actions-check actions)))) |
| 600 | 611 | ||
| 601 | (ert-deftest file-notify-test03-events () | 612 | (ert-deftest file-notify-test03-events () |
| 602 | "Check file creation/change/removal notifications." | 613 | "Check file creation/change/removal notifications." |
| @@ -613,7 +624,7 @@ delivered." | |||
| 613 | (file-notify--test-add-watch | 624 | (file-notify--test-add-watch |
| 614 | file-notify--test-tmpfile | 625 | file-notify--test-tmpfile |
| 615 | '(change) #'file-notify--test-event-handler))) | 626 | '(change) #'file-notify--test-event-handler))) |
| 616 | (file-notify--test-with-events | 627 | (file-notify--test-with-actions |
| 617 | (cond | 628 | (cond |
| 618 | ;; gvfs-monitor-dir on cygwin does not detect the | 629 | ;; gvfs-monitor-dir on cygwin does not detect the |
| 619 | ;; `created' event reliably. | 630 | ;; `created' event reliably. |
| @@ -647,7 +658,7 @@ delivered." | |||
| 647 | (file-notify--test-add-watch | 658 | (file-notify--test-add-watch |
| 648 | file-notify--test-tmpfile | 659 | file-notify--test-tmpfile |
| 649 | '(change) #'file-notify--test-event-handler))) | 660 | '(change) #'file-notify--test-event-handler))) |
| 650 | (file-notify--test-with-events | 661 | (file-notify--test-with-actions |
| 651 | (cond | 662 | (cond |
| 652 | ;; gvfs-monitor-dir on cygwin does not detect the | 663 | ;; gvfs-monitor-dir on cygwin does not detect the |
| 653 | ;; `changed' event reliably. | 664 | ;; `changed' event reliably. |
| @@ -681,7 +692,7 @@ delivered." | |||
| 681 | (file-notify--test-add-watch | 692 | (file-notify--test-add-watch |
| 682 | file-notify--test-tmpdir | 693 | file-notify--test-tmpdir |
| 683 | '(change) #'file-notify--test-event-handler))) | 694 | '(change) #'file-notify--test-event-handler))) |
| 684 | (file-notify--test-with-events | 695 | (file-notify--test-with-actions |
| 685 | (cond | 696 | (cond |
| 686 | ;; w32notify does not raise `deleted' and `stopped' | 697 | ;; w32notify does not raise `deleted' and `stopped' |
| 687 | ;; events for the watched directory. | 698 | ;; events for the watched directory. |
| @@ -728,7 +739,7 @@ delivered." | |||
| 728 | (file-notify--test-add-watch | 739 | (file-notify--test-add-watch |
| 729 | file-notify--test-tmpdir | 740 | file-notify--test-tmpdir |
| 730 | '(change) #'file-notify--test-event-handler))) | 741 | '(change) #'file-notify--test-event-handler))) |
| 731 | (file-notify--test-with-events | 742 | (file-notify--test-with-actions |
| 732 | (cond | 743 | (cond |
| 733 | ;; w32notify does not distinguish between `changed' and | 744 | ;; w32notify does not distinguish between `changed' and |
| 734 | ;; `attribute-changed'. It does not raise `deleted' and | 745 | ;; `attribute-changed'. It does not raise `deleted' and |
| @@ -785,7 +796,7 @@ delivered." | |||
| 785 | (file-notify--test-add-watch | 796 | (file-notify--test-add-watch |
| 786 | file-notify--test-tmpdir | 797 | file-notify--test-tmpdir |
| 787 | '(change) #'file-notify--test-event-handler))) | 798 | '(change) #'file-notify--test-event-handler))) |
| 788 | (file-notify--test-with-events | 799 | (file-notify--test-with-actions |
| 789 | (cond | 800 | (cond |
| 790 | ;; w32notify does not raise `deleted' and `stopped' | 801 | ;; w32notify does not raise `deleted' and `stopped' |
| 791 | ;; events for the watched directory. | 802 | ;; events for the watched directory. |
| @@ -836,7 +847,7 @@ delivered." | |||
| 836 | (file-notify--test-add-watch | 847 | (file-notify--test-add-watch |
| 837 | file-notify--test-tmpfile | 848 | file-notify--test-tmpfile |
| 838 | '(attribute-change) #'file-notify--test-event-handler))) | 849 | '(attribute-change) #'file-notify--test-event-handler))) |
| 839 | (file-notify--test-with-events | 850 | (file-notify--test-with-actions |
| 840 | (cond | 851 | (cond |
| 841 | ;; w32notify does not distinguish between `changed' and | 852 | ;; w32notify does not distinguish between `changed' and |
| 842 | ;; `attribute-changed'. Under MS Windows 7, we get four | 853 | ;; `attribute-changed'. Under MS Windows 7, we get four |
| @@ -923,7 +934,7 @@ delivered." | |||
| 923 | "another text" nil file-notify--test-tmpfile nil 'no-message) | 934 | "another text" nil file-notify--test-tmpfile nil 'no-message) |
| 924 | 935 | ||
| 925 | ;; Check, that the buffer has been reverted. | 936 | ;; Check, that the buffer has been reverted. |
| 926 | (file-notify--wait-for-events | 937 | (file-notify--test-wait-for-events |
| 927 | timeout | 938 | timeout |
| 928 | (string-match | 939 | (string-match |
| 929 | (format-message "Reverting buffer `%s'." (buffer-name buf)) | 940 | (format-message "Reverting buffer `%s'." (buffer-name buf)) |
| @@ -932,7 +943,7 @@ delivered." | |||
| 932 | 943 | ||
| 933 | ;; Stop file notification. Autorevert shall still work via polling. | 944 | ;; Stop file notification. Autorevert shall still work via polling. |
| 934 | (file-notify-rm-watch auto-revert-notify-watch-descriptor) | 945 | (file-notify-rm-watch auto-revert-notify-watch-descriptor) |
| 935 | (file-notify--wait-for-events | 946 | (file-notify--test-wait-for-events |
| 936 | timeout (null auto-revert-notify-watch-descriptor)) | 947 | timeout (null auto-revert-notify-watch-descriptor)) |
| 937 | (should auto-revert-use-notify) | 948 | (should auto-revert-use-notify) |
| 938 | (should-not auto-revert-notify-watch-descriptor) | 949 | (should-not auto-revert-notify-watch-descriptor) |
| @@ -946,7 +957,7 @@ delivered." | |||
| 946 | "foo bla" nil file-notify--test-tmpfile nil 'no-message) | 957 | "foo bla" nil file-notify--test-tmpfile nil 'no-message) |
| 947 | 958 | ||
| 948 | ;; Check, that the buffer has been reverted. | 959 | ;; Check, that the buffer has been reverted. |
| 949 | (file-notify--wait-for-events | 960 | (file-notify--test-wait-for-events |
| 950 | timeout | 961 | timeout |
| 951 | (string-match | 962 | (string-match |
| 952 | (format-message "Reverting buffer `%s'." (buffer-name buf)) | 963 | (format-message "Reverting buffer `%s'." (buffer-name buf)) |
| @@ -1002,7 +1013,7 @@ delivered." | |||
| 1002 | file-notify--test-tmpfile | 1013 | file-notify--test-tmpfile |
| 1003 | '(change) #'file-notify--test-event-handler))) | 1014 | '(change) #'file-notify--test-event-handler))) |
| 1004 | (should (file-notify-valid-p file-notify--test-desc)) | 1015 | (should (file-notify-valid-p file-notify--test-desc)) |
| 1005 | (file-notify--test-with-events | 1016 | (file-notify--test-with-actions |
| 1006 | (cond | 1017 | (cond |
| 1007 | ;; gvfs-monitor-dir on cygwin does not detect the | 1018 | ;; gvfs-monitor-dir on cygwin does not detect the |
| 1008 | ;; `changed' event reliably. | 1019 | ;; `changed' event reliably. |
| @@ -1039,7 +1050,7 @@ delivered." | |||
| 1039 | file-notify--test-tmpdir | 1050 | file-notify--test-tmpdir |
| 1040 | '(change) #'file-notify--test-event-handler))) | 1051 | '(change) #'file-notify--test-event-handler))) |
| 1041 | (should (file-notify-valid-p file-notify--test-desc)) | 1052 | (should (file-notify-valid-p file-notify--test-desc)) |
| 1042 | (file-notify--test-with-events | 1053 | (file-notify--test-with-actions |
| 1043 | (cond | 1054 | (cond |
| 1044 | ;; w32notify does not raise `deleted' and `stopped' | 1055 | ;; w32notify does not raise `deleted' and `stopped' |
| 1045 | ;; events for the watched directory. | 1056 | ;; events for the watched directory. |
| @@ -1100,7 +1111,7 @@ delivered." | |||
| 1100 | ;; After removing the watch, the descriptor must not be valid | 1111 | ;; After removing the watch, the descriptor must not be valid |
| 1101 | ;; anymore. | 1112 | ;; anymore. |
| 1102 | (file-notify-rm-watch file-notify--test-desc) | 1113 | (file-notify-rm-watch file-notify--test-desc) |
| 1103 | (file-notify--wait-for-events | 1114 | (file-notify--test-wait-for-events |
| 1104 | (file-notify--test-timeout) | 1115 | (file-notify--test-timeout) |
| 1105 | (not (file-notify-valid-p file-notify--test-desc))) | 1116 | (not (file-notify-valid-p file-notify--test-desc))) |
| 1106 | (should-not (file-notify-valid-p file-notify--test-desc)) | 1117 | (should-not (file-notify-valid-p file-notify--test-desc)) |
| @@ -1127,7 +1138,7 @@ delivered." | |||
| 1127 | ;; After deleting the directory, the descriptor must not be | 1138 | ;; After deleting the directory, the descriptor must not be |
| 1128 | ;; valid anymore. | 1139 | ;; valid anymore. |
| 1129 | (delete-directory file-notify--test-tmpfile 'recursive) | 1140 | (delete-directory file-notify--test-tmpfile 'recursive) |
| 1130 | (file-notify--wait-for-events | 1141 | (file-notify--test-wait-for-events |
| 1131 | (file-notify--test-timeout) | 1142 | (file-notify--test-timeout) |
| 1132 | (not (file-notify-valid-p file-notify--test-desc))) | 1143 | (not (file-notify-valid-p file-notify--test-desc))) |
| 1133 | (should-not (file-notify-valid-p file-notify--test-desc)) | 1144 | (should-not (file-notify-valid-p file-notify--test-desc)) |
| @@ -1170,7 +1181,7 @@ delivered." | |||
| 1170 | (push (expand-file-name (format "y%d" i)) target-file-list)) | 1181 | (push (expand-file-name (format "y%d" i)) target-file-list)) |
| 1171 | (push (expand-file-name (format "y%d" i)) source-file-list) | 1182 | (push (expand-file-name (format "y%d" i)) source-file-list) |
| 1172 | (push (expand-file-name (format "x%d" i)) target-file-list))) | 1183 | (push (expand-file-name (format "x%d" i)) target-file-list))) |
| 1173 | (file-notify--test-with-events (make-list (+ n n) 'created) | 1184 | (file-notify--test-with-actions (make-list (+ n n) 'created) |
| 1174 | (let ((source-file-list source-file-list) | 1185 | (let ((source-file-list source-file-list) |
| 1175 | (target-file-list target-file-list)) | 1186 | (target-file-list target-file-list)) |
| 1176 | (while (and source-file-list target-file-list) | 1187 | (while (and source-file-list target-file-list) |
| @@ -1178,7 +1189,7 @@ delivered." | |||
| 1178 | (write-region "" nil (pop source-file-list) nil 'no-message) | 1189 | (write-region "" nil (pop source-file-list) nil 'no-message) |
| 1179 | (file-notify--test-read-event) | 1190 | (file-notify--test-read-event) |
| 1180 | (write-region "" nil (pop target-file-list) nil 'no-message)))) | 1191 | (write-region "" nil (pop target-file-list) nil 'no-message)))) |
| 1181 | (file-notify--test-with-events | 1192 | (file-notify--test-with-actions |
| 1182 | (cond | 1193 | (cond |
| 1183 | ;; w32notify fires both `deleted' and `renamed' events. | 1194 | ;; w32notify fires both `deleted' and `renamed' events. |
| 1184 | ((string-equal (file-notify--test-library) "w32notify") | 1195 | ((string-equal (file-notify--test-library) "w32notify") |
| @@ -1199,7 +1210,7 @@ delivered." | |||
| 1199 | (while (and source-file-list target-file-list) | 1210 | (while (and source-file-list target-file-list) |
| 1200 | (file-notify--test-read-event) | 1211 | (file-notify--test-read-event) |
| 1201 | (rename-file (pop source-file-list) (pop target-file-list) t)))) | 1212 | (rename-file (pop source-file-list) (pop target-file-list) t)))) |
| 1202 | (file-notify--test-with-events (make-list n 'deleted) | 1213 | (file-notify--test-with-actions (make-list n 'deleted) |
| 1203 | (dolist (file target-file-list) | 1214 | (dolist (file target-file-list) |
| 1204 | (file-notify--test-read-event) | 1215 | (file-notify--test-read-event) |
| 1205 | (delete-file file))) | 1216 | (delete-file file))) |
| @@ -1233,7 +1244,7 @@ delivered." | |||
| 1233 | file-notify--test-tmpfile | 1244 | file-notify--test-tmpfile |
| 1234 | '(change) #'file-notify--test-event-handler))) | 1245 | '(change) #'file-notify--test-event-handler))) |
| 1235 | (should (file-notify-valid-p file-notify--test-desc)) | 1246 | (should (file-notify-valid-p file-notify--test-desc)) |
| 1236 | (file-notify--test-with-events | 1247 | (file-notify--test-with-actions |
| 1237 | ;; There could be one or two `changed' events. | 1248 | ;; There could be one or two `changed' events. |
| 1238 | '((changed) | 1249 | '((changed) |
| 1239 | (changed changed)) | 1250 | (changed changed)) |
| @@ -1269,7 +1280,7 @@ delivered." | |||
| 1269 | file-notify--test-tmpfile | 1280 | file-notify--test-tmpfile |
| 1270 | '(change) #'file-notify--test-event-handler))) | 1281 | '(change) #'file-notify--test-event-handler))) |
| 1271 | (should (file-notify-valid-p file-notify--test-desc)) | 1282 | (should (file-notify-valid-p file-notify--test-desc)) |
| 1272 | (file-notify--test-with-events | 1283 | (file-notify--test-with-actions |
| 1273 | (cond | 1284 | (cond |
| 1274 | ;; On cygwin we only get the `changed' event. | 1285 | ;; On cygwin we only get the `changed' event. |
| 1275 | ((eq system-type 'cygwin) | 1286 | ((eq system-type 'cygwin) |
| @@ -1345,7 +1356,7 @@ the file watch." | |||
| 1345 | (should-not (equal file-notify--test-desc1 file-notify--test-desc2)) | 1356 | (should-not (equal file-notify--test-desc1 file-notify--test-desc2)) |
| 1346 | (let ((n 100)) | 1357 | (let ((n 100)) |
| 1347 | ;; Run the test. | 1358 | ;; Run the test. |
| 1348 | (file-notify--test-with-events | 1359 | (file-notify--test-with-actions |
| 1349 | ;; There could be one or two `changed' events. | 1360 | ;; There could be one or two `changed' events. |
| 1350 | (list | 1361 | (list |
| 1351 | ;; cygwin. | 1362 | ;; cygwin. |
| @@ -1387,13 +1398,13 @@ the file watch." | |||
| 1387 | ;; directory and the file monitor. The `stopped' event is | 1398 | ;; directory and the file monitor. The `stopped' event is |
| 1388 | ;; from the file monitor. It's undecided in which order the | 1399 | ;; from the file monitor. It's undecided in which order the |
| 1389 | ;; the directory and the file monitor are triggered. | 1400 | ;; the directory and the file monitor are triggered. |
| 1390 | (file-notify--test-with-events '(:random deleted deleted stopped) | 1401 | (file-notify--test-with-actions '(:random deleted deleted stopped) |
| 1391 | (delete-file file-notify--test-tmpfile1)) | 1402 | (delete-file file-notify--test-tmpfile1)) |
| 1392 | (should (file-notify-valid-p file-notify--test-desc1)) | 1403 | (should (file-notify-valid-p file-notify--test-desc1)) |
| 1393 | (should-not (file-notify-valid-p file-notify--test-desc2)) | 1404 | (should-not (file-notify-valid-p file-notify--test-desc2)) |
| 1394 | 1405 | ||
| 1395 | ;; Now we delete the directory. | 1406 | ;; Now we delete the directory. |
| 1396 | (file-notify--test-with-events | 1407 | (file-notify--test-with-actions |
| 1397 | (cond | 1408 | (cond |
| 1398 | ;; In kqueue and for cygwin, just one `deleted' event for | 1409 | ;; In kqueue and for cygwin, just one `deleted' event for |
| 1399 | ;; the directory is received. | 1410 | ;; the directory is received. |