diff options
author | Michael Albinus <michael.albinus@gmx.de> | 2022-06-08 12:06:56 +0200 |
---|---|---|
committer | Michael Albinus <michael.albinus@gmx.de> | 2022-06-08 12:06:56 +0200 |
commit | b2ed8a547ace1dade2823d28b60c21d3634d68b2 (patch) | |
tree | aa3420eccea7101e5f5b7d8639825e4e4dc65ff7 /test/lisp/shadowfile-tests.el | |
parent | 493ae66be08a99ea7918ee8210aec3eb925c8fad (diff) | |
download | emacs-b2ed8a547ace1dade2823d28b60c21d3634d68b2.tar.gz |
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 'test/lisp/shadowfile-tests.el')
-rw-r--r-- | test/lisp/shadowfile-tests.el | 116 |
1 files changed, 36 insertions, 80 deletions
diff --git a/test/lisp/shadowfile-tests.el b/test/lisp/shadowfile-tests.el index 46ab34535d4..e822bc9eb66 100644 --- a/test/lisp/shadowfile-tests.el +++ b/test/lisp/shadowfile-tests.el @@ -37,37 +37,9 @@ ;;; Code: -(require 'ert) -(require 'shadowfile) (require 'tramp) - -;; There is no default value on w32 systems, which could work out of the box. -(defconst shadow-test-remote-temporary-file-directory - (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' Makefile sets $HOME to a nonexistent value. Needed in - ;; batch mode only, therefore. `shadow-homedir' cannot be - ;; `temporary-directory', because the tests with "~" would fail. - (unless (and (null noninteractive) (file-directory-p "~/")) - (setenv "HOME" (file-name-unquote temporary-file-directory)) - (setq shadow-homedir invocation-directory) - (add-to-list - 'tramp-connection-properties - `(,(file-remote-p "/mock::") "~" ,invocation-directory))) - (format "/mock::%s" temporary-file-directory))) - "Temporary directory for Tramp tests.") +(require 'ert-x) +(require 'shadowfile) (setq auth-source-save-behavior nil password-cache-expiry nil @@ -80,9 +52,8 @@ tramp-verbose 0 ;; On macOS, `temporary-file-directory' is a symlinked directory. temporary-file-directory (file-truename temporary-file-directory) - shadow-test-remote-temporary-file-directory - (ignore-errors - (file-truename shadow-test-remote-temporary-file-directory))) + ert-remote-temporary-file-directory + (ignore-errors (file-truename ert-remote-temporary-file-directory))) ;; This should happen on hydra only. (when (getenv "EMACS_HYDRA_CI") @@ -100,7 +71,7 @@ "Reset all `shadowfile' internals." ;; Cleanup Tramp. (tramp-cleanup-connection - (tramp-dissect-file-name shadow-test-remote-temporary-file-directory) t t) + (tramp-dissect-file-name ert-remote-temporary-file-directory) t t) ;; Delete auto-saved files. (with-current-buffer (find-file-noselect shadow-info-file 'nowarn) (ignore-errors (delete-file (make-auto-save-file-name))) @@ -135,7 +106,7 @@ a cluster (or site). This is not tested here; it must be guaranteed by the originator of a cluster definition." :tags '(:expensive-test) (skip-unless (not (memq system-type '(windows-nt ms-dos)))) - (skip-unless (file-remote-p shadow-test-remote-temporary-file-directory)) + (skip-unless (file-remote-p ert-remote-temporary-file-directory)) (let ((text-quoting-style 'grave) ;; We inspect the *Messages* buffer! (inhibit-message t) @@ -222,8 +193,7 @@ guaranteed by the originator of a cluster definition." (shadow-cluster-regexp (shadow-get-cluster cluster)) regexp)) ;; Redefine the cluster. - (setq primary - (file-remote-p shadow-test-remote-temporary-file-directory) + (setq primary (file-remote-p ert-remote-temporary-file-directory) regexp (shadow-regexp-superquote primary) mocked-input `(,cluster ,primary ,regexp)) (call-interactively #'shadow-define-cluster) @@ -254,7 +224,7 @@ Per definition, all files are identical on the different hosts of a cluster (or site). This is not tested here; it must be guaranteed by the originator of a cluster definition." (skip-unless (not (memq system-type '(windows-nt ms-dos)))) - (skip-unless (file-remote-p shadow-test-remote-temporary-file-directory)) + (skip-unless (file-remote-p ert-remote-temporary-file-directory)) (let ((shadow-info-file shadow-test-info-file) (shadow-todo-file shadow-test-todo-file) @@ -286,14 +256,14 @@ guaranteed by the originator of a cluster definition." (should (string-equal (system-name) (shadow-site-name primary1))) (should (string-equal - (file-remote-p shadow-test-remote-temporary-file-directory) + (file-remote-p ert-remote-temporary-file-directory) (shadow-name-site - (file-remote-p shadow-test-remote-temporary-file-directory)))) + (file-remote-p ert-remote-temporary-file-directory)))) (should (string-equal - (file-remote-p shadow-test-remote-temporary-file-directory) + (file-remote-p ert-remote-temporary-file-directory) (shadow-site-name - (file-remote-p shadow-test-remote-temporary-file-directory)))) + (file-remote-p ert-remote-temporary-file-directory)))) (should (equal (shadow-site-cluster cluster1) (shadow-get-cluster cluster1))) @@ -324,8 +294,7 @@ guaranteed by the originator of a cluster definition." ;; Define a second cluster. (setq cluster2 "cluster2" - primary2 - (file-remote-p shadow-test-remote-temporary-file-directory) + primary2 (file-remote-p ert-remote-temporary-file-directory) regexp2 (format "^\\(%s\\|%s\\)$" shadow-system-name primary2)) (shadow-set-cluster cluster2 primary2 regexp2) @@ -356,7 +325,7 @@ guaranteed by the originator of a cluster definition." (ert-deftest shadow-test02-files () "Check file manipulation functions." (skip-unless (not (memq system-type '(windows-nt ms-dos)))) - (skip-unless (file-remote-p shadow-test-remote-temporary-file-directory)) + (skip-unless (file-remote-p ert-remote-temporary-file-directory)) (let ((shadow-info-file shadow-test-info-file) (shadow-todo-file shadow-test-todo-file) @@ -398,8 +367,7 @@ guaranteed by the originator of a cluster definition." (string-equal (shadow-local-file (concat primary file)) file)) ;; Redefine the cluster. - (setq primary - (file-remote-p shadow-test-remote-temporary-file-directory) + (setq primary (file-remote-p ert-remote-temporary-file-directory) regexp (shadow-regexp-superquote primary)) (shadow-set-cluster cluster primary regexp) @@ -428,7 +396,7 @@ guaranteed by the originator of a cluster definition." (ert-deftest shadow-test03-expand-cluster-in-file-name () "Check canonical file name of a cluster or site." (skip-unless (not (memq system-type '(windows-nt ms-dos)))) - (skip-unless (file-remote-p shadow-test-remote-temporary-file-directory)) + (skip-unless (file-remote-p ert-remote-temporary-file-directory)) (let ((shadow-info-file shadow-test-info-file) (shadow-todo-file shadow-test-todo-file) @@ -453,8 +421,7 @@ guaranteed by the originator of a cluster definition." file2 (make-temp-name (expand-file-name - "shadowfile-tests" - shadow-test-remote-temporary-file-directory))) + "shadowfile-tests" ert-remote-temporary-file-directory))) ;; A local file name is kept. (should @@ -473,8 +440,7 @@ guaranteed by the originator of a cluster definition." (shadow-expand-cluster-in-file-name (concat primary file1)) file1)) ;; Redefine the cluster. - (setq primary - (file-remote-p shadow-test-remote-temporary-file-directory) + (setq primary (file-remote-p ert-remote-temporary-file-directory) regexp (shadow-regexp-superquote primary)) (shadow-set-cluster cluster primary regexp) @@ -495,7 +461,7 @@ guaranteed by the originator of a cluster definition." (ert-deftest shadow-test04-contract-file-name () "Check canonical file name of a cluster or site." (skip-unless (not (memq system-type '(windows-nt ms-dos)))) - (skip-unless (file-remote-p shadow-test-remote-temporary-file-directory)) + (skip-unless (file-remote-p ert-remote-temporary-file-directory)) (let ((shadow-info-file shadow-test-info-file) (shadow-todo-file shadow-test-todo-file) @@ -533,8 +499,7 @@ guaranteed by the originator of a cluster definition." (concat "/cluster:" file))) ;; Redefine the cluster. - (setq primary - (file-remote-p shadow-test-remote-temporary-file-directory) + (setq primary (file-remote-p ert-remote-temporary-file-directory) regexp (shadow-regexp-superquote primary)) (shadow-set-cluster cluster primary regexp) @@ -542,8 +507,7 @@ guaranteed by the originator of a cluster definition." (should (string-equal (shadow-contract-file-name - (concat - (file-remote-p shadow-test-remote-temporary-file-directory) file)) + (concat (file-remote-p ert-remote-temporary-file-directory) file)) (concat "/cluster:" file)))) ;; Cleanup. @@ -552,7 +516,7 @@ guaranteed by the originator of a cluster definition." (ert-deftest shadow-test05-file-match () "Check `shadow-same-site' and `shadow-file-match'." (skip-unless (not (memq system-type '(windows-nt ms-dos)))) - (skip-unless (file-remote-p shadow-test-remote-temporary-file-directory)) + (skip-unless (file-remote-p ert-remote-temporary-file-directory)) (let ((shadow-info-file shadow-test-info-file) (shadow-todo-file shadow-test-todo-file) @@ -588,17 +552,14 @@ guaranteed by the originator of a cluster definition." (should (shadow-file-match (shadow-parse-name file) file)) ;; Redefine the cluster. - (setq primary - (file-remote-p shadow-test-remote-temporary-file-directory) + (setq primary (file-remote-p ert-remote-temporary-file-directory) regexp (shadow-regexp-superquote primary)) (shadow-set-cluster cluster primary regexp) (should (shadow-file-match (shadow-parse-name - (concat - (file-remote-p shadow-test-remote-temporary-file-directory) - file)) + (concat (file-remote-p ert-remote-temporary-file-directory) file)) file))) ;; Cleanup. @@ -607,7 +568,7 @@ guaranteed by the originator of a cluster definition." (ert-deftest shadow-test06-literal-groups () "Check literal group definitions." (skip-unless (not (memq system-type '(windows-nt ms-dos)))) - (skip-unless (file-remote-p shadow-test-remote-temporary-file-directory)) + (skip-unless (file-remote-p ert-remote-temporary-file-directory)) (let ((shadow-info-file shadow-test-info-file) (shadow-todo-file shadow-test-todo-file) @@ -632,8 +593,7 @@ guaranteed by the originator of a cluster definition." (shadow-set-cluster cluster1 primary regexp) (setq cluster2 "cluster2" - primary - (file-remote-p shadow-test-remote-temporary-file-directory) + primary (file-remote-p ert-remote-temporary-file-directory) regexp (format "^\\(%s\\|%s\\)$" shadow-system-name primary)) (shadow-set-cluster cluster2 primary regexp) @@ -644,8 +604,7 @@ guaranteed by the originator of a cluster definition." file2 (make-temp-name (expand-file-name - "shadowfile-tests" - shadow-test-remote-temporary-file-directory)) + "shadowfile-tests" ert-remote-temporary-file-directory)) mocked-input `(,cluster1 ,file1 ,cluster2 ,file2 ,primary ,file1 ,(kbd "RET"))) @@ -694,7 +653,7 @@ guaranteed by the originator of a cluster definition." (ert-deftest shadow-test07-regexp-groups () "Check regexp group definitions." (skip-unless (not (memq system-type '(windows-nt ms-dos)))) - (skip-unless (file-remote-p shadow-test-remote-temporary-file-directory)) + (skip-unless (file-remote-p ert-remote-temporary-file-directory)) (let ((shadow-info-file shadow-test-info-file) (shadow-todo-file shadow-test-todo-file) @@ -719,8 +678,7 @@ guaranteed by the originator of a cluster definition." (shadow-set-cluster cluster1 primary regexp) (setq cluster2 "cluster2" - primary - (file-remote-p shadow-test-remote-temporary-file-directory) + primary (file-remote-p ert-remote-temporary-file-directory) regexp (format "^\\(%s\\|%s\\)$" shadow-system-name primary)) (shadow-set-cluster cluster2 primary regexp) @@ -757,8 +715,8 @@ guaranteed by the originator of a cluster definition." (ert-deftest shadow-test08-shadow-todo () "Check that needed shadows are added to todo." (skip-unless (not (memq system-type '(windows-nt ms-dos)))) - (skip-unless (file-remote-p shadow-test-remote-temporary-file-directory)) - (skip-unless (file-writable-p shadow-test-remote-temporary-file-directory)) + (skip-unless (file-remote-p ert-remote-temporary-file-directory)) + (skip-unless (file-writable-p ert-remote-temporary-file-directory)) (let ((backup-inhibited t) create-lockfiles @@ -778,7 +736,7 @@ guaranteed by the originator of a cluster definition." (message "%s %s %s %s %s" temporary-file-directory - shadow-test-remote-temporary-file-directory + ert-remote-temporary-file-directory shadow-homedir shadow-info-file shadow-todo-file)) ;; Define clusters. @@ -792,8 +750,7 @@ guaranteed by the originator of a cluster definition." cluster1 primary regexp shadow-clusters)) (setq cluster2 "cluster2" - primary - (file-remote-p shadow-test-remote-temporary-file-directory) + primary (file-remote-p ert-remote-temporary-file-directory) regexp (shadow-regexp-superquote primary)) (shadow-set-cluster cluster2 primary regexp) (when shadow-debug @@ -903,8 +860,8 @@ guaranteed by the originator of a cluster definition." "Check that needed shadow files are copied." :tags '(:expensive-test) (skip-unless (not (memq system-type '(windows-nt ms-dos)))) - (skip-unless (file-remote-p shadow-test-remote-temporary-file-directory)) - (skip-unless (file-writable-p shadow-test-remote-temporary-file-directory)) + (skip-unless (file-remote-p ert-remote-temporary-file-directory)) + (skip-unless (file-writable-p ert-remote-temporary-file-directory)) (let ((backup-inhibited t) create-lockfiles @@ -928,8 +885,7 @@ guaranteed by the originator of a cluster definition." (shadow-set-cluster cluster1 primary regexp) (setq cluster2 "cluster2" - primary - (file-remote-p shadow-test-remote-temporary-file-directory) + primary (file-remote-p ert-remote-temporary-file-directory) regexp (shadow-regexp-superquote primary)) (shadow-set-cluster cluster2 primary regexp) |