aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/lisp/erc/erc-dcc-tests.el23
-rw-r--r--test/lisp/erc/erc-tests.el46
2 files changed, 62 insertions, 7 deletions
diff --git a/test/lisp/erc/erc-dcc-tests.el b/test/lisp/erc/erc-dcc-tests.el
index f02ddf228a2..a750c96c80f 100644
--- a/test/lisp/erc/erc-dcc-tests.el
+++ b/test/lisp/erc/erc-dcc-tests.el
@@ -99,10 +99,11 @@
99(ert-deftest erc-dcc-handle-ctcp-send--turbo () 99(ert-deftest erc-dcc-handle-ctcp-send--turbo ()
100 (erc-dcc-tests--dcc-handle-ctcp-send t)) 100 (erc-dcc-tests--dcc-handle-ctcp-send t))
101 101
102(defun erc-dcc-tests--erc-dcc-do-GET-command (file &optional sep) 102(defun erc-dcc-tests--erc-dcc-do-GET-command (file &optional sep nuh)
103 (unless nuh (setq nuh "tester!~tester@fake.irc"))
103 (with-temp-buffer 104 (with-temp-buffer
104 (let* ((proc (start-process "fake" (current-buffer) "sleep" "10")) 105 (let* ((proc (start-process "fake" (current-buffer) "sleep" "10"))
105 (elt (list :nick "tester!~tester@fake.irc" 106 (elt (list :nick nuh
106 :type 'GET 107 :type 'GET
107 :peer nil 108 :peer nil
108 :parent proc 109 :parent proc
@@ -110,6 +111,7 @@
110 :port "9899" 111 :port "9899"
111 :file file 112 :file file
112 :size 1405135128)) 113 :size 1405135128))
114 (nic (erc-extract-nick nuh))
113 (erc-dcc-list (list elt)) 115 (erc-dcc-list (list elt))
114 ;; 116 ;;
115 erc-accidental-paste-threshold-seconds 117 erc-accidental-paste-threshold-seconds
@@ -130,7 +132,7 @@
130 (ert-info ("No turbo") 132 (ert-info ("No turbo")
131 (should-not (plist-member elt :turbo)) 133 (should-not (plist-member elt :turbo))
132 (goto-char erc-input-marker) 134 (goto-char erc-input-marker)
133 (insert "/dcc GET tester " (or sep "") (prin1-to-string file)) 135 (insert "/dcc GET " nic " " (or sep "") (prin1-to-string file))
134 (erc-send-current-line) 136 (erc-send-current-line)
135 (should-not (plist-member (car erc-dcc-list) :turbo)) 137 (should-not (plist-member (car erc-dcc-list) :turbo))
136 (should (equal (pop calls) (list elt file proc)))) 138 (should (equal (pop calls) (list elt file proc))))
@@ -138,7 +140,7 @@
138 (ert-info ("Arg turbo in pos 2") 140 (ert-info ("Arg turbo in pos 2")
139 (should-not (plist-member elt :turbo)) 141 (should-not (plist-member elt :turbo))
140 (goto-char erc-input-marker) 142 (goto-char erc-input-marker)
141 (insert "/dcc GET -t tester " (or sep "") (prin1-to-string file)) 143 (insert "/dcc GET -t " nic " " (or sep "") (prin1-to-string file))
142 (erc-send-current-line) 144 (erc-send-current-line)
143 (should (eq t (plist-get (car erc-dcc-list) :turbo))) 145 (should (eq t (plist-get (car erc-dcc-list) :turbo)))
144 (should (equal (pop calls) (list elt file proc)))) 146 (should (equal (pop calls) (list elt file proc))))
@@ -147,7 +149,7 @@
147 (setq elt (plist-put elt :turbo nil) 149 (setq elt (plist-put elt :turbo nil)
148 erc-dcc-list (list elt)) 150 erc-dcc-list (list elt))
149 (goto-char erc-input-marker) 151 (goto-char erc-input-marker)
150 (insert "/dcc GET tester -t " (or sep "") (prin1-to-string file)) 152 (insert "/dcc GET " nic " -t " (or sep "") (prin1-to-string file))
151 (erc-send-current-line) 153 (erc-send-current-line)
152 (should (eq t (plist-get (car erc-dcc-list) :turbo))) 154 (should (eq t (plist-get (car erc-dcc-list) :turbo)))
153 (should (equal (pop calls) (list elt file proc)))) 155 (should (equal (pop calls) (list elt file proc))))
@@ -156,7 +158,7 @@
156 (setq elt (plist-put elt :turbo nil) 158 (setq elt (plist-put elt :turbo nil)
157 erc-dcc-list (list elt)) 159 erc-dcc-list (list elt))
158 (goto-char erc-input-marker) 160 (goto-char erc-input-marker)
159 (insert "/dcc GET tester " (prin1-to-string file) " -t" (or sep "")) 161 (insert "/dcc GET " nic " " (prin1-to-string file) " -t" (or sep ""))
160 (erc-send-current-line) 162 (erc-send-current-line)
161 (should (eq (if sep nil t) (plist-get (car erc-dcc-list) :turbo))) 163 (should (eq (if sep nil t) (plist-get (car erc-dcc-list) :turbo)))
162 (should (equal (pop calls) (if sep nil (list elt file proc))))))))) 164 (should (equal (pop calls) (if sep nil (list elt file proc)))))))))
@@ -165,7 +167,14 @@
165 (erc-dcc-tests--erc-dcc-do-GET-command "foo.bin") 167 (erc-dcc-tests--erc-dcc-do-GET-command "foo.bin")
166 (erc-dcc-tests--erc-dcc-do-GET-command "foo - file.bin") 168 (erc-dcc-tests--erc-dcc-do-GET-command "foo - file.bin")
167 (erc-dcc-tests--erc-dcc-do-GET-command "foo -t file.bin") 169 (erc-dcc-tests--erc-dcc-do-GET-command "foo -t file.bin")
168 (erc-dcc-tests--erc-dcc-do-GET-command "-t" "-- ")) 170 (erc-dcc-tests--erc-dcc-do-GET-command "-t" "-- ")
171
172 ;; Regression involving pipe character in nickname.
173 (let ((nuh "test|r!~test|r@fake.irc"))
174 (erc-dcc-tests--erc-dcc-do-GET-command "foo.bin" nil nuh)
175 (erc-dcc-tests--erc-dcc-do-GET-command "foo - file.bin" nil nuh)
176 (erc-dcc-tests--erc-dcc-do-GET-command "foo -t file.bin" nil nuh)
177 (erc-dcc-tests--erc-dcc-do-GET-command "-t" "-- " nuh)))
169 178
170(defun erc-dcc-tests--pcomplete-common (test-fn &optional file) 179(defun erc-dcc-tests--pcomplete-common (test-fn &optional file)
171 (with-current-buffer (get-buffer-create "*erc-dcc-do-GET-command*") 180 (with-current-buffer (get-buffer-create "*erc-dcc-do-GET-command*")
diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el
index 80c7c708fc5..f5c900df408 100644
--- a/test/lisp/erc/erc-tests.el
+++ b/test/lisp/erc/erc-tests.el
@@ -1218,6 +1218,52 @@
1218 1218
1219 (should-not calls)))))) 1219 (should-not calls))))))
1220 1220
1221(ert-deftest erc--split-string-shell-cmd ()
1222
1223 ;; Leading and trailing space
1224 (should (equal (erc--split-string-shell-cmd "1 2 3") '("1" "2" "3")))
1225 (should (equal (erc--split-string-shell-cmd " 1 2 3 ") '("1" "2" "3")))
1226
1227 ;; Empty string
1228 (should (equal (erc--split-string-shell-cmd "\"\"") '("")))
1229 (should (equal (erc--split-string-shell-cmd " \"\" ") '("")))
1230 (should (equal (erc--split-string-shell-cmd "1 \"\"") '("1" "")))
1231 (should (equal (erc--split-string-shell-cmd "1 \"\" ") '("1" "")))
1232 (should (equal (erc--split-string-shell-cmd "\"\" 1") '("" "1")))
1233 (should (equal (erc--split-string-shell-cmd " \"\" 1") '("" "1")))
1234
1235 (should (equal (erc--split-string-shell-cmd "''") '("")))
1236 (should (equal (erc--split-string-shell-cmd " '' ") '("")))
1237 (should (equal (erc--split-string-shell-cmd "1 ''") '("1" "")))
1238 (should (equal (erc--split-string-shell-cmd "1 '' ") '("1" "")))
1239 (should (equal (erc--split-string-shell-cmd "'' 1") '("" "1")))
1240 (should (equal (erc--split-string-shell-cmd " '' 1") '("" "1")))
1241
1242 ;; Backslash
1243 (should (equal (erc--split-string-shell-cmd "\\ ") '(" ")))
1244 (should (equal (erc--split-string-shell-cmd " \\ ") '(" ")))
1245 (should (equal (erc--split-string-shell-cmd "1\\ ") '("1 ")))
1246 (should (equal (erc--split-string-shell-cmd "1\\ 2") '("1 2")))
1247
1248 ;; Embedded
1249 (should (equal (erc--split-string-shell-cmd "\"\\\"\"") '("\"")))
1250 (should (equal (erc--split-string-shell-cmd "1 \"2 \\\" \\\" 3\"")
1251 '("1" "2 \" \" 3")))
1252 (should (equal (erc--split-string-shell-cmd "1 \"2 ' ' 3\"")
1253 '("1" "2 ' ' 3")))
1254 (should (equal (erc--split-string-shell-cmd "1 '2 \" \" 3'")
1255 '("1" "2 \" \" 3")))
1256 (should (equal (erc--split-string-shell-cmd "1 '2 \\ 3'")
1257 '("1" "2 \\ 3")))
1258 (should (equal (erc--split-string-shell-cmd "1 \"2 \\\\ 3\"")
1259 '("1" "2 \\ 3"))) ; see comment re ^
1260
1261 ;; Realistic
1262 (should (equal (erc--split-string-shell-cmd "GET bob \"my file.txt\"")
1263 '("GET" "bob" "my file.txt")))
1264 (should (equal (erc--split-string-shell-cmd "GET EXAMPLE|bob \"my file.txt\"")
1265 '("GET" "EXAMPLE|bob" "my file.txt")))) ; regression
1266
1221 1267
1222;; The behavior of `erc-pre-send-functions' differs between versions 1268;; The behavior of `erc-pre-send-functions' differs between versions
1223;; in how hook members see and influence a trailing newline that's 1269;; in how hook members see and influence a trailing newline that's