diff options
| author | Michael Albinus | 2017-09-12 11:20:49 +0200 |
|---|---|---|
| committer | Michael Albinus | 2017-09-12 11:20:49 +0200 |
| commit | 49a42fbd27c3235d7183bc2adf7d413903985dc0 (patch) | |
| tree | b63e8bc4d6d32b161940885d591de1dd106bc2a1 | |
| parent | 370e04fbb206c59c6a2251dc54f69c61887f60cc (diff) | |
| download | emacs-49a42fbd27c3235d7183bc2adf7d413903985dc0.tar.gz emacs-49a42fbd27c3235d7183bc2adf7d413903985dc0.zip | |
Extend tramp-tests according to bug#27986
* test/lisp/net/tramp-tests.el (tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test15-copy-directory)
(tramp-test21-file-links): Extend tests.
(tramp-test13-make-directory, tramp-test14-delete-directory):
Specifiy error symbol in `should-error'.
| -rw-r--r-- | test/lisp/net/tramp-tests.el | 95 |
1 files changed, 78 insertions, 17 deletions
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 13e2e30cab4..d5fec30384b 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el | |||
| @@ -1900,9 +1900,14 @@ This checks also `file-name-as-directory', `file-name-directory', | |||
| 1900 | (with-temp-buffer | 1900 | (with-temp-buffer |
| 1901 | (insert-file-contents tmp-name2) | 1901 | (insert-file-contents tmp-name2) |
| 1902 | (should (string-equal (buffer-string) "foo"))) | 1902 | (should (string-equal (buffer-string) "foo"))) |
| 1903 | (should-error (copy-file tmp-name1 tmp-name2)) | 1903 | (should-error |
| 1904 | (copy-file tmp-name1 tmp-name2) | ||
| 1905 | :type 'file-already-exists) | ||
| 1904 | (copy-file tmp-name1 tmp-name2 'ok) | 1906 | (copy-file tmp-name1 tmp-name2 'ok) |
| 1905 | (make-directory tmp-name3) | 1907 | (make-directory tmp-name3) |
| 1908 | (should-error | ||
| 1909 | (copy-file tmp-name1 tmp-name3) | ||
| 1910 | :type 'file-already-exists) | ||
| 1906 | (copy-file tmp-name1 (file-name-as-directory tmp-name3)) | 1911 | (copy-file tmp-name1 (file-name-as-directory tmp-name3)) |
| 1907 | (should | 1912 | (should |
| 1908 | (file-exists-p | 1913 | (file-exists-p |
| @@ -1922,9 +1927,14 @@ This checks also `file-name-as-directory', `file-name-directory', | |||
| 1922 | (with-temp-buffer | 1927 | (with-temp-buffer |
| 1923 | (insert-file-contents tmp-name4) | 1928 | (insert-file-contents tmp-name4) |
| 1924 | (should (string-equal (buffer-string) "foo"))) | 1929 | (should (string-equal (buffer-string) "foo"))) |
| 1925 | (should-error (copy-file tmp-name1 tmp-name4)) | 1930 | (should-error |
| 1931 | (copy-file tmp-name1 tmp-name4) | ||
| 1932 | :type 'file-already-exists) | ||
| 1926 | (copy-file tmp-name1 tmp-name4 'ok) | 1933 | (copy-file tmp-name1 tmp-name4 'ok) |
| 1927 | (make-directory tmp-name5) | 1934 | (make-directory tmp-name5) |
| 1935 | (should-error | ||
| 1936 | (copy-file tmp-name1 tmp-name5) | ||
| 1937 | :type 'file-already-exists) | ||
| 1928 | (copy-file tmp-name1 (file-name-as-directory tmp-name5)) | 1938 | (copy-file tmp-name1 (file-name-as-directory tmp-name5)) |
| 1929 | (should | 1939 | (should |
| 1930 | (file-exists-p | 1940 | (file-exists-p |
| @@ -1944,9 +1954,14 @@ This checks also `file-name-as-directory', `file-name-directory', | |||
| 1944 | (with-temp-buffer | 1954 | (with-temp-buffer |
| 1945 | (insert-file-contents tmp-name1) | 1955 | (insert-file-contents tmp-name1) |
| 1946 | (should (string-equal (buffer-string) "foo"))) | 1956 | (should (string-equal (buffer-string) "foo"))) |
| 1947 | (should-error (copy-file tmp-name4 tmp-name1)) | 1957 | (should-error |
| 1958 | (copy-file tmp-name4 tmp-name1) | ||
| 1959 | :type 'file-already-exists) | ||
| 1948 | (copy-file tmp-name4 tmp-name1 'ok) | 1960 | (copy-file tmp-name4 tmp-name1 'ok) |
| 1949 | (make-directory tmp-name3) | 1961 | (make-directory tmp-name3) |
| 1962 | (should-error | ||
| 1963 | (copy-file tmp-name4 tmp-name3) | ||
| 1964 | :type 'file-already-exists) | ||
| 1950 | (copy-file tmp-name4 (file-name-as-directory tmp-name3)) | 1965 | (copy-file tmp-name4 (file-name-as-directory tmp-name3)) |
| 1951 | (should | 1966 | (should |
| 1952 | (file-exists-p | 1967 | (file-exists-p |
| @@ -1981,11 +1996,16 @@ This checks also `file-name-as-directory', `file-name-directory', | |||
| 1981 | (insert-file-contents tmp-name2) | 1996 | (insert-file-contents tmp-name2) |
| 1982 | (should (string-equal (buffer-string) "foo"))) | 1997 | (should (string-equal (buffer-string) "foo"))) |
| 1983 | (write-region "foo" nil tmp-name1) | 1998 | (write-region "foo" nil tmp-name1) |
| 1984 | (should-error (rename-file tmp-name1 tmp-name2)) | 1999 | (should-error |
| 2000 | (rename-file tmp-name1 tmp-name2) | ||
| 2001 | :type 'file-already-exists) | ||
| 1985 | (rename-file tmp-name1 tmp-name2 'ok) | 2002 | (rename-file tmp-name1 tmp-name2 'ok) |
| 1986 | (should-not (file-exists-p tmp-name1)) | 2003 | (should-not (file-exists-p tmp-name1)) |
| 1987 | (write-region "foo" nil tmp-name1) | 2004 | (write-region "foo" nil tmp-name1) |
| 1988 | (make-directory tmp-name3) | 2005 | (make-directory tmp-name3) |
| 2006 | (should-error | ||
| 2007 | (rename-file tmp-name1 tmp-name3) | ||
| 2008 | :type 'file-already-exists) | ||
| 1989 | (rename-file tmp-name1 (file-name-as-directory tmp-name3)) | 2009 | (rename-file tmp-name1 (file-name-as-directory tmp-name3)) |
| 1990 | (should-not (file-exists-p tmp-name1)) | 2010 | (should-not (file-exists-p tmp-name1)) |
| 1991 | (should | 2011 | (should |
| @@ -2008,11 +2028,16 @@ This checks also `file-name-as-directory', `file-name-directory', | |||
| 2008 | (insert-file-contents tmp-name4) | 2028 | (insert-file-contents tmp-name4) |
| 2009 | (should (string-equal (buffer-string) "foo"))) | 2029 | (should (string-equal (buffer-string) "foo"))) |
| 2010 | (write-region "foo" nil tmp-name1) | 2030 | (write-region "foo" nil tmp-name1) |
| 2011 | (should-error (rename-file tmp-name1 tmp-name4)) | 2031 | (should-error |
| 2032 | (rename-file tmp-name1 tmp-name4) | ||
| 2033 | :type 'file-already-exists) | ||
| 2012 | (rename-file tmp-name1 tmp-name4 'ok) | 2034 | (rename-file tmp-name1 tmp-name4 'ok) |
| 2013 | (should-not (file-exists-p tmp-name1)) | 2035 | (should-not (file-exists-p tmp-name1)) |
| 2014 | (write-region "foo" nil tmp-name1) | 2036 | (write-region "foo" nil tmp-name1) |
| 2015 | (make-directory tmp-name5) | 2037 | (make-directory tmp-name5) |
| 2038 | (should-error | ||
| 2039 | (rename-file tmp-name1 tmp-name5) | ||
| 2040 | :type 'file-already-exists) | ||
| 2016 | (rename-file tmp-name1 (file-name-as-directory tmp-name5)) | 2041 | (rename-file tmp-name1 (file-name-as-directory tmp-name5)) |
| 2017 | (should-not (file-exists-p tmp-name1)) | 2042 | (should-not (file-exists-p tmp-name1)) |
| 2018 | (should | 2043 | (should |
| @@ -2035,11 +2060,16 @@ This checks also `file-name-as-directory', `file-name-directory', | |||
| 2035 | (insert-file-contents tmp-name1) | 2060 | (insert-file-contents tmp-name1) |
| 2036 | (should (string-equal (buffer-string) "foo"))) | 2061 | (should (string-equal (buffer-string) "foo"))) |
| 2037 | (write-region "foo" nil tmp-name4 nil 'nomessage) | 2062 | (write-region "foo" nil tmp-name4 nil 'nomessage) |
| 2038 | (should-error (rename-file tmp-name4 tmp-name1)) | 2063 | (should-error |
| 2064 | (rename-file tmp-name4 tmp-name1) | ||
| 2065 | :type 'file-already-exists) | ||
| 2039 | (rename-file tmp-name4 tmp-name1 'ok) | 2066 | (rename-file tmp-name4 tmp-name1 'ok) |
| 2040 | (should-not (file-exists-p tmp-name4)) | 2067 | (should-not (file-exists-p tmp-name4)) |
| 2041 | (write-region "foo" nil tmp-name4 nil 'nomessage) | 2068 | (write-region "foo" nil tmp-name4 nil 'nomessage) |
| 2042 | (make-directory tmp-name3) | 2069 | (make-directory tmp-name3) |
| 2070 | (should-error | ||
| 2071 | (rename-file tmp-name4 tmp-name3) | ||
| 2072 | :type 'file-already-exists) | ||
| 2043 | (rename-file tmp-name4 (file-name-as-directory tmp-name3)) | 2073 | (rename-file tmp-name4 (file-name-as-directory tmp-name3)) |
| 2044 | (should-not (file-exists-p tmp-name4)) | 2074 | (should-not (file-exists-p tmp-name4)) |
| 2045 | (should | 2075 | (should |
| @@ -2064,7 +2094,7 @@ This tests also `file-directory-p' and `file-accessible-directory-p'." | |||
| 2064 | (make-directory tmp-name1) | 2094 | (make-directory tmp-name1) |
| 2065 | (should (file-directory-p tmp-name1)) | 2095 | (should (file-directory-p tmp-name1)) |
| 2066 | (should (file-accessible-directory-p tmp-name1)) | 2096 | (should (file-accessible-directory-p tmp-name1)) |
| 2067 | (should-error (make-directory tmp-name2)) | 2097 | (should-error (make-directory tmp-name2) :type 'file-error) |
| 2068 | (make-directory tmp-name2 'parents) | 2098 | (make-directory tmp-name2 'parents) |
| 2069 | (should (file-directory-p tmp-name2)) | 2099 | (should (file-directory-p tmp-name2)) |
| 2070 | (should (file-accessible-directory-p tmp-name2))) | 2100 | (should (file-accessible-directory-p tmp-name2))) |
| @@ -2088,7 +2118,7 @@ This tests also `file-directory-p' and `file-accessible-directory-p'." | |||
| 2088 | (should (file-directory-p tmp-name)) | 2118 | (should (file-directory-p tmp-name)) |
| 2089 | (write-region "foo" nil (expand-file-name "bla" tmp-name)) | 2119 | (write-region "foo" nil (expand-file-name "bla" tmp-name)) |
| 2090 | (should (file-exists-p (expand-file-name "bla" tmp-name))) | 2120 | (should (file-exists-p (expand-file-name "bla" tmp-name))) |
| 2091 | (should-error (delete-directory tmp-name)) | 2121 | (should-error (delete-directory tmp-name) :type 'file-error) |
| 2092 | (delete-directory tmp-name 'recursive) | 2122 | (delete-directory tmp-name 'recursive) |
| 2093 | (should-not (file-directory-p tmp-name))))) | 2123 | (should-not (file-directory-p tmp-name))))) |
| 2094 | 2124 | ||
| @@ -2117,6 +2147,9 @@ This tests also `file-directory-p' and `file-accessible-directory-p'." | |||
| 2117 | (should (file-directory-p tmp-name2)) | 2147 | (should (file-directory-p tmp-name2)) |
| 2118 | (should (file-exists-p tmp-name5)) | 2148 | (should (file-exists-p tmp-name5)) |
| 2119 | ;; Target directory does exist already. | 2149 | ;; Target directory does exist already. |
| 2150 | (should-error | ||
| 2151 | (copy-directory tmp-name1 tmp-name2) | ||
| 2152 | :type 'file-error) | ||
| 2120 | (copy-directory tmp-name1 (file-name-as-directory tmp-name2)) | 2153 | (copy-directory tmp-name1 (file-name-as-directory tmp-name2)) |
| 2121 | (should (file-directory-p tmp-name3)) | 2154 | (should (file-directory-p tmp-name3)) |
| 2122 | (should (file-exists-p tmp-name6))) | 2155 | (should (file-exists-p tmp-name6))) |
| @@ -2140,8 +2173,9 @@ This tests also `file-directory-p' and `file-accessible-directory-p'." | |||
| 2140 | ;; Target directory does exist already. | 2173 | ;; Target directory does exist already. |
| 2141 | (delete-file tmp-name5) | 2174 | (delete-file tmp-name5) |
| 2142 | (should-not (file-exists-p tmp-name5)) | 2175 | (should-not (file-exists-p tmp-name5)) |
| 2143 | (copy-directory tmp-name1 (file-name-as-directory tmp-name2) | 2176 | (copy-directory |
| 2144 | nil 'parents 'contents) | 2177 | tmp-name1 (file-name-as-directory tmp-name2) |
| 2178 | nil 'parents 'contents) | ||
| 2145 | (should (file-directory-p tmp-name2)) | 2179 | (should (file-directory-p tmp-name2)) |
| 2146 | (should (file-exists-p tmp-name5)) | 2180 | (should (file-exists-p tmp-name5)) |
| 2147 | (should-not (file-directory-p tmp-name3)) | 2181 | (should-not (file-directory-p tmp-name3)) |
| @@ -2591,7 +2625,8 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 2591 | (file-truename tramp-test-temporary-file-directory)) | 2625 | (file-truename tramp-test-temporary-file-directory)) |
| 2592 | (tmp-name1 (tramp--test-make-temp-name nil quoted)) | 2626 | (tmp-name1 (tramp--test-make-temp-name nil quoted)) |
| 2593 | (tmp-name2 (tramp--test-make-temp-name nil quoted)) | 2627 | (tmp-name2 (tramp--test-make-temp-name nil quoted)) |
| 2594 | (tmp-name3 (tramp--test-make-temp-name 'local quoted))) | 2628 | (tmp-name3 (tramp--test-make-temp-name 'local quoted)) |
| 2629 | (tmp-name4 (tramp--test-make-temp-name nil quoted))) | ||
| 2595 | 2630 | ||
| 2596 | ;; Check `make-symbolic-link'. | 2631 | ;; Check `make-symbolic-link'. |
| 2597 | (unwind-protect | 2632 | (unwind-protect |
| @@ -2642,13 +2677,28 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 2642 | ;; target remains unchanged, even if quoted. | 2677 | ;; target remains unchanged, even if quoted. |
| 2643 | (make-symbolic-link tmp-name1 tmp-name3) | 2678 | (make-symbolic-link tmp-name1 tmp-name3) |
| 2644 | (should | 2679 | (should |
| 2645 | (string-equal tmp-name1 (file-symlink-p tmp-name3)))) | 2680 | (string-equal tmp-name1 (file-symlink-p tmp-name3))) |
| 2681 | ;; Check directory as newname. | ||
| 2682 | (make-directory tmp-name4) | ||
| 2683 | (should-error | ||
| 2684 | (make-symbolic-link tmp-name1 tmp-name4) | ||
| 2685 | :type 'file-already-exists) | ||
| 2686 | (make-symbolic-link tmp-name1 (file-name-as-directory tmp-name4)) | ||
| 2687 | (should | ||
| 2688 | (string-equal | ||
| 2689 | (funcall | ||
| 2690 | (if quoted 'tramp-compat-file-name-unquote 'identity) | ||
| 2691 | (file-remote-p tmp-name1 'localname)) | ||
| 2692 | (file-symlink-p | ||
| 2693 | (expand-file-name | ||
| 2694 | (file-name-nondirectory tmp-name1) tmp-name4))))) | ||
| 2646 | 2695 | ||
| 2647 | ;; Cleanup. | 2696 | ;; Cleanup. |
| 2648 | (ignore-errors | 2697 | (ignore-errors |
| 2649 | (delete-file tmp-name1) | 2698 | (delete-file tmp-name1) |
| 2650 | (delete-file tmp-name2) | 2699 | (delete-file tmp-name2) |
| 2651 | (delete-file tmp-name3))) | 2700 | (delete-file tmp-name3) |
| 2701 | (delete-directory tmp-name4 'recursive))) | ||
| 2652 | 2702 | ||
| 2653 | ;; Check `add-name-to-file'. | 2703 | ;; Check `add-name-to-file'. |
| 2654 | (unwind-protect | 2704 | (unwind-protect |
| @@ -2674,12 +2724,22 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 2674 | ;; `tmp-name3' is a local file name. | 2724 | ;; `tmp-name3' is a local file name. |
| 2675 | (should-error | 2725 | (should-error |
| 2676 | (add-name-to-file tmp-name1 tmp-name3) | 2726 | (add-name-to-file tmp-name1 tmp-name3) |
| 2677 | :type 'file-error)) | 2727 | :type 'file-error) |
| 2728 | ;; Check directory as newname. | ||
| 2729 | (make-directory tmp-name4) | ||
| 2730 | (should-error | ||
| 2731 | (add-name-to-file tmp-name1 tmp-name4) | ||
| 2732 | :type 'file-already-exists) | ||
| 2733 | (add-name-to-file tmp-name1 (file-name-as-directory tmp-name4)) | ||
| 2734 | (should | ||
| 2735 | (file-regular-p | ||
| 2736 | (expand-file-name (file-name-nondirectory tmp-name1) tmp-name4)))) | ||
| 2678 | 2737 | ||
| 2679 | ;; Cleanup. | 2738 | ;; Cleanup. |
| 2680 | (ignore-errors | 2739 | (ignore-errors |
| 2681 | (delete-file tmp-name1) | 2740 | (delete-file tmp-name1) |
| 2682 | (delete-file tmp-name2))) | 2741 | (delete-file tmp-name2) |
| 2742 | (delete-directory tmp-name4 'recursive))) | ||
| 2683 | 2743 | ||
| 2684 | ;; Check `file-truename'. | 2744 | ;; Check `file-truename'. |
| 2685 | (unwind-protect | 2745 | (unwind-protect |
| @@ -2969,7 +3029,8 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 2969 | (write-region "(provide 'tramp-test-load)" nil tmp-name) | 3029 | (write-region "(provide 'tramp-test-load)" nil tmp-name) |
| 2970 | ;; `load' in lread.c does not pass `must-suffix'. Why? | 3030 | ;; `load' in lread.c does not pass `must-suffix'. Why? |
| 2971 | ;;(should-error | 3031 | ;;(should-error |
| 2972 | ;; (load tmp-name nil 'nomessage 'nosuffix 'must-suffix)) | 3032 | ;; (load tmp-name nil 'nomessage 'nosuffix 'must-suffix) |
| 3033 | ;; :type 'file-error) | ||
| 2973 | (load tmp-name nil 'nomessage 'nosuffix) | 3034 | (load tmp-name nil 'nomessage 'nosuffix) |
| 2974 | (should (featurep 'tramp-test-load))) | 3035 | (should (featurep 'tramp-test-load))) |
| 2975 | 3036 | ||
| @@ -3112,7 +3173,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 3112 | (should (equal (process-status proc) 'signal)) | 3173 | (should (equal (process-status proc) 'signal)) |
| 3113 | ;; An interrupted process cannot be interrupted, again. | 3174 | ;; An interrupted process cannot be interrupted, again. |
| 3114 | ;; Does not work reliable. | 3175 | ;; Does not work reliable. |
| 3115 | ;; (should-error (interrupt-process proc))) | 3176 | ;; (should-error (interrupt-process proc) :type 'error)) |
| 3116 | ) | 3177 | ) |
| 3117 | 3178 | ||
| 3118 | ;; Cleanup. | 3179 | ;; Cleanup. |