summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/ert-x.el
diff options
context:
space:
mode:
authorMichael Albinus <michael.albinus@gmx.de>2022-06-08 12:06:56 +0200
committerMichael Albinus <michael.albinus@gmx.de>2022-06-08 12:06:56 +0200
commitb2ed8a547ace1dade2823d28b60c21d3634d68b2 (patch)
treeaa3420eccea7101e5f5b7d8639825e4e4dc65ff7 /lisp/emacs-lisp/ert-x.el
parent493ae66be08a99ea7918ee8210aec3eb925c8fad (diff)
downloademacs-b2ed8a547ace1dade2823d28b60c21d3634d68b2.tar.gz
emacs-b2ed8a547ace1dade2823d28b60c21d3634d68b2.tar.bz2
emacs-b2ed8a547ace1dade2823d28b60c21d3634d68b2.zip
Factor out test configuration for remote files
* lisp/emacs-lisp/ert-x.el (tramp-methods) (tramp-default-host-alist): Declare. (ert-remote-temporary-file-directory): New defconst. * test/README: Mention dnd-tests.el. * test/lisp/autorevert-tests.el (auto-revert-test-remote-temporary-file-directory): Remove. Replace all uses by `ert-remote-temporary-file-directory'. * test/lisp/dnd-tests.el (ert-x): Require. (dnd-tests-temporary-file-directory): Remove. Replace all uses by `ert-remote-temporary-file-directory'. * test/lisp/filenotify-tests.el (file-notify-test-remote-temporary-file-directory): Remove. Replace all uses by `ert-remote-temporary-file-directory'. * test/lisp/shadowfile-tests.el (ert-x): Require. (shadow-test-remote-temporary-file-directory): Remove. Replace all uses by `ert-remote-temporary-file-directory'. * test/lisp/net/tramp-tests.el: Don't require ert. (ert-remote-temporary-file-directory): Define if it doesn't exist. (tramp-test-temporary-file-directory): Remove. Replace all uses by `ert-remote-temporary-file-directory'.
Diffstat (limited to 'lisp/emacs-lisp/ert-x.el')
-rw-r--r--lisp/emacs-lisp/ert-x.el30
1 files changed, 30 insertions, 0 deletions
diff --git a/lisp/emacs-lisp/ert-x.el b/lisp/emacs-lisp/ert-x.el
index 0180e9e53cc..de18adff5b8 100644
--- a/lisp/emacs-lisp/ert-x.el
+++ b/lisp/emacs-lisp/ert-x.el
@@ -491,6 +491,36 @@ The same keyword arguments are supported as in
(string-match "Apple \\(LLVM\\|[Cc]lang\\)\\|Xcode\\.app"
(shell-command-to-string "gcc --version")))
+
+(defvar tramp-methods)
+(defvar tramp-default-host-alist)
+
+;; If this defconst is used in a test file, `tramp' shall be loaded
+;; prior `ert-x'. There is no default value on w32 systems, which
+;; could work out of the box.
+(defconst ert-remote-temporary-file-directory
+ (when (featurep 'tramp)
+ (cond
+ ((getenv "REMOTE_TEMPORARY_FILE_DIRECTORY"))
+ ((eq system-type 'windows-nt) null-device)
+ (t (add-to-list
+ 'tramp-methods
+ '("mock"
+ (tramp-login-program "sh")
+ (tramp-login-args (("-i")))
+ (tramp-remote-shell "/bin/sh")
+ (tramp-remote-shell-args ("-c"))
+ (tramp-connection-timeout 10)))
+ (add-to-list
+ 'tramp-default-host-alist
+ `("\\`mock\\'" nil ,(system-name)))
+ ;; Emacs's Makefile sets $HOME to a nonexistent value. Needed
+ ;; in batch mode only, therefore.
+ (unless (and (null noninteractive) (file-directory-p "~/"))
+ (setenv "HOME" temporary-file-directory))
+ (format "/mock::%s" temporary-file-directory))))
+ "Temporary directory for remote file tests.")
+
(provide 'ert-x)
;;; ert-x.el ends here