diff options
author | F. Jason Park <jp@neverwas.me> | 2022-10-27 00:21:10 -0700 |
---|---|---|
committer | F. Jason Park <jp@neverwas.me> | 2022-11-16 21:34:36 -0800 |
commit | e7f2f6cd92b924ecdfcf1356560d4a168546677d (patch) | |
tree | 9c78b73432be06b9ae1c9fab27e4e29b064dd8db /test/lisp/erc | |
parent | 4351fb7161f9490f21281b0b0abfd5854dc2f2ea (diff) | |
download | emacs-e7f2f6cd92b924ecdfcf1356560d4a168546677d.tar.gz emacs-e7f2f6cd92b924ecdfcf1356560d4a168546677d.tar.bz2 emacs-e7f2f6cd92b924ecdfcf1356560d4a168546677d.zip |
Improve auto-reconnect visibility in ERC
* lisp/erc/erc-backend.el (erc--server-reconnect-timer): New variable.
(erc-server-reconnect-function): New user option.
(erc-process-sentinel-2): Display time remaining until next
reconnection attempt. Also remove condition case and move bulk of
else condition logic to `erc-schedule-reconnect'. More importantly,
no longer set `erc--server-reconnecting here').
(erc-server-connect): Initialize `erc--server-reconnect-timer' to nil.
(erc-server-reconnect): Set `erc-server--reconnecting' here.
(erc--mode-line-process-reconnecting): New constant to store value for
"reconnect" state of `mode-line-process'.
(erc--cancel-auto-reconnect-timer): New function to cancel
auto-reconnect timer and print message.
(erc-schedule-reconnect): New function for scheduling another
reconnect attempt.
* lisp/erc/erc.el (erc-open): Only update mode line for target
buffers. For server buffers, let `erc-login' and/or process sentinels
take care of it.
(erc--cmd-reconnect, erc-cmd-RECONNECT): Rename latter to former, a
new function, but repurpose existing to recognize newly allowed
additional arguments and act accordingly. In new internal function,
cancel an existing auto-reconnect timer, if any, before proceeding.
Defer to `erc-server-reconnect' to set `erc--server-reconnecting'.
Fix `with-suppressed-warnings' form.
(erc-update-mode-line-buffer): Show "reconnecting in Ns" for
`mode-line-process' when awaiting an automatic reconnect attempt.
(erc-message-english-reconnecting,
erc-message-english-reconnect-canceled): Add new message functions to
English catalog.
* lisp/erc/erc-pcomplete.el (pcomplete/erc-mode/RECONNECT): Perform
completion for newly subcommand-aware `erc-cmd-RECONNECT'.
* lisp/erc/erc-scenarios-base-reconnect
(erc-scenarios-base-cancel-reconnect): Add new test case for canceling
reconnect timers. (Bug#58840.)
Diffstat (limited to 'test/lisp/erc')
-rw-r--r-- | test/lisp/erc/erc-scenarios-base-reconnect.el | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/test/lisp/erc/erc-scenarios-base-reconnect.el b/test/lisp/erc/erc-scenarios-base-reconnect.el index 49298dc5942..8762f33b303 100644 --- a/test/lisp/erc/erc-scenarios-base-reconnect.el +++ b/test/lisp/erc/erc-scenarios-base-reconnect.el @@ -224,4 +224,50 @@ (with-current-buffer "#chan" (funcall expect 10 "here comes the lady"))))) + +(ert-deftest erc-scenarios-base-cancel-reconnect () + :tags '(:expensive-test) + (erc-scenarios-common-with-cleanup + ((erc-scenarios-common-dialog "base/reconnect") + (dumb-server (erc-d-run "localhost" t 'timer 'timer 'timer-last)) + (port (process-contact dumb-server :service)) + (expect (erc-d-t-make-expecter)) + (erc-server-auto-reconnect t) + erc-autojoin-channels-alist + erc-server-buffer) + + (ert-info ("Connect to foonet") + (setq erc-server-buffer (erc :server "127.0.0.1" + :port port + :nick "tester" + :password "changeme" + :full-name "tester")) + (with-current-buffer erc-server-buffer + (should (string= (buffer-name) (format "127.0.0.1:%d" port))))) + + (ert-info ("Two connection attempts, all stymied") + (with-current-buffer erc-server-buffer + (ert-info ("First two attempts behave normally") + (dotimes (n 2) + (ert-info ((format "Initial attempt %d" (1+ n))) + (funcall expect 3 "Opening connection") + (funcall expect 2 "Password incorrect") + (funcall expect 2 "Connection failed!") + (funcall expect 2 "Re-establishing connection")))) + (ert-info ("/RECONNECT cancels timer but still attempts to connect") + (erc-cmd-RECONNECT) + (funcall expect 2 "Canceled") + (funcall expect 3 "Opening connection") + (funcall expect 2 "Password incorrect") + (funcall expect 2 "Connection failed!") + (funcall expect 2 "Re-establishing connection")) + (ert-info ("Explicitly cancel timer") + (erc-cmd-RECONNECT "cancel") + (funcall expect 2 "Canceled") + (erc-d-t-absent-for 1 "Opening connection" (point))))) + + (ert-info ("Server buffer is unique and temp name is absent") + (should (equal (list (get-buffer (format "127.0.0.1:%d" port))) + (erc-scenarios-common-buflist "127.0.0.1")))))) + ;;; erc-scenarios-base-reconnect.el ends here |