; Fix erc--channel-modes test on graphical displays
* lisp/erc/erc-fill.el (erc-fill--wrap-insert-merged-post): Use
correct variable.
* test/lisp/erc/erc-scenarios-display-message.el: Mute unrelated noisy
test.
* test/lisp/erc/erc-tests.el (erc--channel-modes): Bail out following
first group of assertions when running on a graphical display.
(erc--channel-modes/graphic-p): New test asserting different values
for graphical terminals. Note that this too is tagged as :unstable.
See also: d2ce30afdd
"; Mark test for erc--update-channel-modes as
:unstable".
This commit is contained in:
parent
36941e9e6a
commit
01e7178917
3 changed files with 50 additions and 2 deletions
|
@ -642,7 +642,7 @@ to be disabled."
|
|||
|
||||
(defun erc-fill--wrap-insert-merged-pre ()
|
||||
"Add `display' property in lieu of speaker."
|
||||
(if erc-fill--wrap-merge-indicator-post
|
||||
(if erc-fill--wrap-merge-indicator-pre
|
||||
(progn
|
||||
(put-text-property (point-min) (point) 'display
|
||||
(car erc-fill--wrap-merge-indicator-pre))
|
||||
|
|
|
@ -57,6 +57,7 @@
|
|||
(funcall expect 10 "*** dummy (~u@rdjcgiwfuwqmc.irc) has quit")
|
||||
(should (eq 'QUIT (get-text-property (match-beginning 0) 'erc-msg)))))
|
||||
|
||||
(erc-cmd-QUIT "")))
|
||||
(with-current-buffer "foonet"
|
||||
(erc-cmd-QUIT ""))))
|
||||
|
||||
;;; erc-scenarios-display-message.el ends here
|
||||
|
|
|
@ -829,15 +829,25 @@
|
|||
(should (equal (erc--channel-modes) '((?k . "h2") (?l . "3") (?t))))
|
||||
(should (equal (erc--channel-modes 3 ",") "klt h2,3"))
|
||||
|
||||
;; The function this tests behaves differently in different
|
||||
;; environments. For example, on one GNU Linux system, it returns
|
||||
;; truncation ellipsis when run interactively. Rather than have
|
||||
;; hard-to-read "nondeterministic" comparisons against sets of
|
||||
;; acceptable values, we use separate tests.
|
||||
(when (display-graphic-p) (ert-pass))
|
||||
|
||||
;; Truncation cache populated and used.
|
||||
(let ((cache (erc--channel-mode-types-shortargs erc--channel-mode-types))
|
||||
first-run)
|
||||
(should (zerop (hash-table-count cache)))
|
||||
(should (equal (erc--channel-modes 1 ",") "klt h,3"))
|
||||
(should (equal (setq first-run (map-pairs cache)) '(((1 ?k "h2") . "h"))))
|
||||
|
||||
;; Second call uses cache.
|
||||
(cl-letf (((symbol-function 'truncate-string-to-width)
|
||||
(lambda (&rest _) (ert-fail "Shouldn't run"))))
|
||||
(should (equal (erc--channel-modes 1 ",") "klt h,3")))
|
||||
|
||||
;; Same key for only entry matches that of first result.
|
||||
(should (pcase (map-pairs cache)
|
||||
((and '(((1 ?k "h2") . "h")) second-run)
|
||||
|
@ -849,6 +859,43 @@
|
|||
(should (equal (erc--channel-modes 1) "klt h 3"))
|
||||
(should (equal (erc--channel-modes 0) "klt "))) ; 2 spaces
|
||||
|
||||
(ert-deftest erc--channel-modes/graphic-p ()
|
||||
:tags '(:unstable)
|
||||
(unless (display-graphic-p) (ert-skip "See non-/graphic-p variant"))
|
||||
|
||||
(erc-tests--set-fake-server-process "sleep" "1")
|
||||
(setq erc--isupport-params (make-hash-table)
|
||||
erc--target (erc--target-from-string "#test")
|
||||
erc-server-parameters
|
||||
'(("CHANMODES" . "eIbq,k,flj,CFLMPQRSTcgimnprstuz")))
|
||||
|
||||
(cl-letf (((symbol-function 'erc-update-mode-line) #'ignore))
|
||||
(erc--update-channel-modes "+bltk" "fool!*@*" "3" "hun2"))
|
||||
|
||||
;; Truncation cache populated and used.
|
||||
(let ((cache (erc--channel-mode-types-shortargs erc--channel-mode-types))
|
||||
first-run)
|
||||
(should (zerop (hash-table-count cache)))
|
||||
(should (equal (erc--channel-modes 2 ",") "klt h…,3" ))
|
||||
(should (equal (setq first-run (map-pairs cache))
|
||||
'(((2 ?k "hun2") . "h…"))))
|
||||
|
||||
;; Second call uses cache.
|
||||
(cl-letf (((symbol-function 'truncate-string-to-width)
|
||||
(lambda (&rest _) (ert-fail "Shouldn't run"))))
|
||||
(should (equal (erc--channel-modes 2 ",") "klt h…,3" )))
|
||||
|
||||
;; Same key for only entry matches that of first result.
|
||||
(should (pcase (map-pairs cache)
|
||||
((and `(((2 ?k "hun2") . "h…")) second-run)
|
||||
(eq (pcase first-run (`((,k . ,_)) k))
|
||||
(pcase second-run (`((,k . ,_)) k)))))))
|
||||
|
||||
;; A max length of 0 is nonsensical anyway, so skip those.
|
||||
(should (equal (erc--channel-modes 3) "klt hu… 3"))
|
||||
(should (equal (erc--channel-modes 2) "klt h… 3"))
|
||||
(should (equal (erc--channel-modes 1) "klt … 3")))
|
||||
|
||||
(ert-deftest erc--update-user-modes ()
|
||||
(let ((erc--user-modes (list ?a)))
|
||||
(should (equal (erc--update-user-modes "+a") '(?a)))
|
||||
|
|
Loading…
Add table
Reference in a new issue