summaryrefslogtreecommitdiff
path: root/test/lisp/erc/erc-tests.el
diff options
context:
space:
mode:
authorF. Jason Park <jp@neverwas.me>2021-09-16 15:35:55 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2021-09-16 15:35:55 +0200
commit426c5fdfb240f101c3f3ee6e001684c1f82c790f (patch)
treee7b29259bc63fb05f8c42505b82403000e1e8266 /test/lisp/erc/erc-tests.el
parentfb2971e18e2d945574a1ff53cae39b861e974989 (diff)
downloademacs-426c5fdfb240f101c3f3ee6e001684c1f82c790f.tar.gz
emacs-426c5fdfb240f101c3f3ee6e001684c1f82c790f.tar.bz2
emacs-426c5fdfb240f101c3f3ee6e001684c1f82c790f.zip
Change the erc debug logging format to be more repeatable
* erc.el (erc-debug-irc-protocol): Fix line-ending mismatch between incoming and outgoing logger lines without changing interface. Do this by adding carriage returns to the latter to improve machine readability. Change printed peer labels to most accurately reflect logical endpoints. (erc-debug-irc-protocol-time-format): Add new variable to support timestamps in protocol logger output. (erc-debug-irc-protocol-version): Add new variable to help tooling track logging format independent of ERC and Emacs versions. (erc-toggle-debug-irc-protocol): Add headers to protocol-log buffer to aid future bug-reproduction tools. Clean up overlong lines (bug#50009).
Diffstat (limited to 'test/lisp/erc/erc-tests.el')
-rw-r--r--test/lisp/erc/erc-tests.el35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el
index 0533d044911..22f62a35c7e 100644
--- a/test/lisp/erc/erc-tests.el
+++ b/test/lisp/erc/erc-tests.el
@@ -192,3 +192,38 @@
(should (looking-at "abc")))))
(when noninteractive
(kill-buffer "*#fake*")))
+
+(ert-deftest erc-log-irc-protocol ()
+ (should-not erc-debug-irc-protocol)
+ (with-temp-buffer
+ (setq erc-server-process (start-process "fake" (current-buffer) "true")
+ erc-server-current-nick "tester"
+ erc-session-server "myproxy.localhost"
+ erc-session-port 6667)
+ (let ((inhibit-message noninteractive))
+ (erc-toggle-debug-irc-protocol)
+ (erc-log-irc-protocol "PASS changeme\r\n" 'outgoing)
+ (setq erc-server-announced-name "irc.gnu.org")
+ (erc-log-irc-protocol ":irc.gnu.org 001 tester :Welcome")
+ (erc-log-irc-protocol ":irc.gnu.org 002 tester :Your host is irc.gnu.org")
+ (setq erc-network 'FooNet)
+ (erc-log-irc-protocol ":irc.gnu.org 422 tester :MOTD missing")
+ (setq erc-network 'BarNet)
+ (erc-log-irc-protocol ":irc.gnu.org 221 tester +i")
+ (set-process-query-on-exit-flag erc-server-process nil)))
+ (with-current-buffer "*erc-protocol*"
+ (goto-char (point-min))
+ (search-forward "Version")
+ (search-forward "\r\n\r\n")
+ (search-forward "myproxy.localhost:6667 >> PASS" (line-end-position))
+ (forward-line)
+ (search-forward "irc.gnu.org << :irc.gnu.org 001" (line-end-position))
+ (forward-line)
+ (search-forward "irc.gnu.org << :irc.gnu.org 002" (line-end-position))
+ (forward-line)
+ (search-forward "FooNet << :irc.gnu.org 422" (line-end-position))
+ (forward-line)
+ (search-forward "BarNet << :irc.gnu.org 221" (line-end-position)))
+ (when noninteractive
+ (kill-buffer "*erc-protocol*")
+ (should-not erc-debug-irc-protocol)))