* lisp/erc/erc-join.el (erc-autojoin-channels-delayed): Only cancel
`erc--autojoin-timer' in the server buffer in which it's local. After
Emacs 28 brought commit fc66ec3322 "Prefer
defvar-local in erc", customizing `erc-autojoin-timing' to `ident' led
to ERC emitting redundant JOINs before `erc-autojoin--join' was factored
out. Additionally, don't bother binding options around the call to
`erc-autojoin-channels' to shape its behavior, preferring instead to
call the internal workhorse function directly. Ever since bug#5521
introduced those options, the logic in `erc-autojoin-channels' has
ignored `erc-autojoin-delay' anyway, so long as `erc-autojoin-timing'
isn't `ident'. This change may break third party advice.
(erc-autojoin-after-ident): Restore code to cancel timer. It was
erroneously deleted in 959fbcf34b "favor
network identities in erc-join".
* test/lisp/erc/erc-join-tests.el: Require erc-tests-common atop file so
tests can take advantage of common utilities.
(erc-autojoin-channels--connect): Replace with a function and three
separate tests.
(erc-join-tests--autojoin-channels-connect): New function.
(erc-autojoin-channels/server, erc-autojoin-channels/network)
(erc-autojoin-channels/nomatch): New tests.
(erc-autojoin-channels--delay): Replace with a function and three
separate tests. Remove guard to skip test on Solaris.
(erc-join-tests--autojoin-channels-ident): New function.
(erc-autojoin-channels-delayed/server)
(erc-autojoin-channels-delayed/network)
(erc-autojoin-channels-delayed/nomatch): New tests.
(erc-autojoin-channels--ident): Replace with function and two separate
tests.
(erc-join-tests--autojoin-after-ident): New function.
(erc-autojoin-after-ident/server)
(erc-autojoin-after-ident/network): New tests.
(erc-join-tests--autojoin-add--common)
(erc-join-tests--autojoin-add): Rename former to latter.
(erc-autojoin-add--network)
(erc-autojoin-add--network-extended-syntax)
(erc-autojoin-add--network-id): Adjust arguments to fixture.
(erc-autojoin-add--server): Use common utils.
(erc-join-tests--autojoin-remove--common)
(erc-join-tests--autojoin-remove): Rename former to latter.
(erc-autojoin-remove--network)
(erc-autojoin-remove--network-id): Adjust args for fixture.
(erc-autojoin-remove--server): Use common utils.
* test/lisp/erc/erc-scenarios-join-timing.el: New file.
* test/lisp/erc/resources/erc-scenarios-common.el
(erc-scenarios-common--run-in-term): In subprocess, don't use failure
tally as exit status unless body form succeeds.
* test/lisp/erc/resources/erc-tests-common.el
(erc-tests-common-init-server-proc): Use `make-process' instead of
`start-process'.
(erc-tests-common-make-server-buf): Use `erc-server-current-nick' to
create the `erc-networks--id' as a `erc-networks--id-qualifying'
instance, which is more realistic than a "fixed" variant.
* test/lisp/erc/resources/join/timing/connect-both.eld: New file.
* test/lisp/erc/resources/join/timing/ident-both.eld: New file.
(Bug#79017)
* lisp/erc/erc-join.el (erc-autojoin-server-match): Favor network
identities, falling back on old definition.
(erc-autojoin--join): Add new helper containing common code from
hookees `erc-autojoin-after-ident' and `erc-autojoin-channels'.
(erc-autojoin-after-ident, erc-autojoin-channels): No longer make a
point of returning nil because the hooks they're registered on,
`erc-nickserv-identified-hook' and `erc-after-connect', don't stop on
success.
(erc-autojoin--mutate): Add helper for `erc-autojoin-add' and
`erc-autojoin-remove'.
(erc-autojoin-add, erc-autojoin-remove): Favor given network
identities, over networks, when matching keys for
`erc-autojoin-channels-alist'.
* test/lisp/erc/erc-scenarios-base-reconnect.el: New file.
* test/lisp/erc/erc-scenarios-join-netid-newcmd-id.el: New file.
* test/lisp/erc/erc-scenarios-join-netid-newcmd.el: New file.
* test/lisp/erc/erc-scenarios-join-netid-recon-id.el: New file.
* test/lisp/erc/erc-scenarios-join-netid-recon.el: New file.
* test/lisp/erc/resources/erc-scenarios-common.el: New file.
* test/lisp/erc/resources/join/legacy/foonet.eld: New file.
* test/lisp/erc/resources/join/network-id/barnet.eld: New file.
* test/lisp/erc/resources/join/network-id/foonet-again.eld: New file.
* test/lisp/erc/resources/join/network-id/foonet.eld: New file.
* test/lisp/erc/resources/join/reconnect/foonet-again.eld: New file.
* test/lisp/erc/resources/join/reconnect/foonet.eld: New file.