From 34fe0b5c87ca991436d999d451276838529c96c2 Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Mon, 18 Dec 2023 20:50:26 -0800 Subject: Replace some uses of erc-error * lisp/erc/erc-button.el (erc-button--display-error-notice-with-keys-and-warn): Use `erc--lwarn' so the warnings buffer is overridable for testing. * lisp/erc/erc-sasl.el (erc-sasl-mode, erc-sasl-enable): Signal an `error' instead of calling `erc-error', which continues execution. In this special case, the session cannot continue initializing, since connection registration can't reasonably be expected to complete successfully. (erc-sasl--destroy): Don't run `erc-quit-hook', and issue a warning of level `:error' to get users' attention instead of calling `ding'. * lisp/erc/erc-speedbar.el (erc-speedbar--emulate-sidebar-set-window-preserve-size): Don't set window parameters. Doing this basically made `erc-speedbar-toggle-nicknames-window-lock' unusable. (erc-speedbar--toggle-nicknames-sidebar): Manually unlock the window after toggling. (erc-nickbar-mode, erc-nickbar-enable, erc-nickbar-disable): Don't `ding' when called in a non-ERC buffer, and make sure to call `erc-speedbar--ensure' from an ERC buffer. Also, don't disable minor-mode var when speedbar buffer doesn't exist because that doesn't ensure it'll be created the next time around, and users may count on the activation state remaining consistent. (erc-speedbar-toggle-nicknames-window-lock): Make usable from lisp with explicit numeric arg. * lisp/erc/erc-status-sidebar.el (erc-bufbar-mode, erc-bufbar-enable): Only create the side window from an erc-mode buffer to ensure the ratio is preserved when burying the current buffer, e.g., with `custom-buffer-done'. * lisp/erc/erc.el (erc--warnings-buffer-name, erc--lwarn): New function, an analog of `lwarn', that allows for overriding the warnings buffer with the new variable `erc--warnings-buffer-name'. (erc-cmd-SERVER): Add comment. * test/lisp/erc/erc-scenarios-sasl.el (erc-scenarios-sasl--plain-fail): Expect warning instead of error. * test/lisp/erc/erc-scenarios-status-sidebar.el (erc-scenarios-status-sidebar--bufbar): Refresh when interactive as well. * test/lisp/erc/resources/sasl/plain-failed.eld: Expect EOF instead of "CAP END". (Bug#63595) --- test/lisp/erc/erc-scenarios-sasl.el | 34 ++++++++++++++------------- test/lisp/erc/erc-scenarios-status-sidebar.el | 3 +-- test/lisp/erc/resources/sasl/plain-failed.eld | 10 ++++---- 3 files changed, 24 insertions(+), 23 deletions(-) (limited to 'test') diff --git a/test/lisp/erc/erc-scenarios-sasl.el b/test/lisp/erc/erc-scenarios-sasl.el index ab652d72dd2..74075b1aaf3 100644 --- a/test/lisp/erc/erc-scenarios-sasl.el +++ b/test/lisp/erc/erc-scenarios-sasl.el @@ -149,23 +149,25 @@ (erc-modules (cons 'sasl erc-modules)) (erc-sasl-password "wrong") (erc-sasl-mechanism 'plain) - (expect (erc-d-t-make-expecter)) - (buf nil)) + (erc--warnings-buffer-name "*ERC test warnings*") + (warnings-buffer (get-buffer-create erc--warnings-buffer-name)) + (expect (erc-d-t-make-expecter))) - (ert-info ("Connect") - (setq buf (erc :server "127.0.0.1" - :port port - :nick "tester" - :user "tester" - :full-name "tester")) - (let ((err (should-error - (with-current-buffer buf - (funcall expect 20 "Connection failed!"))))) - (should (string-search "please review" (cadr err))) - (with-current-buffer buf - (funcall expect 10 "Opening connection") - (funcall expect 20 "SASL authentication failed") - (should-not (erc-server-process-alive))))))) + (with-current-buffer (erc :server "127.0.0.1" + :port port + :nick "tester" + :user "tester" + :full-name "tester") + (funcall expect 10 "Opening connection") + (funcall expect 20 "SASL authentication failed") + (funcall expect 20 "Connection failed!") + (should-not (erc-server-process-alive))) + + (with-current-buffer warnings-buffer + (funcall expect 10 "please review SASL settings"))) + + (when noninteractive + (should-not (get-buffer "*ERC test warnings*")))) (defun erc-scenarios--common--sasl (mech) (erc-scenarios-common-with-cleanup diff --git a/test/lisp/erc/erc-scenarios-status-sidebar.el b/test/lisp/erc/erc-scenarios-status-sidebar.el index 3a047bf3983..b2b6351e333 100644 --- a/test/lisp/erc/erc-scenarios-status-sidebar.el +++ b/test/lisp/erc/erc-scenarios-status-sidebar.el @@ -64,8 +64,7 @@ (let ((obuf (window-buffer))) ; *scratch* (set-window-buffer (selected-window) "#foo") (erc-d-t-wait-for 5 - (when noninteractive - (erc-status-sidebar-refresh)) + (erc-status-sidebar-refresh) (with-current-buffer "*ERC Status*" (and (marker-position erc-status-sidebar--active-marker) (goto-char erc-status-sidebar--active-marker) diff --git a/test/lisp/erc/resources/sasl/plain-failed.eld b/test/lisp/erc/resources/sasl/plain-failed.eld index 336700290c5..47d13de18e5 100644 --- a/test/lisp/erc/resources/sasl/plain-failed.eld +++ b/test/lisp/erc/resources/sasl/plain-failed.eld @@ -1,16 +1,16 @@ ;; -*- mode: lisp-data; -*- ((cap-req 10 "CAP REQ :sasl")) -((nick 1 "NICK tester")) -((user 1 "USER tester 0 * :tester") +((nick 10 "NICK tester")) +((user 10 "USER tester 0 * :tester") (0.0 ":irc.foonet.org NOTICE * :*** Looking up your hostname...") (0.0 ":irc.foonet.org NOTICE * :*** Found your hostname") (0.0 ":irc.foonet.org CAP * ACK :cap-notify sasl")) -((authenticate-plain 3.2 "AUTHENTICATE PLAIN") +((authenticate-plain 10 "AUTHENTICATE PLAIN") (0.0 ":irc.foonet.org AUTHENTICATE +")) -((authenticate-gimme 3.2 "AUTHENTICATE AHRlc3RlcgB3cm9uZw==") +((authenticate-gimme 10 "AUTHENTICATE AHRlc3RlcgB3cm9uZw==") (0.0 ":irc.foonet.org 900 * * tester :You are now logged in as tester") (0.0 ":irc.foonet.org 904 * :SASL authentication failed: Invalid account credentials")) -((cap-end 3.2 "CAP END")) +((eof 10 EOF)) -- cgit v1.2.3