aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2018-03-17 15:10:46 +0100
committerMichael Albinus2018-03-17 15:10:46 +0100
commitbcc146a66867f1106f405f7f0dc1f1e02810a992 (patch)
tree6c3b505ac9700c439d97bce33a8190dd5ba9661f
parentf7346a584ed46fdb0bfcbbdd3673fee022d2c1c3 (diff)
downloademacs-bcc146a66867f1106f405f7f0dc1f1e02810a992.tar.gz
emacs-bcc146a66867f1106f405f7f0dc1f1e02810a992.zip
Optimize tramp-tests.el
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): Make it a defsubst. Adapt all callees. (tramp--test-print-duration): New defmacro. (tramp-test11-copy-file, tramp-test12-rename-file) (tramp-test21-file-links, tramp--test-special-characters): Run some parts only if expensive tests are enabled. (Bug#30807)
-rw-r--r--test/lisp/net/tramp-tests.el254
1 files changed, 139 insertions, 115 deletions
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 3fd8f69443e..e8d35039779 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -102,11 +102,6 @@
102(when (getenv "EMACS_HYDRA_CI") 102(when (getenv "EMACS_HYDRA_CI")
103 (add-to-list 'tramp-remote-path 'tramp-own-remote-path)) 103 (add-to-list 'tramp-remote-path 'tramp-own-remote-path))
104 104
105(defvar tramp--test-expensive-test
106 (null
107 (string-equal (getenv "SELECTOR") "(quote (not (tag :expensive-test)))"))
108 "Whether expensive tests are run.")
109
110(defvar tramp--test-enabled-checked nil 105(defvar tramp--test-enabled-checked nil
111 "Cached result of `tramp--test-enabled'. 106 "Cached result of `tramp--test-enabled'.
112If the function did run, the value is a cons cell, the `cdr' 107If the function did run, the value is a cons cell, the `cdr'
@@ -134,6 +129,12 @@ being the result.")
134 ;; Return result. 129 ;; Return result.
135 (cdr tramp--test-enabled-checked)) 130 (cdr tramp--test-enabled-checked))
136 131
132(defsubst tramp--test-expensive-test ()
133 "Whether expensive tests are run."
134 (ert-select-tests
135 (ert--stats-selector ert--current-run-stats)
136 (list (make-ert-test :body nil :tags '(:expensive-test)))))
137
137(defun tramp--test-make-temp-name (&optional local quoted) 138(defun tramp--test-make-temp-name (&optional local quoted)
138 "Return a temporary file name for test. 139 "Return a temporary file name for test.
139If LOCAL is non-nil, a local file name is returned. 140If LOCAL is non-nil, a local file name is returned.
@@ -186,6 +187,16 @@ handled properly. BODY shall not contain a timeout."
186 (tramp-backtrace 187 (tramp-backtrace
187 (tramp-dissect-file-name tramp-test-temporary-file-directory)))) 188 (tramp-dissect-file-name tramp-test-temporary-file-directory))))
188 189
190(defmacro tramp--test-print-duration (message &rest body)
191 "Run BODY and print a message with duration, prompted by MESSAGE."
192 (declare (indent 1) (debug (stringp body)))
193 `(let ((start (current-time)))
194 (unwind-protect
195 (progn ,@body)
196 (tramp--test-message
197 "%s %f sec"
198 ,message (float-time (time-subtract (current-time) start))))))
199
189(ert-deftest tramp-test00-availability () 200(ert-deftest tramp-test00-availability ()
190 "Test availability of Tramp functions." 201 "Test availability of Tramp functions."
191 :expected-result (if (tramp--test-enabled) :passed :failed) 202 :expected-result (if (tramp--test-enabled) :passed :failed)
@@ -1744,8 +1755,8 @@ handled properly. BODY shall not contain a timeout."
1744 (substitute-in-file-name "/method:host:/~foo") "/method:host:/~foo")) 1755 (substitute-in-file-name "/method:host:/~foo") "/method:host:/~foo"))
1745 (should 1756 (should
1746 (string-equal (substitute-in-file-name "/method:host:/path//~foo") "/~foo")) 1757 (string-equal (substitute-in-file-name "/method:host:/path//~foo") "/~foo"))
1747 ;; (substitute-in-file-name "/path/~foo") expands only to "/~foo"", 1758 ;; (substitute-in-file-name "/path/~foo") expands only for a local
1748 ;; if $LOGNAME or $USER is "foo". Otherwise, it doesn't expand. 1759 ;; user "foo" to "/~foo"". Otherwise, it doesn't expand.
1749 (should 1760 (should
1750 (string-equal 1761 (string-equal
1751 (substitute-in-file-name 1762 (substitute-in-file-name
@@ -1906,7 +1917,7 @@ This checks also `file-name-as-directory', `file-name-directory',
1906 "Check `file-exist-p', `write-region' and `delete-file'." 1917 "Check `file-exist-p', `write-region' and `delete-file'."
1907 (skip-unless (tramp--test-enabled)) 1918 (skip-unless (tramp--test-enabled))
1908 1919
1909 (dolist (quoted (if tramp--test-expensive-test '(nil t) '(nil))) 1920 (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
1910 (let ((tmp-name (tramp--test-make-temp-name nil quoted))) 1921 (let ((tmp-name (tramp--test-make-temp-name nil quoted)))
1911 (should-not (file-exists-p tmp-name)) 1922 (should-not (file-exists-p tmp-name))
1912 (write-region "foo" nil tmp-name) 1923 (write-region "foo" nil tmp-name)
@@ -1918,7 +1929,7 @@ This checks also `file-name-as-directory', `file-name-directory',
1918 "Check `file-local-copy'." 1929 "Check `file-local-copy'."
1919 (skip-unless (tramp--test-enabled)) 1930 (skip-unless (tramp--test-enabled))
1920 1931
1921 (dolist (quoted (if tramp--test-expensive-test '(nil t) '(nil))) 1932 (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
1922 (let ((tmp-name1 (tramp--test-make-temp-name nil quoted)) 1933 (let ((tmp-name1 (tramp--test-make-temp-name nil quoted))
1923 tmp-name2) 1934 tmp-name2)
1924 (unwind-protect 1935 (unwind-protect
@@ -1950,7 +1961,7 @@ This checks also `file-name-as-directory', `file-name-directory',
1950 "Check `insert-file-contents'." 1961 "Check `insert-file-contents'."
1951 (skip-unless (tramp--test-enabled)) 1962 (skip-unless (tramp--test-enabled))
1952 1963
1953 (dolist (quoted (if tramp--test-expensive-test '(nil t) '(nil))) 1964 (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
1954 (let ((tmp-name (tramp--test-make-temp-name nil quoted))) 1965 (let ((tmp-name (tramp--test-make-temp-name nil quoted)))
1955 (unwind-protect 1966 (unwind-protect
1956 (with-temp-buffer 1967 (with-temp-buffer
@@ -1978,7 +1989,7 @@ This checks also `file-name-as-directory', `file-name-directory',
1978 "Check `write-region'." 1989 "Check `write-region'."
1979 (skip-unless (tramp--test-enabled)) 1990 (skip-unless (tramp--test-enabled))
1980 1991
1981 (dolist (quoted (if tramp--test-expensive-test '(nil t) '(nil))) 1992 (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
1982 (let ((tmp-name (tramp--test-make-temp-name nil quoted))) 1993 (let ((tmp-name (tramp--test-make-temp-name nil quoted)))
1983 (unwind-protect 1994 (unwind-protect
1984 (progn 1995 (progn
@@ -2068,7 +2079,7 @@ This checks also `file-name-as-directory', `file-name-directory',
2068 (skip-unless (tramp--test-enabled)) 2079 (skip-unless (tramp--test-enabled))
2069 2080
2070 ;; `filename-non-special' has been fixed in Emacs 27.1, see Bug#29579. 2081 ;; `filename-non-special' has been fixed in Emacs 27.1, see Bug#29579.
2071 (dolist (quoted (if (and tramp--test-expensive-test (tramp--test-emacs27-p)) 2082 (dolist (quoted (if (and (tramp--test-expensive-test) (tramp--test-emacs27-p))
2072 '(nil t) '(nil))) 2083 '(nil t) '(nil)))
2073 (let ((tmp-name1 (tramp--test-make-temp-name nil quoted)) 2084 (let ((tmp-name1 (tramp--test-make-temp-name nil quoted))
2074 (tmp-name2 (tramp--test-make-temp-name nil quoted)) 2085 (tmp-name2 (tramp--test-make-temp-name nil quoted))
@@ -2093,9 +2104,10 @@ This checks also `file-name-as-directory', `file-name-directory',
2093 (with-temp-buffer 2104 (with-temp-buffer
2094 (insert-file-contents target) 2105 (insert-file-contents target)
2095 (should (string-equal (buffer-string) "foo"))) 2106 (should (string-equal (buffer-string) "foo")))
2096 (should-error 2107 (when (tramp--test-expensive-test)
2097 (copy-file source target) 2108 (should-error
2098 :type 'file-already-exists) 2109 (copy-file source target)
2110 :type 'file-already-exists))
2099 (copy-file source target 'ok)) 2111 (copy-file source target 'ok))
2100 2112
2101 ;; Cleanup. 2113 ;; Cleanup.
@@ -2112,7 +2124,7 @@ This checks also `file-name-as-directory', `file-name-directory',
2112 (make-directory target) 2124 (make-directory target)
2113 (should (file-directory-p target)) 2125 (should (file-directory-p target))
2114 ;; This has been changed in Emacs 26.1. 2126 ;; This has been changed in Emacs 26.1.
2115 (when (tramp--test-emacs26-p) 2127 (when (and (tramp--test-expensive-test) (tramp--test-emacs26-p))
2116 (should-error 2128 (should-error
2117 (copy-file source target) 2129 (copy-file source target)
2118 :type 'file-already-exists)) 2130 :type 'file-already-exists))
@@ -2179,7 +2191,7 @@ This checks also `file-name-as-directory', `file-name-directory',
2179 (skip-unless (tramp--test-enabled)) 2191 (skip-unless (tramp--test-enabled))
2180 2192
2181 ;; `filename-non-special' has been fixed in Emacs 27.1, see Bug#29579. 2193 ;; `filename-non-special' has been fixed in Emacs 27.1, see Bug#29579.
2182 (dolist (quoted (if (and tramp--test-expensive-test (tramp--test-emacs27-p)) 2194 (dolist (quoted (if (and (tramp--test-expensive-test) (tramp--test-emacs27-p))
2183 '(nil t) '(nil))) 2195 '(nil t) '(nil)))
2184 (let ((tmp-name1 (tramp--test-make-temp-name nil quoted)) 2196 (let ((tmp-name1 (tramp--test-make-temp-name nil quoted))
2185 (tmp-name2 (tramp--test-make-temp-name nil quoted)) 2197 (tmp-name2 (tramp--test-make-temp-name nil quoted))
@@ -2207,9 +2219,10 @@ This checks also `file-name-as-directory', `file-name-directory',
2207 (should (string-equal (buffer-string) "foo"))) 2219 (should (string-equal (buffer-string) "foo")))
2208 (write-region "foo" nil source) 2220 (write-region "foo" nil source)
2209 (should (file-exists-p source)) 2221 (should (file-exists-p source))
2210 (should-error 2222 (when (tramp--test-expensive-test)
2211 (rename-file source target) 2223 (should-error
2212 :type 'file-already-exists) 2224 (rename-file source target)
2225 :type 'file-already-exists))
2213 (rename-file source target 'ok) 2226 (rename-file source target 'ok)
2214 (should-not (file-exists-p source))) 2227 (should-not (file-exists-p source)))
2215 2228
@@ -2225,7 +2238,7 @@ This checks also `file-name-as-directory', `file-name-directory',
2225 (make-directory target) 2238 (make-directory target)
2226 (should (file-directory-p target)) 2239 (should (file-directory-p target))
2227 ;; This has been changed in Emacs 26.1. 2240 ;; This has been changed in Emacs 26.1.
2228 (when (tramp--test-emacs26-p) 2241 (when (and (tramp--test-expensive-test) (tramp--test-emacs26-p))
2229 (should-error 2242 (should-error
2230 (rename-file source target) 2243 (rename-file source target)
2231 :type 'file-already-exists)) 2244 :type 'file-already-exists))
@@ -2292,7 +2305,7 @@ This checks also `file-name-as-directory', `file-name-directory',
2292This tests also `file-directory-p' and `file-accessible-directory-p'." 2305This tests also `file-directory-p' and `file-accessible-directory-p'."
2293 (skip-unless (tramp--test-enabled)) 2306 (skip-unless (tramp--test-enabled))
2294 2307
2295 (dolist (quoted (if tramp--test-expensive-test '(nil t) '(nil))) 2308 (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
2296 (let* ((tmp-name1 (tramp--test-make-temp-name nil quoted)) 2309 (let* ((tmp-name1 (tramp--test-make-temp-name nil quoted))
2297 (tmp-name2 (expand-file-name "foo/bar" tmp-name1))) 2310 (tmp-name2 (expand-file-name "foo/bar" tmp-name1)))
2298 (unwind-protect 2311 (unwind-protect
@@ -2315,7 +2328,7 @@ This tests also `file-directory-p' and `file-accessible-directory-p'."
2315 "Check `delete-directory'." 2328 "Check `delete-directory'."
2316 (skip-unless (tramp--test-enabled)) 2329 (skip-unless (tramp--test-enabled))
2317 2330
2318 (dolist (quoted (if tramp--test-expensive-test '(nil t) '(nil))) 2331 (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
2319 (let ((tmp-name (tramp--test-make-temp-name nil quoted))) 2332 (let ((tmp-name (tramp--test-make-temp-name nil quoted)))
2320 ;; Delete empty directory. 2333 ;; Delete empty directory.
2321 (make-directory tmp-name) 2334 (make-directory tmp-name)
@@ -2335,7 +2348,7 @@ This tests also `file-directory-p' and `file-accessible-directory-p'."
2335 "Check `copy-directory'." 2348 "Check `copy-directory'."
2336 (skip-unless (tramp--test-enabled)) 2349 (skip-unless (tramp--test-enabled))
2337 2350
2338 (dolist (quoted (if tramp--test-expensive-test '(nil t) '(nil))) 2351 (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
2339 (let* ((tmp-name1 (tramp--test-make-temp-name nil quoted)) 2352 (let* ((tmp-name1 (tramp--test-make-temp-name nil quoted))
2340 (tmp-name2 (tramp--test-make-temp-name nil quoted)) 2353 (tmp-name2 (tramp--test-make-temp-name nil quoted))
2341 (tmp-name3 (expand-file-name 2354 (tmp-name3 (expand-file-name
@@ -2401,7 +2414,7 @@ This tests also `file-directory-p' and `file-accessible-directory-p'."
2401 "Check `directory-files'." 2414 "Check `directory-files'."
2402 (skip-unless (tramp--test-enabled)) 2415 (skip-unless (tramp--test-enabled))
2403 2416
2404 (dolist (quoted (if tramp--test-expensive-test '(nil t) '(nil))) 2417 (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
2405 (let* ((tmp-name1 (tramp--test-make-temp-name nil quoted)) 2418 (let* ((tmp-name1 (tramp--test-make-temp-name nil quoted))
2406 (tmp-name2 (expand-file-name "bla" tmp-name1)) 2419 (tmp-name2 (expand-file-name "bla" tmp-name1))
2407 (tmp-name3 (expand-file-name "foo" tmp-name1))) 2420 (tmp-name3 (expand-file-name "foo" tmp-name1)))
@@ -2434,7 +2447,7 @@ This tests also `file-directory-p' and `file-accessible-directory-p'."
2434 "Check `file-expand-wildcards'." 2447 "Check `file-expand-wildcards'."
2435 (skip-unless (tramp--test-enabled)) 2448 (skip-unless (tramp--test-enabled))
2436 2449
2437 (dolist (quoted (if tramp--test-expensive-test '(nil t) '(nil))) 2450 (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
2438 (let* ((tmp-name1 (tramp--test-make-temp-name nil quoted)) 2451 (let* ((tmp-name1 (tramp--test-make-temp-name nil quoted))
2439 (tmp-name2 (expand-file-name "foo" tmp-name1)) 2452 (tmp-name2 (expand-file-name "foo" tmp-name1))
2440 (tmp-name3 (expand-file-name "bar" tmp-name1)) 2453 (tmp-name3 (expand-file-name "bar" tmp-name1))
@@ -2498,7 +2511,7 @@ This tests also `file-directory-p' and `file-accessible-directory-p'."
2498 "Check `insert-directory'." 2511 "Check `insert-directory'."
2499 (skip-unless (tramp--test-enabled)) 2512 (skip-unless (tramp--test-enabled))
2500 2513
2501 (dolist (quoted (if tramp--test-expensive-test '(nil t) '(nil))) 2514 (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
2502 (let* ((tmp-name1 2515 (let* ((tmp-name1
2503 (expand-file-name (tramp--test-make-temp-name nil quoted))) 2516 (expand-file-name (tramp--test-make-temp-name nil quoted)))
2504 (tmp-name2 (expand-file-name "foo" tmp-name1)) 2517 (tmp-name2 (expand-file-name "foo" tmp-name1))
@@ -2559,7 +2572,7 @@ This tests also `file-directory-p' and `file-accessible-directory-p'."
2559 ;; Since Emacs 26.1. 2572 ;; Since Emacs 26.1.
2560 (skip-unless (fboundp 'insert-directory-wildcard-in-dir-p)) 2573 (skip-unless (fboundp 'insert-directory-wildcard-in-dir-p))
2561 2574
2562 (dolist (quoted (if tramp--test-expensive-test '(nil t) '(nil))) 2575 (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
2563 (let* ((tmp-name1 2576 (let* ((tmp-name1
2564 (expand-file-name (tramp--test-make-temp-name nil quoted))) 2577 (expand-file-name (tramp--test-make-temp-name nil quoted)))
2565 (tmp-name2 2578 (tmp-name2
@@ -2676,7 +2689,7 @@ This tests also `file-readable-p', `file-regular-p' and
2676`file-ownership-preserved-p'." 2689`file-ownership-preserved-p'."
2677 (skip-unless (tramp--test-enabled)) 2690 (skip-unless (tramp--test-enabled))
2678 2691
2679 (dolist (quoted (if tramp--test-expensive-test '(nil t) '(nil))) 2692 (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
2680 ;; We must use `file-truename' for the temporary directory, 2693 ;; We must use `file-truename' for the temporary directory,
2681 ;; because it could be located on a symlinked directory. This 2694 ;; because it could be located on a symlinked directory. This
2682 ;; would let the test fail. 2695 ;; would let the test fail.
@@ -2783,7 +2796,7 @@ This tests also `file-readable-p', `file-regular-p' and
2783 "Check `directory-files-and-attributes'." 2796 "Check `directory-files-and-attributes'."
2784 (skip-unless (tramp--test-enabled)) 2797 (skip-unless (tramp--test-enabled))
2785 2798
2786 (dolist (quoted (if tramp--test-expensive-test '(nil t) '(nil))) 2799 (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
2787 ;; `directory-files-and-attributes' contains also values for 2800 ;; `directory-files-and-attributes' contains also values for
2788 ;; "../". Ensure that this doesn't change during tests, for 2801 ;; "../". Ensure that this doesn't change during tests, for
2789 ;; example due to handling temporary files. 2802 ;; example due to handling temporary files.
@@ -2829,7 +2842,7 @@ This tests also `file-executable-p', `file-writable-p' and `set-file-modes'."
2829 (skip-unless (tramp--test-enabled)) 2842 (skip-unless (tramp--test-enabled))
2830 (skip-unless (tramp--test-sh-p)) 2843 (skip-unless (tramp--test-sh-p))
2831 2844
2832 (dolist (quoted (if tramp--test-expensive-test '(nil t) '(nil))) 2845 (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
2833 (let ((tmp-name (tramp--test-make-temp-name nil quoted))) 2846 (let ((tmp-name (tramp--test-make-temp-name nil quoted)))
2834 (unwind-protect 2847 (unwind-protect
2835 (progn 2848 (progn
@@ -2857,7 +2870,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
2857 ;; older Emacsen, therefore. 2870 ;; older Emacsen, therefore.
2858 (skip-unless (tramp--test-emacs26-p)) 2871 (skip-unless (tramp--test-emacs26-p))
2859 2872
2860 (dolist (quoted (if tramp--test-expensive-test '(nil t) '(nil))) 2873 (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
2861 ;; We must use `file-truename' for the temporary directory, 2874 ;; We must use `file-truename' for the temporary directory,
2862 ;; because it could be located on a symlinked directory. This 2875 ;; because it could be located on a symlinked directory. This
2863 ;; would let the test fail. 2876 ;; would let the test fail.
@@ -2881,14 +2894,16 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
2881 (if quoted 'tramp-compat-file-name-unquote 'identity) 2894 (if quoted 'tramp-compat-file-name-unquote 'identity)
2882 (file-remote-p tmp-name1 'localname)) 2895 (file-remote-p tmp-name1 'localname))
2883 (file-symlink-p tmp-name2))) 2896 (file-symlink-p tmp-name2)))
2884 (should-error 2897 (when (tramp--test-expensive-test)
2885 (make-symbolic-link tmp-name1 tmp-name2)
2886 :type 'file-already-exists)
2887 ;; A number means interactive case.
2888 (cl-letf (((symbol-function 'yes-or-no-p) 'ignore))
2889 (should-error 2898 (should-error
2890 (make-symbolic-link tmp-name1 tmp-name2 0) 2899 (make-symbolic-link tmp-name1 tmp-name2)
2891 :type 'file-already-exists)) 2900 :type 'file-already-exists))
2901 (when (tramp--test-expensive-test)
2902 ;; A number means interactive case.
2903 (cl-letf (((symbol-function 'yes-or-no-p) 'ignore))
2904 (should-error
2905 (make-symbolic-link tmp-name1 tmp-name2 0)
2906 :type 'file-already-exists)))
2892 (cl-letf (((symbol-function 'yes-or-no-p) (lambda (_prompt) t))) 2907 (cl-letf (((symbol-function 'yes-or-no-p) (lambda (_prompt) t)))
2893 (make-symbolic-link tmp-name1 tmp-name2 0) 2908 (make-symbolic-link tmp-name1 tmp-name2 0)
2894 (should 2909 (should
@@ -2923,9 +2938,10 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
2923 (string-equal tmp-name1 (file-symlink-p tmp-name3)))) 2938 (string-equal tmp-name1 (file-symlink-p tmp-name3))))
2924 ;; Check directory as newname. 2939 ;; Check directory as newname.
2925 (make-directory tmp-name4) 2940 (make-directory tmp-name4)
2926 (should-error 2941 (when (tramp--test-expensive-test)
2927 (make-symbolic-link tmp-name1 tmp-name4) 2942 (should-error
2928 :type 'file-already-exists) 2943 (make-symbolic-link tmp-name1 tmp-name4)
2944 :type 'file-already-exists))
2929 (make-symbolic-link tmp-name1 (file-name-as-directory tmp-name4)) 2945 (make-symbolic-link tmp-name1 (file-name-as-directory tmp-name4))
2930 (should 2946 (should
2931 (string-equal 2947 (string-equal
@@ -2947,7 +2963,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
2947 2963
2948 ;; Check `add-name-to-file'. 2964 ;; Check `add-name-to-file'.
2949 (unwind-protect 2965 (unwind-protect
2950 (progn 2966 (when (tramp--test-expensive-test)
2951 (write-region "foo" nil tmp-name1) 2967 (write-region "foo" nil tmp-name1)
2952 (should (file-exists-p tmp-name1)) 2968 (should (file-exists-p tmp-name1))
2953 (add-name-to-file tmp-name1 tmp-name2) 2969 (add-name-to-file tmp-name1 tmp-name2)
@@ -3061,12 +3077,14 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
3061 (string-equal 3077 (string-equal
3062 (file-truename tmp-name2) 3078 (file-truename tmp-name2)
3063 (file-truename tmp-name3))) 3079 (file-truename tmp-name3)))
3064 (should-error 3080 (when (tramp--test-expensive-test)
3065 (with-temp-buffer (insert-file-contents tmp-name2)) 3081 (should-error
3066 :type tramp-file-missing) 3082 (with-temp-buffer (insert-file-contents tmp-name2))
3067 (should-error 3083 :type tramp-file-missing))
3068 (with-temp-buffer (insert-file-contents tmp-name3)) 3084 (when (tramp--test-expensive-test)
3069 :type tramp-file-missing) 3085 (should-error
3086 (with-temp-buffer (insert-file-contents tmp-name3))
3087 :type tramp-file-missing))
3070 ;; `directory-files' does not show symlinks to 3088 ;; `directory-files' does not show symlinks to
3071 ;; non-existing targets in the "smb" case. So we remove 3089 ;; non-existing targets in the "smb" case. So we remove
3072 ;; the symlinks manually. 3090 ;; the symlinks manually.
@@ -3079,18 +3097,19 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
3079 3097
3080 ;; Detect cyclic symbolic links. 3098 ;; Detect cyclic symbolic links.
3081 (unwind-protect 3099 (unwind-protect
3082 (tramp--test-ignore-make-symbolic-link-error 3100 (when (tramp--test-expensive-test)
3083 (make-symbolic-link tmp-name2 tmp-name1) 3101 (tramp--test-ignore-make-symbolic-link-error
3084 (should (file-symlink-p tmp-name1)) 3102 (make-symbolic-link tmp-name2 tmp-name1)
3085 (if (tramp-smb-file-name-p tramp-test-temporary-file-directory) 3103 (should (file-symlink-p tmp-name1))
3086 ;; The symlink command of `smbclient' detects the 3104 (if (tramp-smb-file-name-p tramp-test-temporary-file-directory)
3087 ;; cycle already. 3105 ;; The symlink command of `smbclient' detects the
3088 (should-error 3106 ;; cycle already.
3089 (make-symbolic-link tmp-name1 tmp-name2) 3107 (should-error
3090 :type 'file-error) 3108 (make-symbolic-link tmp-name1 tmp-name2)
3091 (make-symbolic-link tmp-name1 tmp-name2) 3109 :type 'file-error)
3092 (should (file-symlink-p tmp-name2)) 3110 (make-symbolic-link tmp-name1 tmp-name2)
3093 (should-error (file-truename tmp-name1) :type 'file-error))) 3111 (should (file-symlink-p tmp-name2))
3112 (should-error (file-truename tmp-name1) :type 'file-error))))
3094 3113
3095 ;; Cleanup. 3114 ;; Cleanup.
3096 (ignore-errors 3115 (ignore-errors
@@ -3110,7 +3129,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
3110 (skip-unless (tramp--test-enabled)) 3129 (skip-unless (tramp--test-enabled))
3111 (skip-unless (or (tramp--test-adb-p) (tramp--test-sh-p))) 3130 (skip-unless (or (tramp--test-adb-p) (tramp--test-sh-p)))
3112 3131
3113 (dolist (quoted (if tramp--test-expensive-test '(nil t) '(nil))) 3132 (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
3114 (let ((tmp-name1 (tramp--test-make-temp-name nil quoted)) 3133 (let ((tmp-name1 (tramp--test-make-temp-name nil quoted))
3115 (tmp-name2 (tramp--test-make-temp-name nil quoted)) 3134 (tmp-name2 (tramp--test-make-temp-name nil quoted))
3116 (tmp-name3 (tramp--test-make-temp-name nil quoted))) 3135 (tmp-name3 (tramp--test-make-temp-name nil quoted)))
@@ -3144,7 +3163,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
3144 "Check `set-visited-file-modtime' and `verify-visited-file-modtime'." 3163 "Check `set-visited-file-modtime' and `verify-visited-file-modtime'."
3145 (skip-unless (tramp--test-enabled)) 3164 (skip-unless (tramp--test-enabled))
3146 3165
3147 (dolist (quoted (if tramp--test-expensive-test '(nil t) '(nil))) 3166 (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
3148 (let ((tmp-name (tramp--test-make-temp-name nil quoted))) 3167 (let ((tmp-name (tramp--test-make-temp-name nil quoted)))
3149 (unwind-protect 3168 (unwind-protect
3150 (progn 3169 (progn
@@ -3167,7 +3186,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
3167 (skip-unless (file-acl tramp-test-temporary-file-directory)) 3186 (skip-unless (file-acl tramp-test-temporary-file-directory))
3168 3187
3169 ;; `filename-non-special' has been fixed in Emacs 27.1, see Bug#29579. 3188 ;; `filename-non-special' has been fixed in Emacs 27.1, see Bug#29579.
3170 (dolist (quoted (if (and tramp--test-expensive-test (tramp--test-emacs27-p)) 3189 (dolist (quoted (if (and (tramp--test-expensive-test) (tramp--test-emacs27-p))
3171 '(nil t) '(nil))) 3190 '(nil t) '(nil)))
3172 (let ((tmp-name1 (tramp--test-make-temp-name nil quoted)) 3191 (let ((tmp-name1 (tramp--test-make-temp-name nil quoted))
3173 (tmp-name2 (tramp--test-make-temp-name nil quoted)) 3192 (tmp-name2 (tramp--test-make-temp-name nil quoted))
@@ -3245,7 +3264,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
3245 '(nil nil nil nil)))) 3264 '(nil nil nil nil))))
3246 3265
3247 ;; `filename-non-special' has been fixed in Emacs 27.1, see Bug#29579. 3266 ;; `filename-non-special' has been fixed in Emacs 27.1, see Bug#29579.
3248 (dolist (quoted (if (and tramp--test-expensive-test (tramp--test-emacs27-p)) 3267 (dolist (quoted (if (and (tramp--test-expensive-test) (tramp--test-emacs27-p))
3249 '(nil t) '(nil))) 3268 '(nil t) '(nil)))
3250 (let ((tmp-name1 (tramp--test-make-temp-name nil quoted)) 3269 (let ((tmp-name1 (tramp--test-make-temp-name nil quoted))
3251 (tmp-name2 (tramp--test-make-temp-name nil quoted)) 3270 (tmp-name2 (tramp--test-make-temp-name nil quoted))
@@ -3393,7 +3412,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
3393 (unwind-protect 3412 (unwind-protect
3394 (dolist 3413 (dolist
3395 (syntax 3414 (syntax
3396 (if tramp--test-expensive-test 3415 (if (tramp--test-expensive-test)
3397 (tramp-syntax-values) `(,orig-syntax))) 3416 (tramp-syntax-values) `(,orig-syntax)))
3398 (tramp-change-syntax syntax) 3417 (tramp-change-syntax syntax)
3399 (let ;; This is needed for the `simplified' syntax. 3418 (let ;; This is needed for the `simplified' syntax.
@@ -3444,7 +3463,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
3444 (tramp-change-syntax orig-syntax)))) 3463 (tramp-change-syntax orig-syntax))))
3445 3464
3446 (dolist (n-e '(nil t)) 3465 (dolist (n-e '(nil t))
3447 (dolist (quoted (if tramp--test-expensive-test '(nil t) '(nil))) 3466 (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
3448 (let ((non-essential n-e) 3467 (let ((non-essential n-e)
3449 (tmp-name (tramp--test-make-temp-name nil quoted))) 3468 (tmp-name (tramp--test-make-temp-name nil quoted)))
3450 3469
@@ -3506,7 +3525,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
3506 "Check `load'." 3525 "Check `load'."
3507 (skip-unless (tramp--test-enabled)) 3526 (skip-unless (tramp--test-enabled))
3508 3527
3509 (dolist (quoted (if tramp--test-expensive-test '(nil t) '(nil))) 3528 (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
3510 (let ((tmp-name (tramp--test-make-temp-name nil quoted))) 3529 (let ((tmp-name (tramp--test-make-temp-name nil quoted)))
3511 (unwind-protect 3530 (unwind-protect
3512 (progn 3531 (progn
@@ -3531,7 +3550,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
3531 (skip-unless (tramp--test-enabled)) 3550 (skip-unless (tramp--test-enabled))
3532 (skip-unless (or (tramp--test-adb-p) (tramp--test-sh-p))) 3551 (skip-unless (or (tramp--test-adb-p) (tramp--test-sh-p)))
3533 3552
3534 (dolist (quoted (if tramp--test-expensive-test '(nil t) '(nil))) 3553 (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
3535 (let* ((tmp-name (tramp--test-make-temp-name nil quoted)) 3554 (let* ((tmp-name (tramp--test-make-temp-name nil quoted))
3536 (fnnd (file-name-nondirectory tmp-name)) 3555 (fnnd (file-name-nondirectory tmp-name))
3537 (default-directory tramp-test-temporary-file-directory) 3556 (default-directory tramp-test-temporary-file-directory)
@@ -3577,7 +3596,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
3577 (skip-unless (tramp--test-enabled)) 3596 (skip-unless (tramp--test-enabled))
3578 (skip-unless (tramp--test-sh-p)) 3597 (skip-unless (tramp--test-sh-p))
3579 3598
3580 (dolist (quoted (if tramp--test-expensive-test '(nil t) '(nil))) 3599 (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
3581 (let ((default-directory tramp-test-temporary-file-directory) 3600 (let ((default-directory tramp-test-temporary-file-directory)
3582 (tmp-name (tramp--test-make-temp-name nil quoted)) 3601 (tmp-name (tramp--test-make-temp-name nil quoted))
3583 kill-buffer-query-functions proc) 3602 kill-buffer-query-functions proc)
@@ -3669,7 +3688,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
3669 (skip-unless (tramp--test-enabled)) 3688 (skip-unless (tramp--test-enabled))
3670 (skip-unless (tramp--test-sh-p)) 3689 (skip-unless (tramp--test-sh-p))
3671 3690
3672 (dolist (quoted (if tramp--test-expensive-test '(nil t) '(nil))) 3691 (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
3673 (let ((tmp-name (tramp--test-make-temp-name nil quoted)) 3692 (let ((tmp-name (tramp--test-make-temp-name nil quoted))
3674 (default-directory tramp-test-temporary-file-directory) 3693 (default-directory tramp-test-temporary-file-directory)
3675 ;; Suppress nasty messages. 3694 ;; Suppress nasty messages.
@@ -3931,7 +3950,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
3931 (skip-unless (tramp--test-enabled)) 3950 (skip-unless (tramp--test-enabled))
3932 (skip-unless (tramp--test-sh-p)) 3951 (skip-unless (tramp--test-sh-p))
3933 3952
3934 (dolist (quoted (if tramp--test-expensive-test '(nil t) '(nil))) 3953 (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
3935 (let* ((default-directory tramp-test-temporary-file-directory) 3954 (let* ((default-directory tramp-test-temporary-file-directory)
3936 (tmp-name1 (tramp--test-make-temp-name nil quoted)) 3955 (tmp-name1 (tramp--test-make-temp-name nil quoted))
3937 (tmp-name2 (expand-file-name "foo" tmp-name1)) 3956 (tmp-name2 (expand-file-name "foo" tmp-name1))
@@ -3999,7 +4018,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
3999 "Check `make-auto-save-file-name'." 4018 "Check `make-auto-save-file-name'."
4000 (skip-unless (tramp--test-enabled)) 4019 (skip-unless (tramp--test-enabled))
4001 4020
4002 (dolist (quoted (if tramp--test-expensive-test '(nil t) '(nil))) 4021 (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
4003 (let ((tmp-name1 (tramp--test-make-temp-name nil quoted)) 4022 (let ((tmp-name1 (tramp--test-make-temp-name nil quoted))
4004 (tmp-name2 (tramp--test-make-temp-name nil quoted))) 4023 (tmp-name2 (tramp--test-make-temp-name nil quoted)))
4005 4024
@@ -4090,7 +4109,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4090 "Check `find-backup-file-name'." 4109 "Check `find-backup-file-name'."
4091 (skip-unless (tramp--test-enabled)) 4110 (skip-unless (tramp--test-enabled))
4092 4111
4093 (dolist (quoted (if tramp--test-expensive-test '(nil t) '(nil))) 4112 (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
4094 (let ((tmp-name1 (tramp--test-make-temp-name nil quoted)) 4113 (let ((tmp-name1 (tramp--test-make-temp-name nil quoted))
4095 (tmp-name2 (tramp--test-make-temp-name nil quoted)) 4114 (tmp-name2 (tramp--test-make-temp-name nil quoted))
4096 ;; These settings are not used by Tramp, so we ignore them. 4115 ;; These settings are not used by Tramp, so we ignore them.
@@ -4326,7 +4345,7 @@ This requires restrictions of file name syntax."
4326(defun tramp--test-check-files (&rest files) 4345(defun tramp--test-check-files (&rest files)
4327 "Run a simple but comprehensive test over every file in FILES." 4346 "Run a simple but comprehensive test over every file in FILES."
4328 ;; `filename-non-special' has been fixed in Emacs 27.1, see Bug#29579. 4347 ;; `filename-non-special' has been fixed in Emacs 27.1, see Bug#29579.
4329 (dolist (quoted (if (and tramp--test-expensive-test (tramp--test-emacs27-p)) 4348 (dolist (quoted (if (and (tramp--test-expensive-test) (tramp--test-emacs27-p))
4330 '(nil t) '(nil))) 4349 '(nil t) '(nil)))
4331 ;; We must use `file-truename' for the temporary directory, 4350 ;; We must use `file-truename' for the temporary directory,
4332 ;; because it could be located on a symlinked directory. This 4351 ;; because it could be located on a symlinked directory. This
@@ -4459,7 +4478,7 @@ This requires restrictions of file name syntax."
4459 (should-not (file-exists-p file1)))) 4478 (should-not (file-exists-p file1))))
4460 4479
4461 ;; Check, that environment variables are set correctly. 4480 ;; Check, that environment variables are set correctly.
4462 (when (and tramp--test-expensive-test (tramp--test-sh-p)) 4481 (when (and (tramp--test-expensive-test) (tramp--test-sh-p))
4463 (dolist (elt files) 4482 (dolist (elt files)
4464 (let ((envvar (concat "VAR_" (upcase (md5 elt)))) 4483 (let ((envvar (concat "VAR_" (upcase (md5 elt))))
4465 (default-directory tramp-test-temporary-file-directory) 4484 (default-directory tramp-test-temporary-file-directory)
@@ -4489,41 +4508,46 @@ This requires restrictions of file name syntax."
4489 ;; character on Windows or Cygwin, because the backslash is 4508 ;; character on Windows or Cygwin, because the backslash is
4490 ;; interpreted as a path separator, preventing "\t" from being 4509 ;; interpreted as a path separator, preventing "\t" from being
4491 ;; expanded to <TAB>. 4510 ;; expanded to <TAB>.
4492 (tramp--test-check-files 4511 (let ((files
4493 (if (or (tramp--test-gvfs-p) (tramp--test-windows-nt-or-smb-p)) 4512 (list
4494 "foo bar baz" 4513 (if (or (tramp--test-gvfs-p) (tramp--test-windows-nt-or-smb-p))
4495 (if (or (tramp--test-adb-p) 4514 "foo bar baz"
4496 (tramp--test-docker-p) 4515 (if (or (tramp--test-adb-p)
4497 (eq system-type 'cygwin)) 4516 (tramp--test-docker-p)
4498 " foo bar baz " 4517 (eq system-type 'cygwin))
4499 " foo\tbar baz\t")) 4518 " foo bar baz "
4500 "$foo$bar$$baz$" 4519 " foo\tbar baz\t"))
4501 "-foo-bar-baz-" 4520 "$foo$bar$$baz$"
4502 "%foo%bar%baz%" 4521 "-foo-bar-baz-"
4503 "&foo&bar&baz&" 4522 "%foo%bar%baz%"
4504 (unless (or (tramp--test-ftp-p) 4523 "&foo&bar&baz&"
4505 (tramp--test-gvfs-p) 4524 (unless (or (tramp--test-ftp-p)
4506 (tramp--test-windows-nt-or-smb-p)) 4525 (tramp--test-gvfs-p)
4507 "?foo?bar?baz?") 4526 (tramp--test-windows-nt-or-smb-p))
4508 (unless (or (tramp--test-ftp-p) 4527 "?foo?bar?baz?")
4509 (tramp--test-gvfs-p) 4528 (unless (or (tramp--test-ftp-p)
4510 (tramp--test-windows-nt-or-smb-p)) 4529 (tramp--test-gvfs-p)
4511 "*foo*bar*baz*") 4530 (tramp--test-windows-nt-or-smb-p))
4512 (if (or (tramp--test-gvfs-p) (tramp--test-windows-nt-or-smb-p)) 4531 "*foo*bar*baz*")
4513 "'foo'bar'baz'" 4532 (if (or (tramp--test-gvfs-p) (tramp--test-windows-nt-or-smb-p))
4514 "'foo\"bar'baz\"") 4533 "'foo'bar'baz'"
4515 "#foo~bar#baz~" 4534 "'foo\"bar'baz\"")
4516 (if (or (tramp--test-gvfs-p) (tramp--test-windows-nt-or-smb-p)) 4535 "#foo~bar#baz~"
4517 "!foo!bar!baz!" 4536 (if (or (tramp--test-gvfs-p) (tramp--test-windows-nt-or-smb-p))
4518 "!foo|bar!baz|") 4537 "!foo!bar!baz!"
4519 (if (or (tramp--test-gvfs-p) (tramp--test-windows-nt-or-smb-p)) 4538 "!foo|bar!baz|")
4520 ";foo;bar;baz;" 4539 (if (or (tramp--test-gvfs-p) (tramp--test-windows-nt-or-smb-p))
4521 ":foo;bar:baz;") 4540 ";foo;bar;baz;"
4522 (unless (or (tramp--test-gvfs-p) (tramp--test-windows-nt-or-smb-p)) 4541 ":foo;bar:baz;")
4523 "<foo>bar<baz>") 4542 (unless (or (tramp--test-gvfs-p) (tramp--test-windows-nt-or-smb-p))
4524 "(foo)bar(baz)" 4543 "<foo>bar<baz>")
4525 (unless (or (tramp--test-ftp-p) (tramp--test-gvfs-p)) "[foo]bar[baz]") 4544 "(foo)bar(baz)"
4526 "{foo}bar{baz}")) 4545 (unless (or (tramp--test-ftp-p) (tramp--test-gvfs-p)) "[foo]bar[baz]")
4546 "{foo}bar{baz}")))
4547 ;; Simplify test in order to speed up.
4548 (apply 'tramp--test-check-files
4549 (if (tramp--test-expensive-test)
4550 files (list (mapconcat 'identity files ""))))))
4527 4551
4528;; These tests are inspired by Bug#17238. 4552;; These tests are inspired by Bug#17238.
4529(ert-deftest tramp-test38-special-characters () 4553(ert-deftest tramp-test38-special-characters ()
@@ -4742,11 +4766,11 @@ process sentinels. They shall not disturb each other."
4742 ;; Number of asynchronous processes for test. Tests on 4766 ;; Number of asynchronous processes for test. Tests on
4743 ;; some machines handle less parallel processes. 4767 ;; some machines handle less parallel processes.
4744 (number-proc 4768 (number-proc
4745 (or 4769 (cond
4746 (ignore-errors 4770 ((ignore-errors
4747 (string-to-number (getenv "REMOTE_PARALLEL_PROCESSES"))) 4771 (string-to-number (getenv "REMOTE_PARALLEL_PROCESSES"))))
4748 (if (getenv "EMACS_HYDRA_CI") 5) 4772 ((getenv "EMACS_HYDRA_CI") 5)
4749 10)) 4773 (t 10)))
4750 ;; On hydra, timings are bad. 4774 ;; On hydra, timings are bad.
4751 (timer-repeat 4775 (timer-repeat
4752 (cond 4776 (cond