diff options
| author | F. Jason Park | 2023-04-20 19:23:54 -0700 |
|---|---|---|
| committer | F. Jason Park | 2023-05-05 17:18:01 -0700 |
| commit | 8654cea5843aa2fa2074f317d338451eadae092f (patch) | |
| tree | e4ea328f398252fc633c4e34f0044f097fc85e9f /test | |
| parent | c9f1ad2a87081fcc30d541554721806d89365af0 (diff) | |
| download | emacs-8654cea5843aa2fa2074f317d338451eadae092f.tar.gz emacs-8654cea5843aa2fa2074f317d338451eadae092f.zip | |
Move ERC's buffer-display tests to separate file
* test/lisp/erc/erc-scenarios-base-buffer-display.el: New file.
* test/lisp/erc/erc-scenarios-base-reconnect.el
(erc-scenarios-common--base-reconnect-options,
erc-scenarios-base-reconnect-options--buffer,
erc-scenarios-base-reconnect-options--default): Move to new file and
rename. (Bug#62833)
* test/lisp/erc/resources/erc-d/erc-d-tests.el (erc-d-run-linger):
Lengthen timeout.
* test/lisp/erc/resources/erc-d/erc-d.el (erc-d--m): Ensure buffer is
live before inserting.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/erc/erc-scenarios-base-buffer-display.el | 121 | ||||
| -rw-r--r-- | test/lisp/erc/erc-scenarios-base-reconnect.el | 89 | ||||
| -rw-r--r-- | test/lisp/erc/resources/erc-d/erc-d-tests.el | 2 | ||||
| -rw-r--r-- | test/lisp/erc/resources/erc-d/erc-d.el | 7 |
4 files changed, 126 insertions, 93 deletions
diff --git a/test/lisp/erc/erc-scenarios-base-buffer-display.el b/test/lisp/erc/erc-scenarios-base-buffer-display.el new file mode 100644 index 00000000000..d511c8ff738 --- /dev/null +++ b/test/lisp/erc/erc-scenarios-base-buffer-display.el | |||
| @@ -0,0 +1,121 @@ | |||
| 1 | ;;; erc-scenarios-base-buffer-display.el --- Buffer display scenarios -*- lexical-binding: t -*- | ||
| 2 | |||
| 3 | ;; Copyright (C) 2023 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; This file is part of GNU Emacs. | ||
| 6 | |||
| 7 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 8 | ;; it under the terms of the GNU General Public License as published by | ||
| 9 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 10 | ;; (at your option) any later version. | ||
| 11 | |||
| 12 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | ;; GNU General Public License for more details. | ||
| 16 | |||
| 17 | ;; You should have received a copy of the GNU General Public License | ||
| 18 | ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. | ||
| 19 | |||
| 20 | ;;; Code: | ||
| 21 | |||
| 22 | (require 'ert-x) | ||
| 23 | (eval-and-compile | ||
| 24 | (let ((load-path (cons (ert-resource-directory) load-path))) | ||
| 25 | (require 'erc-scenarios-common))) | ||
| 26 | |||
| 27 | (eval-when-compile (require 'erc-join)) | ||
| 28 | |||
| 29 | ;; These first couple `erc-reconnect-display' tests used to live in | ||
| 30 | ;; erc-scenarios-base-reconnect but have since been renamed. | ||
| 31 | |||
| 32 | (defun erc-scenarios-base-buffer-display--reconnect-common (test) | ||
| 33 | (erc-scenarios-common-with-cleanup | ||
| 34 | ((erc-scenarios-common-dialog "base/reconnect") | ||
| 35 | (dumb-server (erc-d-run "localhost" t 'options 'options-again)) | ||
| 36 | (port (process-contact dumb-server :service)) | ||
| 37 | (expect (erc-d-t-make-expecter)) | ||
| 38 | (erc-server-flood-penalty 0.1) | ||
| 39 | (erc-server-auto-reconnect t) | ||
| 40 | erc-autojoin-channels-alist | ||
| 41 | erc-server-buffer) | ||
| 42 | |||
| 43 | (should (memq 'autojoin erc-modules)) | ||
| 44 | |||
| 45 | (ert-info ("Connect to foonet") | ||
| 46 | (setq erc-server-buffer (erc :server "127.0.0.1" | ||
| 47 | :port port | ||
| 48 | :nick "tester" | ||
| 49 | :password "changeme" | ||
| 50 | :full-name "tester")) | ||
| 51 | (with-current-buffer erc-server-buffer | ||
| 52 | (should (string= (buffer-name) (format "127.0.0.1:%d" port))) | ||
| 53 | (funcall expect 10 "debug mode"))) | ||
| 54 | |||
| 55 | (ert-info ("Wait for some output in channels") | ||
| 56 | (with-current-buffer (erc-d-t-wait-for 10 (get-buffer "#chan")) | ||
| 57 | (funcall expect 10 "welcome"))) | ||
| 58 | |||
| 59 | (ert-info ("Server buffer shows connection failed") | ||
| 60 | (with-current-buffer erc-server-buffer | ||
| 61 | (funcall expect 10 "Connection failed! Re-establishing"))) | ||
| 62 | |||
| 63 | (should (equal erc-autojoin-channels-alist '((FooNet "#chan")))) | ||
| 64 | |||
| 65 | (funcall test) | ||
| 66 | |||
| 67 | ;; A manual /JOIN command tells ERC we're done auto-reconnecting | ||
| 68 | (with-current-buffer "FooNet" (erc-cmd-JOIN "#spam")) | ||
| 69 | |||
| 70 | (erc-d-t-ensure-for 1 "Newly joined chan ignores `erc-reconnect-display'" | ||
| 71 | (not (eq (window-buffer) (get-buffer "#spam")))) | ||
| 72 | |||
| 73 | (ert-info ("Wait for auto reconnect") | ||
| 74 | (with-current-buffer erc-server-buffer | ||
| 75 | (funcall expect 10 "still in debug mode"))) | ||
| 76 | |||
| 77 | (ert-info ("Wait for activity to recommence in channels") | ||
| 78 | (with-current-buffer (erc-d-t-wait-for 10 (get-buffer "#chan")) | ||
| 79 | (funcall expect 10 "forest of Arden")) | ||
| 80 | (with-current-buffer (erc-d-t-wait-for 10 (get-buffer "#spam")) | ||
| 81 | (funcall expect 10 "her elves come here anon"))))) | ||
| 82 | |||
| 83 | (ert-deftest erc-scenarios-base-reconnect-options--buffer () | ||
| 84 | :tags '(:expensive-test) | ||
| 85 | (should (eq erc-join-buffer 'bury)) | ||
| 86 | (should-not erc-reconnect-display) | ||
| 87 | |||
| 88 | ;; FooNet (the server buffer) is not switched to because it's | ||
| 89 | ;; already current (but not shown) when `erc-open' is called. See | ||
| 90 | ;; related conditional guard towards the end of that function. | ||
| 91 | |||
| 92 | (let ((erc-reconnect-display 'buffer)) | ||
| 93 | (erc-scenarios-base-buffer-display--reconnect-common | ||
| 94 | (lambda () | ||
| 95 | (pop-to-buffer-same-window "*Messages*") | ||
| 96 | |||
| 97 | (erc-d-t-ensure-for 1 "Server buffer not shown" | ||
| 98 | (not (eq (window-buffer) (get-buffer "FooNet")))) | ||
| 99 | |||
| 100 | (erc-d-t-wait-for 5 "Channel #chan shown when autojoined" | ||
| 101 | (eq (window-buffer) (get-buffer "#chan"))))))) | ||
| 102 | |||
| 103 | (ert-deftest erc-scenarios-base-reconnect-options--default () | ||
| 104 | :tags '(:expensive-test) | ||
| 105 | (should (eq erc-join-buffer 'bury)) | ||
| 106 | (should-not erc-reconnect-display) | ||
| 107 | |||
| 108 | (erc-scenarios-base-buffer-display--reconnect-common | ||
| 109 | |||
| 110 | (lambda () | ||
| 111 | (pop-to-buffer-same-window "*Messages*") | ||
| 112 | |||
| 113 | (erc-d-t-ensure-for 1 "Server buffer not shown" | ||
| 114 | (not (eq (window-buffer) (get-buffer "FooNet")))) | ||
| 115 | |||
| 116 | (erc-d-t-ensure-for 3 "Channel #chan not shown" | ||
| 117 | (not (eq (window-buffer) (get-buffer "#chan")))) | ||
| 118 | |||
| 119 | (should (eq (window-buffer) (messages-buffer)))))) | ||
| 120 | |||
| 121 | ;;; erc-scenarios-base-buffer-display.el ends here | ||
diff --git a/test/lisp/erc/erc-scenarios-base-reconnect.el b/test/lisp/erc/erc-scenarios-base-reconnect.el index 5b4dc549042..7bd16d1ed14 100644 --- a/test/lisp/erc/erc-scenarios-base-reconnect.el +++ b/test/lisp/erc/erc-scenarios-base-reconnect.el | |||
| @@ -65,95 +65,6 @@ | |||
| 65 | (should (equal (list (get-buffer (format "127.0.0.1:%d" port))) | 65 | (should (equal (list (get-buffer (format "127.0.0.1:%d" port))) |
| 66 | (erc-scenarios-common-buflist "127.0.0.1")))))) | 66 | (erc-scenarios-common-buflist "127.0.0.1")))))) |
| 67 | 67 | ||
| 68 | (defun erc-scenarios-common--base-reconnect-options (test) | ||
| 69 | (erc-scenarios-common-with-cleanup | ||
| 70 | ((erc-scenarios-common-dialog "base/reconnect") | ||
| 71 | (dumb-server (erc-d-run "localhost" t 'options 'options-again)) | ||
| 72 | (port (process-contact dumb-server :service)) | ||
| 73 | (expect (erc-d-t-make-expecter)) | ||
| 74 | (erc-server-flood-penalty 0.1) | ||
| 75 | (erc-server-auto-reconnect t) | ||
| 76 | erc-autojoin-channels-alist | ||
| 77 | erc-server-buffer) | ||
| 78 | |||
| 79 | (should (memq 'autojoin erc-modules)) | ||
| 80 | |||
| 81 | (ert-info ("Connect to foonet") | ||
| 82 | (setq erc-server-buffer (erc :server "127.0.0.1" | ||
| 83 | :port port | ||
| 84 | :nick "tester" | ||
| 85 | :password "changeme" | ||
| 86 | :full-name "tester")) | ||
| 87 | (with-current-buffer erc-server-buffer | ||
| 88 | (should (string= (buffer-name) (format "127.0.0.1:%d" port))) | ||
| 89 | (funcall expect 10 "debug mode"))) | ||
| 90 | |||
| 91 | (ert-info ("Wait for some output in channels") | ||
| 92 | (with-current-buffer (erc-d-t-wait-for 10 (get-buffer "#chan")) | ||
| 93 | (funcall expect 10 "welcome"))) | ||
| 94 | |||
| 95 | (ert-info ("Server buffer shows connection failed") | ||
| 96 | (with-current-buffer erc-server-buffer | ||
| 97 | (funcall expect 10 "Connection failed! Re-establishing"))) | ||
| 98 | |||
| 99 | (should (equal erc-autojoin-channels-alist '((FooNet "#chan")))) | ||
| 100 | |||
| 101 | (funcall test) | ||
| 102 | |||
| 103 | ;; A manual /JOIN command tells ERC we're done auto-reconnecting | ||
| 104 | (with-current-buffer "FooNet" (erc-cmd-JOIN "#spam")) | ||
| 105 | |||
| 106 | (erc-d-t-ensure-for 1 "Newly joined chan ignores `erc-reconnect-display'" | ||
| 107 | (not (eq (window-buffer) (get-buffer "#spam")))) | ||
| 108 | |||
| 109 | (ert-info ("Wait for auto reconnect") | ||
| 110 | (with-current-buffer erc-server-buffer | ||
| 111 | (funcall expect 10 "still in debug mode"))) | ||
| 112 | |||
| 113 | (ert-info ("Wait for activity to recommence in channels") | ||
| 114 | (with-current-buffer (erc-d-t-wait-for 10 (get-buffer "#chan")) | ||
| 115 | (funcall expect 10 "forest of Arden")) | ||
| 116 | (with-current-buffer (erc-d-t-wait-for 10 (get-buffer "#spam")) | ||
| 117 | (funcall expect 10 "her elves come here anon"))))) | ||
| 118 | |||
| 119 | (ert-deftest erc-scenarios-base-reconnect-options--buffer () | ||
| 120 | :tags '(:expensive-test) | ||
| 121 | (should (eq erc-join-buffer 'bury)) | ||
| 122 | (should-not erc-reconnect-display) | ||
| 123 | |||
| 124 | ;; FooNet (the server buffer) is not switched to because it's | ||
| 125 | ;; already current (but not shown) when `erc-open' is called. See | ||
| 126 | ;; related conditional guard towards the end of that function. | ||
| 127 | |||
| 128 | (let ((erc-reconnect-display 'buffer)) | ||
| 129 | (erc-scenarios-common--base-reconnect-options | ||
| 130 | (lambda () | ||
| 131 | (pop-to-buffer-same-window "*Messages*") | ||
| 132 | |||
| 133 | (erc-d-t-ensure-for 1 "Server buffer not shown" | ||
| 134 | (not (eq (window-buffer) (get-buffer "FooNet")))) | ||
| 135 | |||
| 136 | (erc-d-t-wait-for 5 "Channel #chan shown when autojoined" | ||
| 137 | (eq (window-buffer) (get-buffer "#chan"))))))) | ||
| 138 | |||
| 139 | (ert-deftest erc-scenarios-base-reconnect-options--default () | ||
| 140 | :tags '(:expensive-test) | ||
| 141 | (should (eq erc-join-buffer 'bury)) | ||
| 142 | (should-not erc-reconnect-display) | ||
| 143 | |||
| 144 | (erc-scenarios-common--base-reconnect-options | ||
| 145 | |||
| 146 | (lambda () | ||
| 147 | (pop-to-buffer-same-window "*Messages*") | ||
| 148 | |||
| 149 | (erc-d-t-ensure-for 1 "Server buffer not shown" | ||
| 150 | (not (eq (window-buffer) (get-buffer "FooNet")))) | ||
| 151 | |||
| 152 | (erc-d-t-ensure-for 3 "Channel #chan not shown" | ||
| 153 | (not (eq (window-buffer) (get-buffer "#chan")))) | ||
| 154 | |||
| 155 | (eq (window-buffer) (messages-buffer))))) | ||
| 156 | |||
| 157 | ;; Upon reconnecting, playback for channel and target buffers is | 68 | ;; Upon reconnecting, playback for channel and target buffers is |
| 158 | ;; routed correctly. Autojoin is irrelevant here, but for the | 69 | ;; routed correctly. Autojoin is irrelevant here, but for the |
| 159 | ;; skeptical, see `erc-scenarios-common--join-network-id', which | 70 | ;; skeptical, see `erc-scenarios-common--join-network-id', which |
diff --git a/test/lisp/erc/resources/erc-d/erc-d-tests.el b/test/lisp/erc/resources/erc-d/erc-d-tests.el index a501cd55494..0ae70087fd1 100644 --- a/test/lisp/erc/resources/erc-d/erc-d-tests.el +++ b/test/lisp/erc/resources/erc-d/erc-d-tests.el | |||
| @@ -674,7 +674,7 @@ nonzero for this to work." | |||
| 674 | (ert-deftest erc-d-run-linger () | 674 | (ert-deftest erc-d-run-linger () |
| 675 | :tags '(:unstable :expensive-test) | 675 | :tags '(:unstable :expensive-test) |
| 676 | (erc-d-tests-with-server (dumb-s _) linger | 676 | (erc-d-tests-with-server (dumb-s _) linger |
| 677 | (with-current-buffer (erc-d-t-wait-for 6 (get-buffer "#chan")) | 677 | (with-current-buffer (erc-d-t-wait-for 10 (get-buffer "#chan")) |
| 678 | (erc-d-t-search-for 2 "hey")) | 678 | (erc-d-t-search-for 2 "hey")) |
| 679 | (with-current-buffer (process-buffer dumb-s) | 679 | (with-current-buffer (process-buffer dumb-s) |
| 680 | (erc-d-t-search-for 2 "Lingering for 1.00 seconds")) | 680 | (erc-d-t-search-for 2 "Lingering for 1.00 seconds")) |
diff --git a/test/lisp/erc/resources/erc-d/erc-d.el b/test/lisp/erc/resources/erc-d/erc-d.el index f4491bbb834..43f6552f0f3 100644 --- a/test/lisp/erc/resources/erc-d/erc-d.el +++ b/test/lisp/erc/resources/erc-d/erc-d.el | |||
| @@ -299,9 +299,10 @@ PROCESS should be a client connection or a server network process." | |||
| 299 | (concat (format-time-string "%s.%N: ") | 299 | (concat (format-time-string "%s.%N: ") |
| 300 | ,format-string) | 300 | ,format-string) |
| 301 | ,format-string)) | 301 | ,format-string)) |
| 302 | (want-insert (and ,process erc-d--in-process))) | 302 | (want-insert (and ,process erc-d--in-process)) |
| 303 | (when want-insert | 303 | (buffer (process-buffer (process-get ,process :server)))) |
| 304 | (with-current-buffer (process-buffer (process-get ,process :server)) | 304 | (when (and want-insert (buffer-live-p buffer)) |
| 305 | (with-current-buffer buffer | ||
| 305 | (goto-char (point-max)) | 306 | (goto-char (point-max)) |
| 306 | (insert (concat (format ,format-string ,@args) "\n")))) | 307 | (insert (concat (format ,format-string ,@args) "\n")))) |
| 307 | (when (or erc-d--m-debug (not want-insert)) | 308 | (when (or erc-d--m-debug (not want-insert)) |