aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorF. Jason Park2024-05-08 19:04:13 -0700
committerF. Jason Park2024-05-27 16:39:18 -0700
commit04477cf97be9eb2bb5ae09eff114252864461f05 (patch)
tree07ac197732c45a1cc5e1c808a9f78e83ee3a297e /test
parent75aefe6514854bfdbe2a398cf1b7265012c9a88b (diff)
downloademacs-04477cf97be9eb2bb5ae09eff114252864461f05.tar.gz
emacs-04477cf97be9eb2bb5ae09eff114252864461f05.zip
Tether query rolls to channel membership in ERC
* lisp/erc/erc-backend.el (erc-server-JOIN): Update query membership via `erc--ensure-query-member' when someone else joins a channel. (erc-server-NICK): Update query membership via `erc--ensure-query-member' after someone else changes their nick. (erc-server-PRIVMSG): After printing a query message from some other person, remove their nick's data from the query buffer's user table if they're "untracked," i.e., not a member of a channel. (erc-server-263, erc-server-263-functions): New function and variable, a default response handler and hook for "RPL_TRYAGAIN", which servers send for things like rejecting "WHO" and "WHOX" responses due to rate limiting. (erc-server-311): Fix call to `erc-update-user-nick' so the userhost login component is no longer supplied as the `info' parameter but rather, correctly, as the `login'. (erc--extract-352-full-name): Factor out trailing hop-count and GECOS parsing for use by overriding handlers or those for adjacent numerics. (erc-server-352): Refactor to handle asterisk as `channel' parameter, which indicates a nick rather than a channel target. (erc-server-366): Update membership in all query buffers via `erc--ensure-query-members' after all names have been received. (erc-server-401): Forget a known user completely when the server reports them as nonexistent. * lisp/erc/erc-common.el (erc--get-server-user): New function, a thin wrapper around `erc-get-server-user' for cases were inlining would require declaring symbols not defined in erc-common. * lisp/erc/erc.el (erc-channel-members): Mention that instances are used for query-participant tables as well. (erc--decouple-query-and-channel-membership-p): New variable, a compatibility flag to access pre-5.6 query bookkeeping behavior. (erc--ensure-query-member, erc--ensure-query-members): New functions. (erc-cmd-QUERY): Ensure parties are present in the query buffer's membership table if they're known to be on the server by simple virtue of being present in some joined channel. (erc-message-english-s352-you): New variable. * test/lisp/erc/erc-scenarios-base-query-participants.el (erc-scenarios-base-query-participants) (erc-scenarios-base-query-participants/legacy): Rename former to latter. Enable compat flag to activate legacy query behavior in which channel membership does not impact query membership. (erc-scenarios-base-query-participants/coupled): New test asserting new behavior in which channel membership dictates query membership. (Bug#70928)
Diffstat (limited to 'test')
-rw-r--r--test/lisp/erc/erc-scenarios-base-query-participants.el93
1 files changed, 92 insertions, 1 deletions
diff --git a/test/lisp/erc/erc-scenarios-base-query-participants.el b/test/lisp/erc/erc-scenarios-base-query-participants.el
index 9e9109091ac..30c04974bb6 100644
--- a/test/lisp/erc/erc-scenarios-base-query-participants.el
+++ b/test/lisp/erc/erc-scenarios-base-query-participants.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(ert-deftest erc-scenarios-base-query-participants () 27(ert-deftest erc-scenarios-base-query-participants/legacy ()
28 :tags '(:expensive-test) 28 :tags '(:expensive-test)
29 29
30 (erc-scenarios-common-with-cleanup 30 (erc-scenarios-common-with-cleanup
@@ -32,6 +32,7 @@
32 (erc-server-flood-penalty 0.1) 32 (erc-server-flood-penalty 0.1)
33 (dumb-server (erc-d-run "localhost" t 'legacy)) 33 (dumb-server (erc-d-run "localhost" t 'legacy))
34 (expect (erc-d-t-make-expecter)) 34 (expect (erc-d-t-make-expecter))
35 (erc--decouple-query-and-channel-membership-p t)
35 (port (process-contact dumb-server :service))) 36 (port (process-contact dumb-server :service)))
36 37
37 (ert-info ("Connect to foonet") 38 (ert-info ("Connect to foonet")
@@ -113,5 +114,95 @@
113 (should-not (erc-get-server-user "bob")) ; missing from query 114 (should-not (erc-get-server-user "bob")) ; missing from query
114 (should (erc-get-server-user "dummy")))))) 115 (should (erc-get-server-user "dummy"))))))
115 116
117(ert-deftest erc-scenarios-base-query-participants/coupled ()
118 :tags '(:expensive-test)
119
120 (erc-scenarios-common-with-cleanup
121 ((erc-scenarios-common-dialog "base/query-participants")
122 (erc-server-flood-penalty 0.1)
123 (dumb-server (erc-d-run "localhost" t 'legacy))
124 (expect (erc-d-t-make-expecter))
125 (port (process-contact dumb-server :service)))
126
127 (ert-info ("Connect to foonet")
128 (with-current-buffer (erc :server "127.0.0.1"
129 :port port
130 :nick "tester"
131 :user "tester"
132 :full-name "tester")
133 (funcall expect 10 "This server is in debug mode")
134 (erc-scenarios-common-say "/query bob")))
135
136 (ert-info ("Opening query on untracked user bob doesn't create entry.")
137 (with-current-buffer "bob"
138 (should-not (erc-get-channel-member "bob"))))
139
140 (ert-info ("DM from untracked user also doesn't create a query entry.")
141 (with-current-buffer (erc-d-t-wait-for 10 (get-buffer "dummy"))
142 (funcall expect 10 "<dummy> hi")
143 (should-not (erc-get-channel-member "dummy"))
144 (should-not (erc-get-server-user "dummy"))))
145
146 (with-current-buffer "foonet"
147 (erc-scenarios-common-say "/join #chan"))
148
149 (ert-info ("Members in new chan added to existing query buffers")
150 (with-current-buffer (erc-d-t-wait-for 10 (get-buffer "#chan"))
151 (funcall expect 10 "bob ")) ; bob is present in #chan (353)
152 (with-current-buffer "bob"
153 (should (erc-get-server-user "bob"))
154 ;; Can't assert immediately: must wait until 366 arrives.
155 (erc-d-t-wait-for 10 (erc-get-channel-member "bob"))))
156
157 (ert-info ("Opening query on tracked user creates entry")
158 (with-current-buffer "#chan"
159 (funcall expect 10 " alice") ;; alice is present
160 (erc-scenarios-common-say "hi channel") ; gate
161 (funcall expect 10 "<tester> hi channel")
162 (erc-scenarios-common-say "/query alice"))
163 (with-current-buffer "alice"
164 (should (erc-get-channel-member "alice"))))
165
166 ;; Bob says something.
167 (with-current-buffer "bob"
168 (funcall expect 10 "<bob> hi")
169 (should (erc-get-channel-member "bob")))
170
171 (ert-info ("Query pal parting channel removes them from query")
172 ;; Identical result if they're kicked: they're removed from the
173 ;; server AND their target buffers
174 (with-current-buffer "#chan"
175 (funcall expect 10 "has left")
176 (should-not (erc-get-channel-member "dummy"))
177 (should-not (erc-get-server-user "dummy")))
178 (with-current-buffer "dummy"
179 (should-not (erc-get-channel-member "dummy"))))
180
181 ;; This is unchanged from legacy behavior.
182 (ert-info ("Query pal quitting channel removes them everywhere")
183 (with-current-buffer "#chan"
184 (funcall expect 10 "has quit")
185 (should-not (erc-get-channel-member "bob"))
186 (should-not (erc-get-server-user "bob")))
187 (with-current-buffer "bob"
188 (should-not (erc-get-channel-member "bob"))))
189
190 (ert-info ("Query pal re-joining repopulates query")
191 (with-current-buffer "#chan"
192 (erc-scenarios-common-say "bob gone")
193 (funcall expect 10 "<alice> bob, welcome back!")
194 (should (erc-get-server-user "bob")))
195 (with-current-buffer "bob"
196 (should (erc-get-channel-member "bob"))))
197
198 (ert-info ("Parting removes chan members from server and queries")
199 (with-current-buffer "#chan"
200 (erc-scenarios-common-say "/part")
201 (funcall expect 10 "you have left")
202 (should-not (erc-get-server-user "fsbot"))
203 (should-not (erc-get-server-user "alice")) ; she never said anything
204 (should-not (erc-get-server-user "bob")) ; missing from query
205 (should-not (erc-get-server-user "dummy"))))))
206
116 207
117;;; erc-scenarios-base-query-participants.el ends here 208;;; erc-scenarios-base-query-participants.el ends here