unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
blob 917638428798ccc039d3ffe7f4f31ca76d2b25df 6196 bytes (raw)
name: test/lisp/erc/erc-scenarios-base-attach.el 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
 
;;; erc-scenarios-base-attach.el --- Reattach scenarios -*- lexical-binding: t -*-

;; Copyright (C) 2023 Free Software Foundation, Inc.

;; This file is part of GNU Emacs.

;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.

;;; Commentary:

;; See also: `erc-scenarios-base-channel-buffer-revival'.
;;
;; ERC 5.5 silently dropped support for the ancient option
;; `erc-query-on-unjoined-chan-privmsg' because the tangled logic in
;; and around the function `erc-auto-query' made it difficult to
;; divine its purpose.
;;
;; Based on the name, it was thought this option likely involved
;; controlling the creation of query buffers for unsolicited messages
;; from users with whom you don't share a common channel.  However,
;; additional spelunking has recently revealed that it was instead
;; meant to service a feature offered by most bouncers that sends
;; PRIVMSGs directed at a channel you're no longer in and that you
;; haven't received a(nother) JOIN message for.  IOW, this is meant to
;; support the following sequence of events:
;;
;;   1. /detach #chan
;;   2. kill buffer #chan or reconnect in new Emacs session
;;   3. /playbuffer #chan
;;
;; Note that the above slash commands are bouncer-specific aliases.
;;
;; Interested users can find more info by looking at this change set
;; from the ancient CVS repo:
;;
;;   Author:     Mario Lang <mlang@delysid.org>
;;   AuthorDate: Mon Nov 26 18:33:19 2001 +0000
;;
;;   * new function erc-BBDB-NICK to handle nickname anotation ...
;;   * Applied antifuchs/mhp patches, the latest on erc-help, unmodified
;;   * New variable: erc-reuse-buffers default to t.
;;   * Modified erc-generate-new-buffer-name to use it. it checks if
;;     server and port are the same, then one can assume thats the same
;;     channel/query target again.

;;; Code:

(require 'ert-x)
(eval-and-compile
  (let ((load-path (cons (ert-resource-directory) load-path)))
    (require 'erc-scenarios-common)))

(ert-deftest erc-scenarios-base-attach--query-on-unjoined-enabled ()
  :tags '(:expensive-test)
  (should erc-query-on-unjoined-chan-privmsg)

  (erc-scenarios-common-with-cleanup
      ((erc-scenarios-common-dialog "base/channel-buffer-revival")
       (dumb-server (erc-d-run "localhost" t 'reattach))
       (port (process-contact dumb-server :service))
       (erc-server-flood-penalty 0.1)
       (expect (erc-d-t-make-expecter)))

    (ert-info ("Connect to foonet")
      (with-current-buffer (erc :server "127.0.0.1"
                                :port port
                                :nick "tester"
                                :password "tester@vanilla/foonet:changeme"
                                :full-name "tester")
        (should (string= (buffer-name) (format "127.0.0.1:%d" port)))))

    (with-current-buffer (erc-d-t-wait-for 10 (get-buffer "foonet"))
      (erc-cmd-MSG "*status playbuffer #chan"))

    (ert-info ("Playback appears in buffer #chan")
      (with-current-buffer (erc-d-t-wait-for 10 (get-buffer "#chan"))
        (funcall expect 10 "Buffer Playback...")
        (funcall expect 10 "Was I a child")
        (funcall expect 10 "Thou counterfeit'st most lively")
        (funcall expect 10 "Playback Complete")))

    (with-current-buffer "foonet"
      (erc-cmd-MSG "*status attach #chan"))

    (ert-info ("Live output from #chan after more playback")
      (with-current-buffer "#chan"
        (funcall expect 10 "Buffer Playback...")
        (funcall expect 10 "With what it loathes")
        (funcall expect 10 "Not by his breath")
        (funcall expect 10 "Playback Complete")
        (funcall expect 10 "Ay, and the captain")
        (erc-scenarios-common-say "bob: hi")
        (funcall expect 10 "Pawn me to this")))))

(ert-deftest erc-scenarios-base-attach--query-on-unjoined-disabled ()
  :tags '(:expensive-test)
  (should erc-query-on-unjoined-chan-privmsg)

  (erc-scenarios-common-with-cleanup
      ((erc-scenarios-common-dialog "base/channel-buffer-revival")
       (dumb-server (erc-d-run "localhost" t 'reattach))
       (port (process-contact dumb-server :service))
       (erc-server-flood-penalty 0.1)
       (erc-query-on-unjoined-chan-privmsg nil) ; off
       (expect (erc-d-t-make-expecter)))

    (ert-info ("Connect to foonet")
      (with-current-buffer (erc :server "127.0.0.1"
                                :port port
                                :nick "tester"
                                :password "tester@vanilla/foonet:changeme"
                                :full-name "tester")
        (should (string= (buffer-name) (format "127.0.0.1:%d" port)))))

    (with-current-buffer (erc-d-t-wait-for 10 (get-buffer "foonet"))
      (erc-cmd-MSG "*status playbuffer #chan")
      (ert-info ("Playback appears in buffer server buffer")
        (erc-d-t-ensure-for -1 (not (get-buffer "#chan")))
        (funcall expect 10 "Buffer Playback...")
        (funcall expect 10 "Was I a child")
        (funcall expect 10 "Thou counterfeit'st most lively")
        (funcall expect 10 "Playback Complete"))
      (should-not (get-buffer "#chan"))
      (erc-cmd-MSG "*status attach #chan"))

    (ert-info ("Buffer #chan joined")
      (with-current-buffer (erc-d-t-wait-for 10 (get-buffer "#chan"))
        (funcall expect 10 "Buffer Playback...")
        (funcall expect 10 "With what it loathes")
        (funcall expect 10 "Not by his breath")
        (funcall expect 10 "Playback Complete")
        (funcall expect 10 "Ay, and the captain")
        (erc-scenarios-common-say "bob: hi")
        (funcall expect 10 "Pawn me to this")))))

;;; erc-scenarios-base-attach.el ends here

debug log:

solving 91763842879 ...
found 91763842879 in https://yhetil.org/emacs-bugs/87leiuy3cv.fsf__49391.7207860918$1681480660$gmane$org@neverwas.me/ ||
	https://yhetil.org/emacs-bugs/87354tcoyk.fsf__32117.3665857472$1682085876$gmane$org@neverwas.me/

applying [1/1] https://yhetil.org/emacs-bugs/87leiuy3cv.fsf__49391.7207860918$1681480660$gmane$org@neverwas.me/
diff --git a/test/lisp/erc/erc-scenarios-base-attach.el b/test/lisp/erc/erc-scenarios-base-attach.el
new file mode 100644
index 00000000000..91763842879

Checking patch test/lisp/erc/erc-scenarios-base-attach.el...
Applied patch test/lisp/erc/erc-scenarios-base-attach.el cleanly.

skipping https://yhetil.org/emacs-bugs/87leiuy3cv.fsf__49391.7207860918$1681480660$gmane$org@neverwas.me/ for 91763842879
skipping https://yhetil.org/emacs-bugs/87354tcoyk.fsf__32117.3665857472$1682085876$gmane$org@neverwas.me/ for 91763842879
index at:
100644 917638428798ccc039d3ffe7f4f31ca76d2b25df	test/lisp/erc/erc-scenarios-base-attach.el

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).