aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorF. Jason Park2022-12-25 21:36:53 -0800
committerF. Jason Park2022-12-28 06:51:38 -0800
commit2ddc480f4417775d6bf8ebcfc27b8cd7fa761a7d (patch)
treec37c55716af7350cd74f3cac577dc9ccd96be8d4 /test
parent19d00fab9aaf28dae6af5786f6e22b8558b10eea (diff)
downloademacs-2ddc480f4417775d6bf8ebcfc27b8cd7fa761a7d.tar.gz
emacs-2ddc480f4417775d6bf8ebcfc27b8cd7fa761a7d.zip
Warn of absent networks module in ERC
* doc/misc/erc.texi: Add linkable note in Modules chapter about some modules being required. Also tweak markup in auth-source section. * etc/ERC-NEWS: Mention the special role of `networks'. * lisp/erc/erc-backend.el (erc--server-post-connect-hook): Add internal hook for core modules to perform post-network-process, pre-protocol config validation even when they haven't been loaded. (erc--register-connection): Run `erc--server-post-connect-hook'. * lisp/erc/erc-networks.el (erc-networks--bouncer-targets, erc-networks-on-MOTD-end): Fix comments and doc strings. Also change former from constant to internal variable in case adjustment needed between releases. (erc-networks--warn-on-connect): New function to warn about the `networks' module being absent from `erc-modules'. This could probably run at any time up to and including when the logical IRC connection is established, but doing so at the process/protocol boundary seems ideal. * lisp/erc/erc-sasl.el (erc--register-connection): Defer to base method instead of calling `erc-login' explicitly. * lisp/erc/erc.el (erc-generate-new-buffer-name): Don't reconcile buffer names when networks module not in play. (erc-format-target-and/or-network): Don't assume networks module loaded. * test/lisp/erc/erc-scenarios-base-unstable.el: (erc-scenarios-networks-no-module): New test. * test/lisp/erc/resources/networks/no-module/basic.eld: New test data file. (Bug#60331.)
Diffstat (limited to 'test')
-rw-r--r--test/lisp/erc/erc-scenarios-base-unstable.el54
-rw-r--r--test/lisp/erc/resources/networks/no-module/basic.eld44
2 files changed, 97 insertions, 1 deletions
diff --git a/test/lisp/erc/erc-scenarios-base-unstable.el b/test/lisp/erc/erc-scenarios-base-unstable.el
index f5b8df6f4a1..e6db40c5efb 100644
--- a/test/lisp/erc/erc-scenarios-base-unstable.el
+++ b/test/lisp/erc/erc-scenarios-base-unstable.el
@@ -24,7 +24,7 @@
24 (let ((load-path (cons (ert-resource-directory) load-path))) 24 (let ((load-path (cons (ert-resource-directory) load-path)))
25 (require 'erc-scenarios-common))) 25 (require 'erc-scenarios-common)))
26 26
27(eval-when-compile (require 'erc-join)) 27(eval-when-compile (require 'erc-join) (require 'warnings))
28 28
29;; Not unstable, but stashed here for now 29;; Not unstable, but stashed here for now
30 30
@@ -132,4 +132,56 @@
132 (not (setq failed (zerop (cl-decf tries))))))) 132 (not (setq failed (zerop (cl-decf tries)))))))
133 (should-not failed))) 133 (should-not failed)))
134 134
135;; The `erc-networks' library has slowly become a hard dependency of
136;; the interactive client since its incorporation in 2006. But its
137;; module, which was added in ERC 5.3 (2008) and thereafter loaded by
138;; default, only became quasi-required in ERC 5.5 (2022). Despite
139;; this, a basic connection should still always succeed, at least long
140;; enough to warn users that their setup is abnormal. Of course,
141;; third-party code intentionally omitting the module will have to
142;; override various erc-server-*-functions to avoid operating in a
143;; degraded state, which has likely been the case for a while.
144
145(ert-deftest erc-scenarios-networks-no-module ()
146 :tags '(:expensive-test)
147 (erc-scenarios-common-with-cleanup
148 ((erc-scenarios-common-dialog "networks/no-module")
149 (erc-server-flood-penalty 0.1)
150 (erc-networks-mode-orig erc-networks-mode)
151 (dumb-server (erc-d-run "localhost" t 'basic))
152 (port (process-contact dumb-server :service))
153 (erc-modules (remq 'networks erc-modules))
154 (warning-suppress-log-types '((erc)))
155 (expect (erc-d-t-make-expecter)))
156
157 (erc-networks-mode -1)
158 (ert-info ("Connect and retain dialed name")
159 (with-current-buffer (erc :server "127.0.0.1"
160 :port port
161 :nick "tester"
162 :user "tester"
163 :full-name "tester")
164 (funcall expect 10 "Required module `networks' not loaded")
165 (funcall expect 10 "This server is in debug mode")
166 ;; Buffer not named after network
167 (should (string= (buffer-name) (format "127.0.0.1:%d" port)))
168 (erc-cmd-JOIN "#chan")))
169
170 (ert-info ("Join #chan, change nick, query op")
171 (with-current-buffer (erc-d-t-wait-for 10 (get-buffer "#chan"))
172 (funcall expect 20 "Even at thy teat thou")
173 (erc-cmd-NICK "dummy")
174 (funcall expect 10 "Your new nickname is dummy")
175 (erc-scenarios-common-say "/msg alice hi")))
176
177 (ert-info ("Switch to query and quit")
178 (with-current-buffer (erc-d-t-wait-for 10 (get-buffer "alice"))
179 (funcall expect 20 "bye"))
180
181 (with-current-buffer (format "127.0.0.1:%d" port)
182 (erc-cmd-QUIT "")
183 (funcall expect 10 "finished")))
184 (when erc-networks-mode-orig
185 (erc-networks-mode +1))))
186
135;;; erc-scenarios-base-unstable.el ends here 187;;; erc-scenarios-base-unstable.el ends here
diff --git a/test/lisp/erc/resources/networks/no-module/basic.eld b/test/lisp/erc/resources/networks/no-module/basic.eld
new file mode 100644
index 00000000000..f1bdbd1219f
--- /dev/null
+++ b/test/lisp/erc/resources/networks/no-module/basic.eld
@@ -0,0 +1,44 @@
1;; -*- mode: lisp-data; -*-
2((nick 10 "NICK tester"))
3((user 1 "USER tester 0 * :tester")
4 (0.00 ":irc.foonet.org 001 tester :Welcome to the foonet IRC Network tester")
5 (0.00 ":irc.foonet.org 002 tester :Your host is irc.foonet.org, running version ergo-v2.8.0")
6 (0.00 ":irc.foonet.org 003 tester :This server was created Mon, 12 Dec 2022 01:25:38 UTC")
7 (0.00 ":irc.foonet.org 004 tester irc.foonet.org ergo-v2.8.0 BERTZios CEIMRUabefhiklmnoqstuv Iabefhkloqv")
8 (0.00 ":irc.foonet.org 005 tester AWAYLEN=390 BOT=B CASEMAPPING=ascii CHANLIMIT=#:100 CHANMODES=Ibe,k,fl,CEMRUimnstu CHANNELLEN=64 CHANTYPES=# ELIST=U EXCEPTS EXTBAN=,m FORWARD=f INVEX KICKLEN=390 :are supported by this server")
9 (0.00 ":irc.foonet.org 005 tester MAXLIST=beI:60 MAXTARGETS=4 MODES MONITOR=100 NETWORK=foonet NICKLEN=32 PREFIX=(qaohv)~&@%+ STATUSMSG=~&@%+ TARGMAX=NAMES:1,LIST:1,KICK:,WHOIS:1,USERHOST:10,PRIVMSG:4,TAGMSG:4,NOTICE:4,MONITOR:100 TOPICLEN=390 UTF8MAPPING=rfc8265 UTF8ONLY WHOX :are supported by this server")
10 (0.01 ":irc.foonet.org 005 tester draft/CHATHISTORY=100 :are supported by this server")
11 (0.00 ":irc.foonet.org 251 tester :There are 0 users and 4 invisible on 1 server(s)")
12 (0.00 ":irc.foonet.org 252 tester 0 :IRC Operators online")
13 (0.00 ":irc.foonet.org 253 tester 0 :unregistered connections")
14 (0.00 ":irc.foonet.org 254 tester 1 :channels formed")
15 (0.00 ":irc.foonet.org 255 tester :I have 4 clients and 0 servers")
16 (0.00 ":irc.foonet.org 265 tester 4 4 :Current local users 4, max 4")
17 (0.01 ":irc.foonet.org 266 tester 4 4 :Current global users 4, max 4")
18 (0.00 ":irc.foonet.org 422 tester :MOTD File is missing"))
19
20((mode 10 "MODE tester +i")
21 (0.00 ":irc.foonet.org 221 tester +i")
22 (0.00 ":irc.foonet.org NOTICE tester :This server is in debug mode and is logging all user I/O. If you do not wish for everything you send to be readable by the server owner(s), please disconnect."))
23
24((join 10 "JOIN #chan")
25 (0.03 ":tester!~u@z5d6jyn8pwxge.irc JOIN #chan"))
26
27((~nick 10 "NICK dummy")
28 (0.01 ":tester!~u@z5d6jyn8pwxge.irc NICK dummy"))
29
30((mode-1 10 "MODE #chan")
31 (0.01 ":irc.foonet.org 353 tester = #chan :@alice bob foonet tester")
32 (0.00 ":irc.foonet.org 366 tester #chan :End of NAMES list")
33 (0.03 ":irc.foonet.org 324 tester #chan +nt")
34 (0.00 ":irc.foonet.org 329 tester #chan 1670808354")
35 (0.00 ":bob!~u@d6ftaiqzk8x2k.irc PRIVMSG #chan :tester, welcome!")
36 (0.00 ":alice!~u@d6ftaiqzk8x2k.irc PRIVMSG #chan :tester, welcome!")
37 (0.03 ":bob!~u@d6ftaiqzk8x2k.irc PRIVMSG #chan :alice: Forbear it therefore; give your cause to heaven.")
38 (0.01 ":alice!~u@d6ftaiqzk8x2k.irc PRIVMSG #chan :bob: Even at thy teat thou hadst thy tyranny."))
39
40((privmsg 10 "PRIVMSG alice :hi")
41 (0.00 ":alice!~u@d6ftaiqzk8x2k.irc PRIVMSG dummy :bye"))
42
43((quit 10 "QUIT :\2ERC\2")
44 (0.03 ":dummy!~u@z5d6jyn8pwxge.irc QUIT :Quit: \2ERC\2"))