diff options
| author | Michael Albinus | 2017-09-13 20:10:40 +0200 |
|---|---|---|
| committer | Michael Albinus | 2017-09-13 20:10:40 +0200 |
| commit | 4ab44f75d6ad7eb378c85c111ea1006076cf994b (patch) | |
| tree | 3ff3df277e62dc31d284a59f0e7eeaa90f75169f | |
| parent | 516481156c91822ba217661272ef410b2252e97e (diff) | |
| download | emacs-4ab44f75d6ad7eb378c85c111ea1006076cf994b.tar.gz emacs-4ab44f75d6ad7eb378c85c111ea1006076cf994b.zip | |
Improve backward compatibility of tramp-tests
* test/lisp/net/tramp-tests.el (seq): Don't require.
(tramp--test-emacs26-p): New defun.
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test15-copy-directory)
(tramp-test21-file-links): Use it.
(tramp-test16-file-expand-wildcards): Use `copy-sequence'.
| -rw-r--r-- | test/lisp/net/tramp-tests.el | 135 |
1 files changed, 84 insertions, 51 deletions
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index d5fec30384b..8d30570a0c9 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el | |||
| @@ -39,7 +39,6 @@ | |||
| 39 | 39 | ||
| 40 | (require 'dired) | 40 | (require 'dired) |
| 41 | (require 'ert) | 41 | (require 'ert) |
| 42 | (require 'seq) | ||
| 43 | (require 'tramp) | 42 | (require 'tramp) |
| 44 | (require 'vc) | 43 | (require 'vc) |
| 45 | (require 'vc-bzr) | 44 | (require 'vc-bzr) |
| @@ -1862,11 +1861,8 @@ This checks also `file-name-as-directory', `file-name-directory', | |||
| 1862 | ;; Do not overwrite if excluded. | 1861 | ;; Do not overwrite if excluded. |
| 1863 | (cl-letf (((symbol-function 'y-or-n-p) (lambda (_prompt) t))) | 1862 | (cl-letf (((symbol-function 'y-or-n-p) (lambda (_prompt) t))) |
| 1864 | (write-region "foo" nil tmp-name nil nil nil 'mustbenew)) | 1863 | (write-region "foo" nil tmp-name nil nil nil 'mustbenew)) |
| 1865 | ;; `mustbenew' is passed to Tramp since Emacs 26.1. We | 1864 | ;; `mustbenew' is passed to Tramp since Emacs 26.1. |
| 1866 | ;; have no test for this, so we check function | 1865 | (when (tramp--test-emacs26-p) |
| 1867 | ;; `temporary-file-directory', which has been added to | ||
| 1868 | ;; Emacs 26.1 as well. | ||
| 1869 | (when (fboundp 'temporary-file-directory) | ||
| 1870 | (should-error | 1866 | (should-error |
| 1871 | (cl-letf (((symbol-function 'y-or-n-p) 'ignore)) | 1867 | (cl-letf (((symbol-function 'y-or-n-p) 'ignore)) |
| 1872 | (write-region "foo" nil tmp-name nil nil nil 'mustbenew)) | 1868 | (write-region "foo" nil tmp-name nil nil nil 'mustbenew)) |
| @@ -1905,9 +1901,11 @@ This checks also `file-name-as-directory', `file-name-directory', | |||
| 1905 | :type 'file-already-exists) | 1901 | :type 'file-already-exists) |
| 1906 | (copy-file tmp-name1 tmp-name2 'ok) | 1902 | (copy-file tmp-name1 tmp-name2 'ok) |
| 1907 | (make-directory tmp-name3) | 1903 | (make-directory tmp-name3) |
| 1908 | (should-error | 1904 | ;; This has been changed in Emacs 26.1. |
| 1909 | (copy-file tmp-name1 tmp-name3) | 1905 | (when (tramp--test-emacs26-p) |
| 1910 | :type 'file-already-exists) | 1906 | (should-error |
| 1907 | (copy-file tmp-name1 tmp-name3) | ||
| 1908 | :type 'file-already-exists)) | ||
| 1911 | (copy-file tmp-name1 (file-name-as-directory tmp-name3)) | 1909 | (copy-file tmp-name1 (file-name-as-directory tmp-name3)) |
| 1912 | (should | 1910 | (should |
| 1913 | (file-exists-p | 1911 | (file-exists-p |
| @@ -1932,9 +1930,11 @@ This checks also `file-name-as-directory', `file-name-directory', | |||
| 1932 | :type 'file-already-exists) | 1930 | :type 'file-already-exists) |
| 1933 | (copy-file tmp-name1 tmp-name4 'ok) | 1931 | (copy-file tmp-name1 tmp-name4 'ok) |
| 1934 | (make-directory tmp-name5) | 1932 | (make-directory tmp-name5) |
| 1935 | (should-error | 1933 | ;; This has been changed in Emacs 26.1. |
| 1936 | (copy-file tmp-name1 tmp-name5) | 1934 | (when (tramp--test-emacs26-p) |
| 1937 | :type 'file-already-exists) | 1935 | (should-error |
| 1936 | (copy-file tmp-name1 tmp-name5) | ||
| 1937 | :type 'file-already-exists)) | ||
| 1938 | (copy-file tmp-name1 (file-name-as-directory tmp-name5)) | 1938 | (copy-file tmp-name1 (file-name-as-directory tmp-name5)) |
| 1939 | (should | 1939 | (should |
| 1940 | (file-exists-p | 1940 | (file-exists-p |
| @@ -1959,9 +1959,11 @@ This checks also `file-name-as-directory', `file-name-directory', | |||
| 1959 | :type 'file-already-exists) | 1959 | :type 'file-already-exists) |
| 1960 | (copy-file tmp-name4 tmp-name1 'ok) | 1960 | (copy-file tmp-name4 tmp-name1 'ok) |
| 1961 | (make-directory tmp-name3) | 1961 | (make-directory tmp-name3) |
| 1962 | (should-error | 1962 | ;; This has been changed in Emacs 26.1. |
| 1963 | (copy-file tmp-name4 tmp-name3) | 1963 | (when (tramp--test-emacs26-p) |
| 1964 | :type 'file-already-exists) | 1964 | (should-error |
| 1965 | (copy-file tmp-name4 tmp-name3) | ||
| 1966 | :type 'file-already-exists)) | ||
| 1965 | (copy-file tmp-name4 (file-name-as-directory tmp-name3)) | 1967 | (copy-file tmp-name4 (file-name-as-directory tmp-name3)) |
| 1966 | (should | 1968 | (should |
| 1967 | (file-exists-p | 1969 | (file-exists-p |
| @@ -2003,9 +2005,11 @@ This checks also `file-name-as-directory', `file-name-directory', | |||
| 2003 | (should-not (file-exists-p tmp-name1)) | 2005 | (should-not (file-exists-p tmp-name1)) |
| 2004 | (write-region "foo" nil tmp-name1) | 2006 | (write-region "foo" nil tmp-name1) |
| 2005 | (make-directory tmp-name3) | 2007 | (make-directory tmp-name3) |
| 2006 | (should-error | 2008 | ;; This has been changed in Emacs 26.1. |
| 2007 | (rename-file tmp-name1 tmp-name3) | 2009 | (when (tramp--test-emacs26-p) |
| 2008 | :type 'file-already-exists) | 2010 | (should-error |
| 2011 | (rename-file tmp-name1 tmp-name3) | ||
| 2012 | :type 'file-already-exists)) | ||
| 2009 | (rename-file tmp-name1 (file-name-as-directory tmp-name3)) | 2013 | (rename-file tmp-name1 (file-name-as-directory tmp-name3)) |
| 2010 | (should-not (file-exists-p tmp-name1)) | 2014 | (should-not (file-exists-p tmp-name1)) |
| 2011 | (should | 2015 | (should |
| @@ -2035,9 +2039,11 @@ This checks also `file-name-as-directory', `file-name-directory', | |||
| 2035 | (should-not (file-exists-p tmp-name1)) | 2039 | (should-not (file-exists-p tmp-name1)) |
| 2036 | (write-region "foo" nil tmp-name1) | 2040 | (write-region "foo" nil tmp-name1) |
| 2037 | (make-directory tmp-name5) | 2041 | (make-directory tmp-name5) |
| 2038 | (should-error | 2042 | ;; This has been changed in Emacs 26.1. |
| 2039 | (rename-file tmp-name1 tmp-name5) | 2043 | (when (tramp--test-emacs26-p) |
| 2040 | :type 'file-already-exists) | 2044 | (should-error |
| 2045 | (rename-file tmp-name1 tmp-name5) | ||
| 2046 | :type 'file-already-exists)) | ||
| 2041 | (rename-file tmp-name1 (file-name-as-directory tmp-name5)) | 2047 | (rename-file tmp-name1 (file-name-as-directory tmp-name5)) |
| 2042 | (should-not (file-exists-p tmp-name1)) | 2048 | (should-not (file-exists-p tmp-name1)) |
| 2043 | (should | 2049 | (should |
| @@ -2067,9 +2073,11 @@ This checks also `file-name-as-directory', `file-name-directory', | |||
| 2067 | (should-not (file-exists-p tmp-name4)) | 2073 | (should-not (file-exists-p tmp-name4)) |
| 2068 | (write-region "foo" nil tmp-name4 nil 'nomessage) | 2074 | (write-region "foo" nil tmp-name4 nil 'nomessage) |
| 2069 | (make-directory tmp-name3) | 2075 | (make-directory tmp-name3) |
| 2070 | (should-error | 2076 | ;; This has been changed in Emacs 26.1. |
| 2071 | (rename-file tmp-name4 tmp-name3) | 2077 | (when (tramp--test-emacs26-p) |
| 2072 | :type 'file-already-exists) | 2078 | (should-error |
| 2079 | (rename-file tmp-name4 tmp-name3) | ||
| 2080 | :type 'file-already-exists)) | ||
| 2073 | (rename-file tmp-name4 (file-name-as-directory tmp-name3)) | 2081 | (rename-file tmp-name4 (file-name-as-directory tmp-name3)) |
| 2074 | (should-not (file-exists-p tmp-name4)) | 2082 | (should-not (file-exists-p tmp-name4)) |
| 2075 | (should | 2083 | (should |
| @@ -2147,9 +2155,11 @@ This tests also `file-directory-p' and `file-accessible-directory-p'." | |||
| 2147 | (should (file-directory-p tmp-name2)) | 2155 | (should (file-directory-p tmp-name2)) |
| 2148 | (should (file-exists-p tmp-name5)) | 2156 | (should (file-exists-p tmp-name5)) |
| 2149 | ;; Target directory does exist already. | 2157 | ;; Target directory does exist already. |
| 2150 | (should-error | 2158 | ;; This has been changed in Emacs 26.1. |
| 2151 | (copy-directory tmp-name1 tmp-name2) | 2159 | (when (tramp--test-emacs26-p) |
| 2152 | :type 'file-error) | 2160 | (should-error |
| 2161 | (copy-directory tmp-name1 tmp-name2) | ||
| 2162 | :type 'file-error)) | ||
| 2153 | (copy-directory tmp-name1 (file-name-as-directory tmp-name2)) | 2163 | (copy-directory tmp-name1 (file-name-as-directory tmp-name2)) |
| 2154 | (should (file-directory-p tmp-name3)) | 2164 | (should (file-directory-p tmp-name3)) |
| 2155 | (should (file-exists-p tmp-name6))) | 2165 | (should (file-exists-p tmp-name6))) |
| @@ -2240,30 +2250,44 @@ This tests also `file-directory-p' and `file-accessible-directory-p'." | |||
| 2240 | (should (file-exists-p tmp-name3)) | 2250 | (should (file-exists-p tmp-name3)) |
| 2241 | (should (file-exists-p tmp-name4)) | 2251 | (should (file-exists-p tmp-name4)) |
| 2242 | 2252 | ||
| 2243 | ;; We cannot use `sort', it works destructive. | 2253 | ;; `sort' works destructive. |
| 2244 | (should (equal (file-expand-wildcards "*") | 2254 | (should |
| 2245 | (seq-sort 'string< '("foo" "bar" "baz")))) | 2255 | (equal (file-expand-wildcards "*") |
| 2246 | (should (equal (file-expand-wildcards "ba?") | 2256 | (sort (copy-sequence '("foo" "bar" "baz")) 'string<))) |
| 2247 | (seq-sort 'string< '("bar" "baz")))) | 2257 | (should |
| 2248 | (should (equal (file-expand-wildcards "ba[rz]") | 2258 | (equal (file-expand-wildcards "ba?") |
| 2249 | (seq-sort 'string< '("bar" "baz")))) | 2259 | (sort (copy-sequence '("bar" "baz")) 'string<))) |
| 2250 | 2260 | (should | |
| 2251 | (should (equal (file-expand-wildcards "*" 'full) | 2261 | (equal (file-expand-wildcards "ba[rz]") |
| 2252 | (seq-sort | 2262 | (sort (copy-sequence '("bar" "baz")) 'string<))) |
| 2253 | 'string< `(,tmp-name2 ,tmp-name3 ,tmp-name4)))) | 2263 | |
| 2254 | (should (equal (file-expand-wildcards "ba?" 'full) | 2264 | (should |
| 2255 | (seq-sort 'string< `(,tmp-name3 ,tmp-name4)))) | 2265 | (equal |
| 2256 | (should (equal (file-expand-wildcards "ba[rz]" 'full) | 2266 | (file-expand-wildcards "*" 'full) |
| 2257 | (seq-sort 'string< `(,tmp-name3 ,tmp-name4)))) | 2267 | (sort |
| 2258 | 2268 | (copy-sequence `(,tmp-name2 ,tmp-name3 ,tmp-name4)) 'string<))) | |
| 2259 | (should (equal (file-expand-wildcards (concat tmp-name1 "/" "*")) | 2269 | (should |
| 2260 | (seq-sort | 2270 | (equal |
| 2261 | 'string< `(,tmp-name2 ,tmp-name3 ,tmp-name4)))) | 2271 | (file-expand-wildcards "ba?" 'full) |
| 2262 | (should (equal (file-expand-wildcards (concat tmp-name1 "/" "ba?")) | 2272 | (sort (copy-sequence `(,tmp-name3 ,tmp-name4)) 'string<))) |
| 2263 | (seq-sort 'string< `(,tmp-name3 ,tmp-name4)))) | 2273 | (should |
| 2264 | (should (equal (file-expand-wildcards | 2274 | (equal |
| 2265 | (concat tmp-name1 "/" "ba[rz]")) | 2275 | (file-expand-wildcards "ba[rz]" 'full) |
| 2266 | (seq-sort 'string< `(,tmp-name3 ,tmp-name4))))) | 2276 | (sort (copy-sequence `(,tmp-name3 ,tmp-name4)) 'string<))) |
| 2277 | |||
| 2278 | (should | ||
| 2279 | (equal | ||
| 2280 | (file-expand-wildcards (concat tmp-name1 "/" "*")) | ||
| 2281 | (sort | ||
| 2282 | (copy-sequence `(,tmp-name2 ,tmp-name3 ,tmp-name4)) 'string<))) | ||
| 2283 | (should | ||
| 2284 | (equal | ||
| 2285 | (file-expand-wildcards (concat tmp-name1 "/" "ba?")) | ||
| 2286 | (sort (copy-sequence `(,tmp-name3 ,tmp-name4)) 'string<))) | ||
| 2287 | (should | ||
| 2288 | (equal | ||
| 2289 | (file-expand-wildcards (concat tmp-name1 "/" "ba[rz]")) | ||
| 2290 | (sort (copy-sequence `(,tmp-name3 ,tmp-name4)) 'string<)))) | ||
| 2267 | 2291 | ||
| 2268 | ;; Cleanup. | 2292 | ;; Cleanup. |
| 2269 | (ignore-errors | 2293 | (ignore-errors |
| @@ -2616,6 +2640,9 @@ This tests also `file-executable-p', `file-writable-p' and `set-file-modes'." | |||
| 2616 | "Check `file-symlink-p'. | 2640 | "Check `file-symlink-p'. |
| 2617 | This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | 2641 | This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." |
| 2618 | (skip-unless (tramp--test-enabled)) | 2642 | (skip-unless (tramp--test-enabled)) |
| 2643 | ;; The semantics has changed heavily in Emacs 26.1. We cannot test | ||
| 2644 | ;; older Emacsen, therefore. | ||
| 2645 | (skip-unless (tramp--test-emacs26-p)) | ||
| 2619 | 2646 | ||
| 2620 | (dolist (quoted (if tramp--test-expensive-test '(nil t) '(nil))) | 2647 | (dolist (quoted (if tramp--test-expensive-test '(nil t) '(nil))) |
| 2621 | ;; We must use `file-truename' for the temporary directory, | 2648 | ;; We must use `file-truename' for the temporary directory, |
| @@ -3648,6 +3675,12 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 3648 | (delete-directory tmp-file) | 3675 | (delete-directory tmp-file) |
| 3649 | (should-not (file-exists-p tmp-file)))) | 3676 | (should-not (file-exists-p tmp-file)))) |
| 3650 | 3677 | ||
| 3678 | (defun tramp--test-emacs26-p () | ||
| 3679 | "Check for Emacs version >= 26.1. | ||
| 3680 | Some semantics has been changed for there, w/o new functions or | ||
| 3681 | variables, so we check function Emacs version directly." | ||
| 3682 | (>= emacs-major-version 26)) | ||
| 3683 | |||
| 3651 | (defun tramp--test-adb-p () | 3684 | (defun tramp--test-adb-p () |
| 3652 | "Check, whether the remote host runs Android. | 3685 | "Check, whether the remote host runs Android. |
| 3653 | This requires restrictions of file name syntax." | 3686 | This requires restrictions of file name syntax." |