aboutsummaryrefslogtreecommitdiffstats
path: root/test/src/process-tests.el
diff options
context:
space:
mode:
authorPhilipp Stephani2018-12-17 21:47:46 +0100
committerPhilipp Stephani2018-12-22 22:10:48 +0100
commit039be4e02513e03ae465efae5694bd4e28a74dbe (patch)
tree34d43f419b279e7f652ef592332f2021b5eedc66 /test/src/process-tests.el
parentb41789f31f2355f6de8c15bbbc10cd6bf3dfe61e (diff)
downloademacs-039be4e02513e03ae465efae5694bd4e28a74dbe.tar.gz
emacs-039be4e02513e03ae465efae5694bd4e28a74dbe.zip
Add file name handler support for 'make-process' (Bug#28691)
* src/process.c (Fmake_process): Add new keyword argument ':file-handler'. (syms_of_process) <make-process, :file-handler>: Define new symbols. * lisp/files.el (file-name-non-special): Add support for 'make-process'. * test/src/process-tests.el (make-process/file-handler/found) (make-process/file-handler/not-found) (make-process/file-handler/disable): New unit tests. (process-tests--file-handler): New helper function. * test/lisp/files-tests.el (files-tests-file-name-non-special-make-process): New unit test. * doc/lispref/files.texi (Magic File Names): Document that 'make-process' can invoke file name handlers. * doc/lispref/processes.texi (Asynchronous Processes): Document ':file-handlers' argument to 'make-process'. * etc/NEWS (Lisp Changes in Emacs 27.1): Mention new :file-handler argument for 'make-process'.
Diffstat (limited to 'test/src/process-tests.el')
-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.