From e98465e5418497a925e795c358231a4d70d6e5ff Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Wed, 17 Aug 2022 00:00:53 -0700 Subject: [PATCH] Stabilize channels variant of erc-reuse-buffers test * lisp/erc/erc-networks.el (erc-networks--id-sort-buffers): Use `buffer-local-value' instead of `with-current-buffer'. * test/lisp/erc/erc-scenarios-base-reuse-buffers.el (erc-scenarios-common--base-reuse-buffers-channel-buffers): Wait for buffers to be created by server-initiated JOINs. (erc-scenarios-base-reuse-buffers-channel-buffers--disabled): Remove `:unstable' tag. * test/lisp/erc-tests.el (erc-ring-previous-command): Remove unnecessary `goto-char'. --- lisp/erc/erc-networks.el | 4 +-- .../erc/erc-scenarios-base-reuse-buffers.el | 35 ++++++++----------- test/lisp/erc/erc-tests.el | 2 +- 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/lisp/erc/erc-networks.el b/lisp/erc/erc-networks.el index c54b12fcb0b..2c8f8fb72bb 100644 --- a/lisp/erc/erc-networks.el +++ b/lisp/erc/erc-networks.el @@ -996,8 +996,8 @@ Rename the current buffer if its NID has grown." "Return a list of target BUFFERS, newest to oldest." (sort buffers (lambda (a b) - (> (with-current-buffer a (erc-networks--id-ts erc-networks--id)) - (with-current-buffer b (erc-networks--id-ts erc-networks--id)))))) + (> (erc-networks--id-ts (buffer-local-value 'erc-networks--id a)) + (erc-networks--id-ts (buffer-local-value 'erc-networks--id b)))))) ;;;; Buffer association diff --git a/test/lisp/erc/erc-scenarios-base-reuse-buffers.el b/test/lisp/erc/erc-scenarios-base-reuse-buffers.el index f134f3ffb69..8e7e939d046 100644 --- a/test/lisp/erc/erc-scenarios-base-reuse-buffers.el +++ b/test/lisp/erc/erc-scenarios-base-reuse-buffers.el @@ -131,43 +131,38 @@ Adapted from scenario clash-of-chans/uniquify described in Bug#48598: (get-buffer (format "127.0.0.1:%d/127.0.0.1" port))) (server-buffer-bar (get-buffer (format "127.0.0.1:%d/127.0.0.1<2>" port))) - (chan-buffer-foo (get-buffer "#chan/127.0.0.1")) - (chan-buffer-bar (get-buffer "#chan/127.0.0.1<2>")) - (server-process-foo (with-current-buffer server-buffer-foo - erc-server-process)) - (server-process-bar (with-current-buffer server-buffer-bar - erc-server-process))) + (server-process-foo + (buffer-local-value 'erc-server-process server-buffer-foo)) + (server-process-bar + (buffer-local-value 'erc-server-process server-buffer-bar))) (ert-info ("Unique #chan buffers exist") - (let ((chan-bufs (erc-scenarios-common-buflist "#chan")) - (known (list chan-buffer-bar chan-buffer-foo))) - (should (memq (pop chan-bufs) known)) - (should (memq (pop chan-bufs) known)) - (should-not chan-bufs))) + (erc-d-t-wait-for 3 (get-buffer "#chan/127.0.0.1<2>")) + (erc-d-t-wait-for 3 (get-buffer "#chan/127.0.0.1"))) (ert-info ("#chan@foonet is exclusive and not contaminated") - (with-current-buffer chan-buffer-foo + (with-current-buffer "#chan/127.0.0.1" (funcall expect 1 "") (erc-d-t-absent-for 0.1 "") (funcall expect 1 "strength to climb") (should (eq erc-server-process server-process-foo)))) (ert-info ("#chan@barnet is exclusive and not contaminated") - (with-current-buffer chan-buffer-bar + (with-current-buffer "#chan/127.0.0.1<2>" (funcall expect 1 "") (erc-d-t-absent-for 0.1 "") (funcall expect 1 "the loudest noise") (should (eq erc-server-process server-process-bar)))) (ert-info ("Part #chan@foonet") - (with-current-buffer chan-buffer-foo + (with-current-buffer "#chan/127.0.0.1" (erc-d-t-search-for 1 "shake my sword") (erc-cmd-PART "#chan") (funcall expect 3 "You have left channel #chan") (erc-cmd-JOIN "#chan"))) (ert-info ("Part #chan@barnet") - (with-current-buffer chan-buffer-bar + (with-current-buffer "#chan/127.0.0.1<2>" (funcall expect 10 "Arm it in rags") (should (erc-get-channel-user (erc-current-nick))) (erc-cmd-PART "#chan") @@ -179,7 +174,7 @@ Adapted from scenario clash-of-chans/uniquify described in Bug#48598: (get-buffer "#chan/127.0.0.1<3>")) (ert-info ("Activity continues in new, -suffixed #chan@foonet buffer") - (with-current-buffer chan-buffer-foo + (with-current-buffer "#chan/127.0.0.1" (should-not (erc-get-channel-user (erc-current-nick)))) (with-current-buffer "#chan/127.0.0.1<3>" (should (erc-get-channel-user (erc-current-nick))) @@ -194,7 +189,7 @@ Adapted from scenario clash-of-chans/uniquify described in Bug#48598: (get-buffer "#chan/127.0.0.1<4>")) (ert-info ("Activity continues in new, -suffixed #chan@barnet buffer") - (with-current-buffer chan-buffer-bar + (with-current-buffer "#chan/127.0.0.1<2>" (should-not (erc-get-channel-user (erc-current-nick)))) (with-current-buffer "#chan/127.0.0.1<4>" (funcall expect 2 "You have joined channel #chan") @@ -221,12 +216,12 @@ Adapted from scenario clash-of-chans/uniquify described in Bug#48598: (ert-info ("Buffers are exempt from shortening") (kill-buffer "#chan/127.0.0.1<4>") (kill-buffer "#chan/127.0.0.1<3>") - (kill-buffer chan-buffer-bar) + (kill-buffer "#chan/127.0.0.1<2>") (should-not (get-buffer "#chan")) - (should chan-buffer-foo)))) + (should (get-buffer "#chan/127.0.0.1"))))) (ert-deftest erc-scenarios-base-reuse-buffers-channel-buffers--disabled () - :tags '(:expensive-test :unstable) + :tags '(:expensive-test) (with-suppressed-warnings ((obsolete erc-reuse-buffers)) (should erc-reuse-buffers) (let ((erc-scenarios-common-dialog "base/reuse-buffers/channel") diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el index 55efe2fd2d9..b2ed29e80ec 100644 --- a/test/lisp/erc/erc-tests.el +++ b/test/lisp/erc/erc-tests.el @@ -522,7 +522,7 @@ (erc-send-current-line) (should (ring-p erc-input-ring)) (should (zerop (ring-member erc-input-ring "/one"))) ; equal - (should (save-excursion (forward-line -1) (goto-char (pos-bol)) + (should (save-excursion (forward-line -1) (looking-at-p "[*]+ echo: one"))) (should-not erc-input-ring-index) (erc-bol) -- 2.39.2