summaryrefslogtreecommitdiff
path: root/test/lisp/erc/resources
diff options
context:
space:
mode:
Diffstat (limited to 'test/lisp/erc/resources')
-rw-r--r--test/lisp/erc/resources/dcc/chat/accept-dcc.eld3
-rw-r--r--test/lisp/erc/resources/dcc/chat/accept.eld23
-rw-r--r--test/lisp/erc/resources/erc-d/erc-d-tests.el27
-rw-r--r--test/lisp/erc/resources/erc-d/erc-d.el68
-rw-r--r--test/lisp/erc/resources/erc-d/resources/foreign.eld5
5 files changed, 98 insertions, 28 deletions
diff --git a/test/lisp/erc/resources/dcc/chat/accept-dcc.eld b/test/lisp/erc/resources/dcc/chat/accept-dcc.eld
new file mode 100644
index 00000000000..23828a8115e
--- /dev/null
+++ b/test/lisp/erc/resources/dcc/chat/accept-dcc.eld
@@ -0,0 +1,3 @@
+;; -*- mode: lisp-data; -*-
+((open 10 "Hi")
+ (0 "Hola"))
diff --git a/test/lisp/erc/resources/dcc/chat/accept.eld b/test/lisp/erc/resources/dcc/chat/accept.eld
new file mode 100644
index 00000000000..a23e9580bcc
--- /dev/null
+++ b/test/lisp/erc/resources/dcc/chat/accept.eld
@@ -0,0 +1,23 @@
+;; -*- mode: lisp-data; -*-
+((pass 1 "PASS :changeme"))
+((nick 1 "NICK tester"))
+((user 1 "USER user 0 * :tester")
+ (0 ":irc.foonet.org 001 tester :Welcome to the foonet IRC Network tester")
+ (0 ":irc.foonet.org 002 tester :Your host is irc.foonet.org, running version oragono-2.6.0-7481bf0385b95b16")
+ (0 ":irc.foonet.org 003 tester :This server was created Mon, 31 May 2021 09:56:24 UTC")
+ (0 ":irc.foonet.org 004 tester irc.foonet.org oragono-2.6.0-7481bf0385b95b16 BERTZios CEIMRUabefhiklmnoqstuv Iabefhkloqv")
+ (0 ":irc.foonet.org 005 tester AWAYLEN=390 BOT=B CASEMAPPING=ascii CHANLIMIT=#:100 CHANMODES=Ibe,k,fl,CEMRUimnstu CHANNELLEN=64 CHANTYPES=# ELIST=U EXCEPTS EXTBAN=,m FORWARD=f INVEX KICKLEN=390 :are supported by this server")
+ (0 ":irc.foonet.org 005 tester MAXLIST=beI:60 MAXTARGETS=4 MODES MONITOR=100 NETWORK=foonet NICKLEN=32 PREFIX=(qaohv)~&@%+ STATUSMSG=~&@%+ TARGMAX=NAMES:1,LIST:1,KICK:1,WHOIS:1,USERHOST:10,PRIVMSG:4,TAGMSG:4,NOTICE:4,MONITOR:100 TOPICLEN=390 UTF8MAPPING=rfc8265 UTF8ONLY WHOX :are supported by this server")
+ (0 ":irc.foonet.org 005 tester draft/CHATHISTORY=100 :are supported by this server")
+ (0 ":irc.foonet.org 251 tester :There are 0 users and 4 invisible on 1 server(s)")
+ (0 ":irc.foonet.org 252 tester 0 :IRC Operators online")
+ (0 ":irc.foonet.org 254 tester 2 :channels formed")
+ (0 ":irc.foonet.org 255 tester :I have 4 clients and 0 servers")
+ (0 ":irc.foonet.org 265 tester 4 4 :Current local users 4, max 4")
+ (0 ":irc.foonet.org 266 tester 4 4 :Current global users 4, max 4")
+ (0 ":irc.foonet.org 422 tester :MOTD File is missing"))
+
+((mode-user 1.2 "MODE tester +i")
+ ;; No mode answer
+ (0 ":irc.foonet.org NOTICE tester :This server is in debug mode and is logging all user I/O. If you do not wish for everything you send to be readable by the server owner(s), please disconnect.")
+ (0.2 ":dummy!~u@34n9brushbpj2.irc PRIVMSG tester :\C-aDCC CHAT chat 2130706433 " port "\C-a"))
diff --git a/test/lisp/erc/resources/erc-d/erc-d-tests.el b/test/lisp/erc/resources/erc-d/erc-d-tests.el
index 21005cd7600..357bc48b088 100644
--- a/test/lisp/erc/resources/erc-d/erc-d-tests.el
+++ b/test/lisp/erc/resources/erc-d/erc-d-tests.el
@@ -1343,4 +1343,31 @@ DIALOGS are symbols representing the base names of dialog files in
(kill-buffer dumb-server-buffer)))
(delete-file sock))))
+(ert-deftest erc-d-run-direct-foreign-protocol ()
+ :tags '(:expensive-test)
+ (let* ((server (erc-d-run "localhost" t "erc-d-server" 'foreign
+ :ending "\n"))
+ (server-buffer (get-buffer "*erc-d-server*"))
+ (client-buffer (get-buffer-create "*erc-d-client*"))
+ client)
+ (with-current-buffer server-buffer (erc-d-t-search-for 4 "Starting"))
+ (setq client (make-network-process
+ :buffer client-buffer
+ :name "erc-d-client"
+ :family 'ipv4
+ :noquery t
+ :coding 'binary
+ :service (process-contact server :service)
+ :host "localhost"))
+ (process-send-string client "ONE one\n")
+ (with-current-buffer client-buffer
+ (erc-d-t-search-for 5 "echo ONE one"))
+ (process-send-string client "TWO two\n")
+ (with-current-buffer client-buffer
+ (erc-d-t-search-for 2 "echo TWO two"))
+ (erc-d-t-wait-for 2 "server death" (not (process-live-p server)))
+ (when noninteractive
+ (kill-buffer client-buffer)
+ (kill-buffer server-buffer))))
+
;;; erc-d-tests.el ends here
diff --git a/test/lisp/erc/resources/erc-d/erc-d.el b/test/lisp/erc/resources/erc-d/erc-d.el
index ee9b6a7fec9..d6082227c52 100644
--- a/test/lisp/erc/resources/erc-d/erc-d.el
+++ b/test/lisp/erc/resources/erc-d/erc-d.el
@@ -136,6 +136,9 @@ Only relevant when starting a server with `erc-d-run'.")
Possibly used by overriding handlers, like the one for PING, and/or
dialog templates for the sender portion of a reply message.")
+(defvar erc-d-line-ending "\r\n"
+ "Protocol line delimiter for sending and receiving.")
+
(defvar erc-d-linger-secs nil
"Seconds to wait before quitting for all dialogs.
For more granular control, use the provided LINGER `rx' variable (alone)
@@ -249,6 +252,7 @@ return a replacement.")
(mat-h (copy-sequence (process-get process :dialog-match-handlers)))
(fqdn (copy-sequence (process-get process :dialog-server-fqdn)))
(vars (copy-sequence (process-get process :dialog-vars)))
+ (ending (process-get process :dialog-ending))
(dialog (make-erc-d-dialog :name name
:process process
:queue (make-ring 5)
@@ -263,6 +267,8 @@ return a replacement.")
(erc-d-dialog-hunks dialog) reader)
;; Add reverse link, register client, launch
(process-put process :dialog dialog)
+ (process-put process :ending ending)
+ (process-put process :ending-regexp (rx-to-string `(+ ,ending)))
(push process erc-d--clients)
(erc-d--command-refresh dialog nil)
(erc-d--on-request process)))
@@ -311,7 +317,7 @@ PROCESS should be a client connection or a server network process."
(name (erc-d-dialog-name (process-get ,process :dialog))))
(if ,outbound
(erc-d--m process "-> %s:%s %s" name id ,string)
- (dolist (line (split-string ,string "\r\n"))
+ (dolist (line (split-string ,string (process-get process :ending)))
(erc-d--m process "<- %s:%s %s" name id line)))))
(defun erc-d--log-process-event (server process msg)
@@ -320,7 +326,7 @@ PROCESS should be a client connection or a server network process."
(defun erc-d--send (process string)
"Send STRING to PROCESS peer."
(erc-d--log process string 'outbound)
- (process-send-string process (concat string "\r\n")))
+ (process-send-string process (concat string (process-get process :ending))))
(define-inline erc-d--fuzzy-p (exchange)
(inline-letevals (exchange)
@@ -442,9 +448,10 @@ This will start the teardown for DIALOG."
"Handle input received from peer.
PROCESS represents a client peer connection and STRING is a raw request
including line delimiters."
- (let ((queue (erc-d-dialog-queue (process-get process :dialog))))
+ (let ((queue (erc-d-dialog-queue (process-get process :dialog)))
+ (delim (process-get process :ending-regexp)))
(setq string (concat (process-get process :stashed-input) string))
- (while (and string (string-match (rx (+ "\r\n")) string))
+ (while (and string (string-match delim string))
(let ((line (substring string 0 (match-beginning 0))))
(setq string (unless (= (match-end 0) (length string))
(substring string (match-end 0))))
@@ -913,35 +920,40 @@ Pass HOST and SERVICE directly to `make-network-process'. When present,
use string SERVER-NAME for the server-process name as well as that of
its buffer (w. surrounding asterisks). When absent, do the same with
`erc-d-server-name'. When running \"in process,\" return the server
-process, otherwise sleep for the duration of the server process.
+process; otherwise sleep until it dies.
A dialog must be a symbol matching the base name of a dialog file in
-`erc-d-u-canned-dialog-dir'.
-
-The variable `erc-d-tmpl-vars' determines the common members of the
-`erc-d--render-entries' ENTRIES param. Variables `erc-d-server-fqdn'
-and `erc-d-linger-secs' determine the `erc-d-dialog' items
-`:server-fqdn' and `:linger-secs' for all client processes.
-
-The variable `erc-d-tmpl-vars' can be used to initialize the
-process's `erc-d-dialog' vars item."
+`erc-d-u-canned-dialog-dir'. Global variables `erc-d-server-fqdn',
+`erc-d-linger-secs', and `erc-d-tmpl-vars' determine the process's
+`erc-d-dialog' fields `:server-fqdn', `:linger-secs', and `:vars',
+respectively. The latter may also be populated via keyword pairs
+appearing among DIALOGS."
(when (and server-name (symbolp server-name))
(push server-name dialogs)
(setq server-name nil))
- (let (loaded)
- (dolist (dialog (nreverse dialogs))
- (let ((reader (erc-d-u--canned-load-dialog dialog)))
- (when erc-d--slow-mo
- (setq reader (erc-d-u--rewrite-for-slow-mo erc-d--slow-mo reader)))
- (push (cons (erc-d-u--normalize-canned-name dialog) reader) loaded)))
- (setq dialogs loaded))
- (erc-d--start host service (or server-name erc-d-server-name)
- :dialog-dialogs dialogs
- :dialog-vars erc-d-tmpl-vars
- :dialog-linger-secs erc-d-linger-secs
- :dialog-server-fqdn erc-d-server-fqdn
- :dialog-match-handlers (erc-d-u--unkeyword
- erc-d-match-handlers)))
+ (let (loaded kwds defaults args)
+ (while dialogs
+ (if-let* ((dlog (pop dialogs))
+ ((keywordp dlog)))
+ (progn (push (pop dialogs) kwds) (push dlog kwds))
+ (let ((reader (erc-d-u--canned-load-dialog dlog)))
+ (when erc-d--slow-mo
+ (setq reader (erc-d-u--rewrite-for-slow-mo erc-d--slow-mo reader)))
+ (push (cons (erc-d-u--normalize-canned-name dlog) reader) loaded))))
+ (setq kwds (erc-d-u--unkeyword kwds)
+ defaults `((ending . ,erc-d-line-ending)
+ (server-fqdn . ,erc-d-server-fqdn)
+ (linger-secs . ,erc-d-linger-secs)
+ (vars . ,(or (plist-get kwds 'tmpl-vars) erc-d-tmpl-vars))
+ (dialogs . ,(nreverse loaded)))
+ args (list :dialog-match-handlers
+ (erc-d-u--unkeyword (or (plist-get kwds 'match-handlers)
+ erc-d-match-handlers))))
+ (pcase-dolist (`(,var . ,def) defaults)
+ (push (or (plist-get kwds var) def) args)
+ (push (intern (format ":dialog-%s" var)) args))
+ (apply #'erc-d--start host service (or server-name erc-d-server-name)
+ args)))
(defun erc-d-serve ()
"Start serving canned dialogs from the command line.
diff --git a/test/lisp/erc/resources/erc-d/resources/foreign.eld b/test/lisp/erc/resources/erc-d/resources/foreign.eld
new file mode 100644
index 00000000000..64a5dca8b10
--- /dev/null
+++ b/test/lisp/erc/resources/erc-d/resources/foreign.eld
@@ -0,0 +1,5 @@
+;;; -*- mode: lisp-data -*-
+((one 5 "ONE one")
+ (0 "echo ONE one"))
+((two 5 "TWO two")
+ (0 "echo TWO two"))