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
| | ;;; erc-scenarios-base-reuse-buffers.el --- base-reuse-buffers scenarios -*- lexical-binding: t -*-
;; Copyright (C) 2022 Free Software Foundation, Inc.
;;
;; This file is part of GNU Emacs.
;;
;; This program 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.
;;
;; This program 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 this program. If not, see
;; <https://www.gnu.org/licenses/>.
(require 'ert-x)
(eval-and-compile
(let ((load-path (cons (ert-resource-directory) load-path)))
(require 'erc-scenarios-common)))
(eval-when-compile (require 'erc-join))
(defun erc-scenarios-common--base-reuse-buffers-server-buffers (&optional more)
"Show that `erc-reuse-buffers' doesn't affect server buffers.
Overlaps some with `clash-of-chans/uniquify'. Adapted from
rebuffed/reuseless, described in Bug#48598: 28.0.50; buffer-naming
collisions involving bouncers in ERC. Run EXTRA."
(erc-scenarios-common-with-cleanup
((erc-d-linger-secs 1)
(dumb-server (erc-d-run "localhost" t 'foonet 'barnet))
(port (process-contact dumb-server :service))
erc-autojoin-channels-alist)
(ert-info ("Connect to foonet")
(with-current-buffer (erc :server "127.0.0.1"
:port port
:nick "tester"
:password "foonet:changeme"
:full-name "tester")
(should (string= (buffer-name)
(format "127.0.0.1:%d/127.0.0.1" port)))
(erc-d-t-search-for 12 "marked as being away")))
(ert-info ("Connect to barnet")
(with-current-buffer (erc :server "127.0.0.1"
:port port
:nick "tester"
:password "barnet:changeme"
:full-name "tester")
(should (string= (buffer-name)
(format "127.0.0.1:%d/127.0.0.1<2>" port)))
(erc-d-t-search-for 45 "marked as being away")))
(erc-d-t-wait-for 2 (get-buffer (format "127.0.0.1:%d/127.0.0.1" port)))
(erc-d-t-wait-for 2 (get-buffer (format "127.0.0.1:%d/127.0.0.1<2>" port)))
(ert-info ("Server buffers are unique, no IP-based names")
(should (cdr (erc-scenarios-common-buflist "127.0.0.1"))))
(when more (funcall more port))))
;; XXX maybe remove: already covered many times over by other scenarios
(ert-deftest erc-scenarios-base-reuse-buffers-server-buffers--enabled ()
:tags '(:expensive-test)
(with-suppressed-warnings ((obsolete erc-reuse-buffers))
(should erc-reuse-buffers))
(let ((erc-scenarios-common-dialog "base/reuse-buffers/server-buffers"))
(erc-scenarios-common-with-cleanup
((erc-d-linger-secs 1)
(dumb-server (erc-d-run "localhost" t 'foonet 'barnet))
(port (process-contact dumb-server :service))
erc-autojoin-channels-alist)
(ert-info ("Connect to foonet")
(with-current-buffer (erc :server "127.0.0.1"
:port port
:nick "tester"
:password "foonet:changeme"
:full-name "tester")
(should (string= (buffer-name) (format "127.0.0.1:%d" port)))
(erc-d-t-search-for 12 "marked as being away")))
(ert-info ("Connect to barnet")
(with-current-buffer (erc :server "127.0.0.1"
:port port
:nick "tester"
:password "barnet:changeme"
:full-name "tester")
(should (string= (buffer-name) (format "127.0.0.1:%d" port)))
(erc-d-t-search-for 45 "marked as being away")))
(erc-d-t-wait-for 2 (get-buffer "foonet"))
(erc-d-t-wait-for 2 (get-buffer "barnet"))
(ert-info ("Server buffers are unique, no IP-based names")
(should-not (eq (get-buffer "foonet") (get-buffer "barnet")))
(should-not (erc-scenarios-common-buflist "127.0.0.1"))))))
;; FIXME no sense in running this twice (JOIN variant includes this)
(ert-deftest erc-scenarios-base-reuse-buffers-server-buffers--disabled ()
:tags '(:expensive-test)
(with-suppressed-warnings ((obsolete erc-reuse-buffers))
(should erc-reuse-buffers)
(let ((erc-scenarios-common-dialog "base/reuse-buffers/server-buffers")
erc-reuse-buffers)
(erc-scenarios-common--base-reuse-buffers-server-buffers nil))))
;;; erc-scenarios-base-reuse-buffers.el ends here
|