aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorF. Jason Park2023-11-17 13:26:00 -0800
committerF. Jason Park2023-11-18 12:34:56 -0800
commitcc7e008dce1df9d2472338b1fc3cc766166e9e55 (patch)
treeb4b74a0f0275489a9a2a1fcbdbc5043cb2707a42
parent64174ae148d0d81f232d41ecaaa4de17692cf315 (diff)
downloademacs-cc7e008dce1df9d2472338b1fc3cc766166e9e55.tar.gz
emacs-cc7e008dce1df9d2472338b1fc3cc766166e9e55.zip
Add test for erc-cmd-SQUERY
* lisp/erc/erc-backend.el (erc-message): Revise doc string. * test/lisp/erc/erc-scenarios-base-misc-regressions.el (erc-cmd-MOTD): Move test to another file specifically for slash commands. * test/lisp/erc/erc-scenarios-misc-commands.el: New file. * test/lisp/erc/resources/base/commands/motd.eld: Move file elsewhere. * test/lisp/erc/resources/commands/motd.eld: "New" file, moved here reusing the same Git blob from now deleted subdir base/commands. * test/lisp/erc/resources/commands/squery.eld: New file. (Bug#67209)
-rw-r--r--lisp/erc/erc-backend.el6
-rw-r--r--test/lisp/erc/erc-scenarios-base-misc-regressions.el44
-rw-r--r--test/lisp/erc/erc-scenarios-misc-commands.el94
-rw-r--r--test/lisp/erc/resources/commands/motd.eld (renamed from test/lisp/erc/resources/base/commands/motd.eld)0
-rw-r--r--test/lisp/erc/resources/commands/squery.eld31
5 files changed, 129 insertions, 46 deletions
diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el
index 9281c107d06..66ac9057d75 100644
--- a/lisp/erc/erc-backend.el
+++ b/lisp/erc/erc-backend.el
@@ -1284,8 +1284,10 @@ protection algorithm."
1284 nil #'erc-server-send-queue buffer))))))) 1284 nil #'erc-server-send-queue buffer)))))))
1285 1285
1286(defun erc-message (message-command line &optional force) 1286(defun erc-message (message-command line &optional force)
1287 "Send LINE to the server as a privmsg or a notice. 1287 "Send LINE, possibly expanding a target specifier beforehand.
1288MESSAGE-COMMAND should be either \"PRIVMSG\" or \"NOTICE\". 1288Expect MESSAGE-COMMAND to be an IRC command with a single
1289positional target parameter followed by a trailing parameter.
1290
1289If the target is \",\", the last person you've got a message from will 1291If the target is \",\", the last person you've got a message from will
1290be used. If the target is \".\", the last person you've sent a message 1292be used. If the target is \".\", the last person you've sent a message
1291to will be used." 1293to will be used."
diff --git a/test/lisp/erc/erc-scenarios-base-misc-regressions.el b/test/lisp/erc/erc-scenarios-base-misc-regressions.el
index 42d7653d3ec..85b2c03b6a4 100644
--- a/test/lisp/erc/erc-scenarios-base-misc-regressions.el
+++ b/test/lisp/erc/erc-scenarios-base-misc-regressions.el
@@ -124,48 +124,4 @@ Originally from scenario rebuffed/gapless as explained in Bug#48598:
124 (with-current-buffer (erc-d-t-wait-for 5 (get-buffer "#chan")) 124 (with-current-buffer (erc-d-t-wait-for 5 (get-buffer "#chan"))
125 (erc-d-t-search-for 10 "and be prosperous"))))) 125 (erc-d-t-search-for 10 "and be prosperous")))))
126 126
127;; This defends against a partial regression in which an /MOTD caused
128;; 376 and 422 handlers in erc-networks to run.
129
130(ert-deftest erc-cmd-MOTD ()
131 :tags '(:expensive-test)
132 (erc-scenarios-common-with-cleanup
133 ((erc-scenarios-common-dialog "base/commands")
134 (erc-server-flood-penalty 0.1)
135 (dumb-server (erc-d-run "localhost" t 'motd))
136 (port (process-contact dumb-server :service))
137 (expect (erc-d-t-make-expecter)))
138
139 (ert-info ("Connect to server")
140 (with-current-buffer (erc :server "127.0.0.1"
141 :port port
142 :nick "tester"
143 :full-name "tester")
144 (funcall expect 10 "This is the default Ergo MOTD")
145 (funcall expect 10 "debug mode")))
146
147 (ert-info ("Send plain MOTD")
148 (with-current-buffer "foonet"
149 (erc-cmd-MOTD)
150 (funcall expect -0.2 "Unexpected state detected")
151 (funcall expect 10 "This is the default Ergo MOTD")))
152
153 (ert-info ("Send MOTD with known target")
154 (with-current-buffer "foonet"
155 (erc-scenarios-common-say "/MOTD irc1.foonet.org")
156 (funcall expect -0.2 "Unexpected state detected")
157 (funcall expect 10 "This is the default Ergo MOTD")))
158
159 (ert-info ("Send MOTD with erroneous target")
160 (with-current-buffer "foonet"
161 (erc-scenarios-common-say "/MOTD fake.foonet.org")
162 (funcall expect -0.2 "Unexpected state detected")
163 (funcall expect 10 "No such server")
164 ;; Message may show up before the handler runs.
165 (erc-d-t-wait-for 10
166 (not (local-variable-p 'erc-server-402-functions)))
167 (should-not (local-variable-p 'erc-server-376-functions))
168 (should-not (local-variable-p 'erc-server-422-functions))
169 (erc-cmd-QUIT "")))))
170
171;;; erc-scenarios-base-misc-regressions.el ends here 127;;; erc-scenarios-base-misc-regressions.el ends here
diff --git a/test/lisp/erc/erc-scenarios-misc-commands.el b/test/lisp/erc/erc-scenarios-misc-commands.el
new file mode 100644
index 00000000000..2a36d52b835
--- /dev/null
+++ b/test/lisp/erc/erc-scenarios-misc-commands.el
@@ -0,0 +1,94 @@
1;;; erc-scenarios-misc-commands.el --- Misc commands for ERC -*- 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;; This defends against a partial regression in which an /MOTD caused
28;; 376 and 422 handlers in erc-networks to run.
29
30(ert-deftest erc-scenarios-misc-commands--MOTD ()
31 :tags '(:expensive-test)
32 (erc-scenarios-common-with-cleanup
33 ((erc-scenarios-common-dialog "commands")
34 (erc-server-flood-penalty 0.1)
35 (dumb-server (erc-d-run "localhost" t 'motd))
36 (port (process-contact dumb-server :service))
37 (expect (erc-d-t-make-expecter)))
38
39 (ert-info ("Connect to server")
40 (with-current-buffer (erc :server "127.0.0.1"
41 :port port
42 :nick "tester"
43 :full-name "tester")
44 (funcall expect 10 "This is the default Ergo MOTD")
45 (funcall expect 10 "debug mode")))
46
47 (ert-info ("Send plain MOTD")
48 (with-current-buffer "foonet"
49 (erc-cmd-MOTD)
50 (funcall expect -0.2 "Unexpected state detected")
51 (funcall expect 10 "This is the default Ergo MOTD")))
52
53 (ert-info ("Send MOTD with known target")
54 (with-current-buffer "foonet"
55 (erc-scenarios-common-say "/MOTD irc1.foonet.org")
56 (funcall expect -0.2 "Unexpected state detected")
57 (funcall expect 10 "This is the default Ergo MOTD")))
58
59 (ert-info ("Send MOTD with erroneous target")
60 (with-current-buffer "foonet"
61 (erc-scenarios-common-say "/MOTD fake.foonet.org")
62 (funcall expect -0.2 "Unexpected state detected")
63 (funcall expect 10 "No such server")
64 ;; Message may show up before the handler runs.
65 (erc-d-t-wait-for 10
66 (not (local-variable-p 'erc-server-402-functions)))
67 (should-not (local-variable-p 'erc-server-376-functions))
68 (should-not (local-variable-p 'erc-server-422-functions))
69 (erc-cmd-QUIT "")))))
70
71
72(ert-deftest erc-scenarios-misc-commands--SQUERY ()
73 :tags '(:expensive-test)
74 (erc-scenarios-common-with-cleanup
75 ((erc-scenarios-common-dialog "commands")
76 (erc-server-flood-penalty 0.1)
77 (dumb-server (erc-d-run "localhost" t 'squery))
78 (port (process-contact dumb-server :service))
79 (expect (erc-d-t-make-expecter)))
80
81 (ert-info ("Connect to server")
82 (with-current-buffer (erc :server "127.0.0.1"
83 :port port
84 :nick "tester"
85 :full-name "tester")
86 (funcall expect 10 "Your connection is secure")))
87
88 (ert-info ("Send SQUERY")
89 (with-current-buffer "IRCnet"
90 (erc-scenarios-common-say "/SQUERY alis help list")
91 (funcall expect -0.1 "Incorrect arguments")
92 (funcall expect 10 "See also: HELP EXAMPLES")))))
93
94;;; erc-scenarios-misc-commands.el ends here
diff --git a/test/lisp/erc/resources/base/commands/motd.eld b/test/lisp/erc/resources/commands/motd.eld
index 6d10ee122e2..6d10ee122e2 100644
--- a/test/lisp/erc/resources/base/commands/motd.eld
+++ b/test/lisp/erc/resources/commands/motd.eld
diff --git a/test/lisp/erc/resources/commands/squery.eld b/test/lisp/erc/resources/commands/squery.eld
new file mode 100644
index 00000000000..bcd176e515b
--- /dev/null
+++ b/test/lisp/erc/resources/commands/squery.eld
@@ -0,0 +1,31 @@
1;; -*- mode: lisp-data; -*-
2((nick 10 "NICK tester"))
3((user 10 "USER user 0 * :tester")
4 (0.07 ":ircnet.hostsailor.com 020 * :Please wait while we process your connection.")
5 (0.03 ":ircnet.hostsailor.com 001 tester :Welcome to the Internet Relay Network tester!~user@93.184.216.34")
6 (0.02 ":ircnet.hostsailor.com 002 tester :Your host is ircnet.hostsailor.com, running version 2.11.2p3+0PNv1.06")
7 (0.03 ":ircnet.hostsailor.com 003 tester :This server was created Thu May 20 2021 at 17:13:24 EDT")
8 (0.01 ":ircnet.hostsailor.com 004 tester ircnet.hostsailor.com 2.11.2p3+0PNv1.06 aoOirw abeiIklmnoOpqrRstv")
9 (0.00 ":ircnet.hostsailor.com 005 tester RFC2812 PREFIX=(ov)@+ CHANTYPES=#&!+ MODES=3 CHANLIMIT=#&!+:42 NICKLEN=15 TOPICLEN=255 KICKLEN=255 MAXLIST=beIR:64 CHANNELLEN=50 IDCHAN=!:5 CHANMODES=beIR,k,l,imnpstaqrzZ :are supported by this server")
10 (0.01 ":ircnet.hostsailor.com 005 tester PENALTY FNC EXCEPTS=e INVEX=I CASEMAPPING=ascii NETWORK=IRCnet :are supported by this server")
11 (0.01 ":ircnet.hostsailor.com 042 tester 0PNHANAWX :your unique ID")
12 (0.01 ":ircnet.hostsailor.com 251 tester :There are 18711 users and 2 services on 26 servers")
13 (0.01 ":ircnet.hostsailor.com 252 tester 63 :operators online")
14 (0.01 ":ircnet.hostsailor.com 253 tester 4 :unknown connections")
15 (0.01 ":ircnet.hostsailor.com 254 tester 10493 :channels formed")
16 (0.01 ":ircnet.hostsailor.com 255 tester :I have 933 users, 0 services and 1 servers")
17 (0.01 ":ircnet.hostsailor.com 265 tester 933 1328 :Current local users 933, max 1328")
18 (0.01 ":ircnet.hostsailor.com 266 tester 18711 25625 :Current global users 18711, max 25625")
19 (0.02 ":ircnet.hostsailor.com 375 tester :- ircnet.hostsailor.com Message of the Day - ")
20 (0.01 ":ircnet.hostsailor.com 372 tester :- 17/11/2023 3:08")
21 (0.02 ":ircnet.hostsailor.com 376 tester :End of MOTD command."))
22
23((mode 10 "MODE tester +i")
24 (0.00 ":ircnet.hostsailor.com NOTICE tester :Your connection is secure (SSL/TLS).")
25 (0.01 ":tester MODE tester :+i"))
26
27((squery 10 "SQUERY alis :help list")
28 (0.08 ":Alis@hub.uk NOTICE tester :Searches for a channel")
29 (0.01 ":Alis@hub.uk NOTICE tester :/SQUERY Alis LIST mask [-options]")
30 (0.04 ":Alis@hub.uk NOTICE tester :[...]")
31 (0.01 ":Alis@hub.uk NOTICE tester :See also: HELP EXAMPLES"))