aboutsummaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
Diffstat (limited to 'test/src')
-rw-r--r--test/src/process-tests.el49
1 files changed, 49 insertions, 0 deletions
diff --git a/test/src/process-tests.el b/test/src/process-tests.el
index 551b34ff371..af5bc737574 100644
--- a/test/src/process-tests.el
+++ b/test/src/process-tests.el
@@ -215,5 +215,54 @@
215 (string-to-list "stdout\n") 215 (string-to-list "stdout\n")
216 (string-to-list "stderr\n")))))) 216 (string-to-list "stderr\n"))))))
217 217
218(ert-deftest make-process/file-handler/found ()
219 "Check that the ‘:file-handler’ argument of ‘make-process’
220works as expected if a file handler is found."
221 (let ((file-handler-calls 0))
222 (cl-flet ((file-handler
223 (&rest args)
224 (should (equal default-directory "test-handler:/dir/"))
225 (should (equal args '(make-process :name "name"
226 :command ("/some/binary")
227 :file-handler t)))
228 (cl-incf file-handler-calls)
229 'fake-process))
230 (let ((file-name-handler-alist (list (cons (rx bos "test-handler:")
231 #'file-handler)))
232 (default-directory "test-handler:/dir/"))
233 (should (eq (make-process :name "name"
234 :command '("/some/binary")
235 :file-handler t)
236 'fake-process))
237 (should (= file-handler-calls 1))))))
238
239(ert-deftest make-process/file-handler/not-found ()
240 "Check that the ‘:file-handler’ argument of ‘make-process’
241works as expected if no file handler is found."
242 (let ((file-name-handler-alist ())
243 (default-directory invocation-directory)
244 (program (expand-file-name invocation-name invocation-directory)))
245 (should (processp (make-process :name "name"
246 :command (list program "--version")
247 :file-handler t)))))
248
249(ert-deftest make-process/file-handler/disable ()
250 "Check ‘make-process’ works as expected if it shouldn’t use the
251file handler."
252 (let ((file-name-handler-alist (list (cons (rx bos "test-handler:")
253 #'process-tests--file-handler)))
254 (default-directory "test-handler:/dir/")
255 (program (expand-file-name invocation-name invocation-directory)))
256 (should (processp (make-process :name "name"
257 :command (list program "--version"))))))
258
259(defun process-tests--file-handler (operation &rest _args)
260 (cl-ecase operation
261 (unhandled-file-name-directory "/")
262 (make-process (ert-fail "file handler called unexpectedly"))))
263
264(put #'process-tests--file-handler 'operations
265 '(unhandled-file-name-directory make-process))
266
218(provide 'process-tests) 267(provide 'process-tests)
219;; process-tests.el ends here. 268;; process-tests.el ends here.