diff options
| author | Michael Albinus | 2016-07-14 10:10:53 +0200 |
|---|---|---|
| committer | Michael Albinus | 2016-07-14 10:10:53 +0200 |
| commit | 05ba7a0f83205e647546c2a3bb90e16add58cf06 (patch) | |
| tree | ce75e6996b12e7702821f5a3de6fd873a2a6637c | |
| parent | e393d4f4ce64498408bd82f88eeab182c18457e4 (diff) | |
| download | emacs-05ba7a0f83205e647546c2a3bb90e16add58cf06.tar.gz emacs-05ba7a0f83205e647546c2a3bb90e16add58cf06.zip | |
Add test for handling environment variables in Tramp
* test/automatedtramp-tests.el
(tramp-test--shell-command-to-string-asynchronously): New defun.
(tramp-test29-environment-variables): New test.
(tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp-test32-special-characters)
(tramp-test32-special-characters-with-stat)
(tramp-test32-special-characters-with-perl)
(tramp-test32-special-characters-with-ls, tramp-test33-utf8)
(tramp-test33-utf8-with-stat, tramp-test33-utf8-with-perl)
(tramp-test33-utf8-with-ls)
(tramp-test34-asynchronous-requests)
(tramp-test35-recursive-load, tramp-test36-unload): Rename.
| -rw-r--r-- | test/automated/tramp-tests.el | 130 |
1 files changed, 113 insertions, 17 deletions
diff --git a/test/automated/tramp-tests.el b/test/automated/tramp-tests.el index a12ee387576..cc90d1950cd 100644 --- a/test/automated/tramp-tests.el +++ b/test/automated/tramp-tests.el | |||
| @@ -1598,7 +1598,103 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 1598 | ;; Cleanup. | 1598 | ;; Cleanup. |
| 1599 | (ignore-errors (delete-file tmp-name))))) | 1599 | (ignore-errors (delete-file tmp-name))))) |
| 1600 | 1600 | ||
| 1601 | (ert-deftest tramp-test29-vc-registered () | 1601 | (defun tramp-test--shell-command-to-string-asynchronously (command) |
| 1602 | "Like `shell-command-to-string', but for asynchronous processes." | ||
| 1603 | (with-temp-buffer | ||
| 1604 | (async-shell-command command (current-buffer)) | ||
| 1605 | ;; Suppress nasty messages. | ||
| 1606 | (set-process-sentinel (get-buffer-process (current-buffer)) nil) | ||
| 1607 | (while | ||
| 1608 | (and (get-buffer-process (current-buffer)) | ||
| 1609 | (eq (process-status (get-buffer-process (current-buffer))) 'run)) | ||
| 1610 | (accept-process-output (get-buffer-process (current-buffer)) 1)) | ||
| 1611 | (buffer-substring-no-properties (point-min) (point-max)))) | ||
| 1612 | |||
| 1613 | ;; This test is inspired by Bug#23952. | ||
| 1614 | (ert-deftest tramp-test29-environment-variables () | ||
| 1615 | "Check that remote processes set / unset environment variables properly." | ||
| 1616 | :tags '(:expensive-test) | ||
| 1617 | (skip-unless (tramp--test-enabled)) | ||
| 1618 | (skip-unless | ||
| 1619 | (eq | ||
| 1620 | (tramp-find-foreign-file-name-handler tramp-test-temporary-file-directory) | ||
| 1621 | 'tramp-sh-file-name-handler)) | ||
| 1622 | |||
| 1623 | ;; Implementation note: There is a "sleep 1" at the end of every | ||
| 1624 | ;; test. Otherwise, the scripts could return too early, without | ||
| 1625 | ;; expected output. | ||
| 1626 | (dolist (this-shell-command-to-string | ||
| 1627 | '(;; Synchronously. | ||
| 1628 | shell-command-to-string | ||
| 1629 | ;; Asynchronously. | ||
| 1630 | tramp-test--shell-command-to-string-asynchronously)) | ||
| 1631 | |||
| 1632 | (let ((default-directory tramp-test-temporary-file-directory) | ||
| 1633 | (shell-file-name "/bin/sh") | ||
| 1634 | (envvar (concat "VAR_" (upcase (md5 (current-time-string))))) | ||
| 1635 | kill-buffer-query-functions) | ||
| 1636 | |||
| 1637 | (unwind-protect | ||
| 1638 | ;; Set a value. | ||
| 1639 | (let ((process-environment | ||
| 1640 | (cons (concat envvar "=foo") process-environment))) | ||
| 1641 | ;; Default value. | ||
| 1642 | (should | ||
| 1643 | (string-match | ||
| 1644 | "foo" | ||
| 1645 | (funcall | ||
| 1646 | this-shell-command-to-string | ||
| 1647 | (format "echo -n ${%s:?bla}; sleep 1" envvar)))))) | ||
| 1648 | |||
| 1649 | (unwind-protect | ||
| 1650 | ;; Set the empty value. | ||
| 1651 | (let ((process-environment | ||
| 1652 | (cons (concat envvar "=") process-environment))) | ||
| 1653 | ;; Value is null. | ||
| 1654 | (should | ||
| 1655 | (string-match | ||
| 1656 | "bla" | ||
| 1657 | (funcall | ||
| 1658 | this-shell-command-to-string | ||
| 1659 | (format "echo -n ${%s:?bla}; sleep 1" envvar)))) | ||
| 1660 | ;; Variable is set. | ||
| 1661 | (should | ||
| 1662 | (string-match | ||
| 1663 | (regexp-quote envvar) | ||
| 1664 | (funcall this-shell-command-to-string "set; sleep 1"))))) | ||
| 1665 | |||
| 1666 | ;; We force a reconnect, in order to have a clean environment. | ||
| 1667 | (tramp-cleanup-connection | ||
| 1668 | (tramp-dissect-file-name tramp-test-temporary-file-directory) | ||
| 1669 | 'keep-debug 'keep-password) | ||
| 1670 | (unwind-protect | ||
| 1671 | ;; Unset the variable. | ||
| 1672 | (let ((tramp-remote-process-environment | ||
| 1673 | (cons (concat envvar "=foo") | ||
| 1674 | tramp-remote-process-environment))) | ||
| 1675 | ;; Set the initial value, we want to unset below. | ||
| 1676 | (should | ||
| 1677 | (string-match | ||
| 1678 | "foo" | ||
| 1679 | (funcall | ||
| 1680 | this-shell-command-to-string | ||
| 1681 | (format "echo -n ${%s:?bla}; sleep 1" envvar)))) | ||
| 1682 | (let ((process-environment | ||
| 1683 | (cons envvar process-environment))) | ||
| 1684 | ;; Variable is unset. | ||
| 1685 | (should | ||
| 1686 | (string-match | ||
| 1687 | "bla" | ||
| 1688 | (funcall | ||
| 1689 | this-shell-command-to-string | ||
| 1690 | (format "echo -n ${%s:?bla}; sleep 1" envvar)))) | ||
| 1691 | ;; Variable is unset. | ||
| 1692 | (should-not | ||
| 1693 | (string-match | ||
| 1694 | (regexp-quote envvar) | ||
| 1695 | (funcall this-shell-command-to-string "set; sleep 1"))))))))) | ||
| 1696 | |||
| 1697 | (ert-deftest tramp-test30-vc-registered () | ||
| 1602 | "Check `vc-registered'." | 1698 | "Check `vc-registered'." |
| 1603 | :tags '(:expensive-test) | 1699 | :tags '(:expensive-test) |
| 1604 | (skip-unless (tramp--test-enabled)) | 1700 | (skip-unless (tramp--test-enabled)) |
| @@ -1667,7 +1763,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 1667 | ;; Cleanup. | 1763 | ;; Cleanup. |
| 1668 | (ignore-errors (delete-directory tmp-name1 'recursive))))) | 1764 | (ignore-errors (delete-directory tmp-name1 'recursive))))) |
| 1669 | 1765 | ||
| 1670 | (ert-deftest tramp-test30-make-auto-save-file-name () | 1766 | (ert-deftest tramp-test31-make-auto-save-file-name () |
| 1671 | "Check `make-auto-save-file-name'." | 1767 | "Check `make-auto-save-file-name'." |
| 1672 | (skip-unless (tramp--test-enabled)) | 1768 | (skip-unless (tramp--test-enabled)) |
| 1673 | 1769 | ||
| @@ -1921,7 +2017,7 @@ Several special characters do not work properly there." | |||
| 1921 | (ignore-errors (delete-directory tmp-name2 'recursive))))) | 2017 | (ignore-errors (delete-directory tmp-name2 'recursive))))) |
| 1922 | 2018 | ||
| 1923 | (defun tramp--test-special-characters () | 2019 | (defun tramp--test-special-characters () |
| 1924 | "Perform the test in `tramp-test31-special-characters*'." | 2020 | "Perform the test in `tramp-test32-special-characters*'." |
| 1925 | ;; Newlines, slashes and backslashes in file names are not | 2021 | ;; Newlines, slashes and backslashes in file names are not |
| 1926 | ;; supported. So we don't test. And we don't test the tab | 2022 | ;; supported. So we don't test. And we don't test the tab |
| 1927 | ;; character on Windows or Cygwin, because the backslash is | 2023 | ;; character on Windows or Cygwin, because the backslash is |
| @@ -1962,13 +2058,13 @@ Several special characters do not work properly there." | |||
| 1962 | "{foo}bar{baz}")) | 2058 | "{foo}bar{baz}")) |
| 1963 | 2059 | ||
| 1964 | ;; These tests are inspired by Bug#17238. | 2060 | ;; These tests are inspired by Bug#17238. |
| 1965 | (ert-deftest tramp-test31-special-characters () | 2061 | (ert-deftest tramp-test32-special-characters () |
| 1966 | "Check special characters in file names." | 2062 | "Check special characters in file names." |
| 1967 | (skip-unless (tramp--test-enabled)) | 2063 | (skip-unless (tramp--test-enabled)) |
| 1968 | 2064 | ||
| 1969 | (tramp--test-special-characters)) | 2065 | (tramp--test-special-characters)) |
| 1970 | 2066 | ||
| 1971 | (ert-deftest tramp-test31-special-characters-with-stat () | 2067 | (ert-deftest tramp-test32-special-characters-with-stat () |
| 1972 | "Check special characters in file names. | 2068 | "Check special characters in file names. |
| 1973 | Use the `stat' command." | 2069 | Use the `stat' command." |
| 1974 | :tags '(:expensive-test) | 2070 | :tags '(:expensive-test) |
| @@ -1987,7 +2083,7 @@ Use the `stat' command." | |||
| 1987 | tramp-connection-properties))) | 2083 | tramp-connection-properties))) |
| 1988 | (tramp--test-special-characters))) | 2084 | (tramp--test-special-characters))) |
| 1989 | 2085 | ||
| 1990 | (ert-deftest tramp-test31-special-characters-with-perl () | 2086 | (ert-deftest tramp-test32-special-characters-with-perl () |
| 1991 | "Check special characters in file names. | 2087 | "Check special characters in file names. |
| 1992 | Use the `perl' command." | 2088 | Use the `perl' command." |
| 1993 | :tags '(:expensive-test) | 2089 | :tags '(:expensive-test) |
| @@ -2009,7 +2105,7 @@ Use the `perl' command." | |||
| 2009 | tramp-connection-properties))) | 2105 | tramp-connection-properties))) |
| 2010 | (tramp--test-special-characters))) | 2106 | (tramp--test-special-characters))) |
| 2011 | 2107 | ||
| 2012 | (ert-deftest tramp-test31-special-characters-with-ls () | 2108 | (ert-deftest tramp-test32-special-characters-with-ls () |
| 2013 | "Check special characters in file names. | 2109 | "Check special characters in file names. |
| 2014 | Use the `ls' command." | 2110 | Use the `ls' command." |
| 2015 | :tags '(:expensive-test) | 2111 | :tags '(:expensive-test) |
| @@ -2032,7 +2128,7 @@ Use the `ls' command." | |||
| 2032 | (tramp--test-special-characters))) | 2128 | (tramp--test-special-characters))) |
| 2033 | 2129 | ||
| 2034 | (defun tramp--test-utf8 () | 2130 | (defun tramp--test-utf8 () |
| 2035 | "Perform the test in `tramp-test32-utf8*'." | 2131 | "Perform the test in `tramp-test33-utf8*'." |
| 2036 | (let* ((utf8 (if (and (eq system-type 'darwin) | 2132 | (let* ((utf8 (if (and (eq system-type 'darwin) |
| 2037 | (memq 'utf-8-hfs (coding-system-list))) | 2133 | (memq 'utf-8-hfs (coding-system-list))) |
| 2038 | 'utf-8-hfs 'utf-8)) | 2134 | 'utf-8-hfs 'utf-8)) |
| @@ -2046,13 +2142,13 @@ Use the `ls' command." | |||
| 2046 | "银河系漫游指南系列" | 2142 | "银河系漫游指南系列" |
| 2047 | "Автостопом по гала́ктике"))) | 2143 | "Автостопом по гала́ктике"))) |
| 2048 | 2144 | ||
| 2049 | (ert-deftest tramp-test32-utf8 () | 2145 | (ert-deftest tramp-test33-utf8 () |
| 2050 | "Check UTF8 encoding in file names and file contents." | 2146 | "Check UTF8 encoding in file names and file contents." |
| 2051 | (skip-unless (tramp--test-enabled)) | 2147 | (skip-unless (tramp--test-enabled)) |
| 2052 | 2148 | ||
| 2053 | (tramp--test-utf8)) | 2149 | (tramp--test-utf8)) |
| 2054 | 2150 | ||
| 2055 | (ert-deftest tramp-test32-utf8-with-stat () | 2151 | (ert-deftest tramp-test33-utf8-with-stat () |
| 2056 | "Check UTF8 encoding in file names and file contents. | 2152 | "Check UTF8 encoding in file names and file contents. |
| 2057 | Use the `stat' command." | 2153 | Use the `stat' command." |
| 2058 | :tags '(:expensive-test) | 2154 | :tags '(:expensive-test) |
| @@ -2071,7 +2167,7 @@ Use the `stat' command." | |||
| 2071 | tramp-connection-properties))) | 2167 | tramp-connection-properties))) |
| 2072 | (tramp--test-utf8))) | 2168 | (tramp--test-utf8))) |
| 2073 | 2169 | ||
| 2074 | (ert-deftest tramp-test32-utf8-with-perl () | 2170 | (ert-deftest tramp-test33-utf8-with-perl () |
| 2075 | "Check UTF8 encoding in file names and file contents. | 2171 | "Check UTF8 encoding in file names and file contents. |
| 2076 | Use the `perl' command." | 2172 | Use the `perl' command." |
| 2077 | :tags '(:expensive-test) | 2173 | :tags '(:expensive-test) |
| @@ -2093,7 +2189,7 @@ Use the `perl' command." | |||
| 2093 | tramp-connection-properties))) | 2189 | tramp-connection-properties))) |
| 2094 | (tramp--test-utf8))) | 2190 | (tramp--test-utf8))) |
| 2095 | 2191 | ||
| 2096 | (ert-deftest tramp-test32-utf8-with-ls () | 2192 | (ert-deftest tramp-test33-utf8-with-ls () |
| 2097 | "Check UTF8 encoding in file names and file contents. | 2193 | "Check UTF8 encoding in file names and file contents. |
| 2098 | Use the `ls' command." | 2194 | Use the `ls' command." |
| 2099 | :tags '(:expensive-test) | 2195 | :tags '(:expensive-test) |
| @@ -2116,7 +2212,7 @@ Use the `ls' command." | |||
| 2116 | (tramp--test-utf8))) | 2212 | (tramp--test-utf8))) |
| 2117 | 2213 | ||
| 2118 | ;; This test is inspired by Bug#16928. | 2214 | ;; This test is inspired by Bug#16928. |
| 2119 | (ert-deftest tramp-test33-asynchronous-requests () | 2215 | (ert-deftest tramp-test34-asynchronous-requests () |
| 2120 | "Check parallel asynchronous requests. | 2216 | "Check parallel asynchronous requests. |
| 2121 | Such requests could arrive from timers, process filters and | 2217 | Such requests could arrive from timers, process filters and |
| 2122 | process sentinels. They shall not disturb each other." | 2218 | process sentinels. They shall not disturb each other." |
| @@ -2206,7 +2302,7 @@ process sentinels. They shall not disturb each other." | |||
| 2206 | (dolist (buf buffers) | 2302 | (dolist (buf buffers) |
| 2207 | (ignore-errors (kill-buffer buf))))))) | 2303 | (ignore-errors (kill-buffer buf))))))) |
| 2208 | 2304 | ||
| 2209 | (ert-deftest tramp-test34-recursive-load () | 2305 | (ert-deftest tramp-test35-recursive-load () |
| 2210 | "Check that Tramp does not fail due to recursive load." | 2306 | "Check that Tramp does not fail due to recursive load." |
| 2211 | (skip-unless (tramp--test-enabled)) | 2307 | (skip-unless (tramp--test-enabled)) |
| 2212 | 2308 | ||
| @@ -2229,7 +2325,7 @@ process sentinels. They shall not disturb each other." | |||
| 2229 | (mapconcat 'shell-quote-argument load-path " -L ") | 2325 | (mapconcat 'shell-quote-argument load-path " -L ") |
| 2230 | (shell-quote-argument code))))))) | 2326 | (shell-quote-argument code))))))) |
| 2231 | 2327 | ||
| 2232 | (ert-deftest tramp-test35-unload () | 2328 | (ert-deftest tramp-test36-unload () |
| 2233 | "Check that Tramp and its subpackages unload completely. | 2329 | "Check that Tramp and its subpackages unload completely. |
| 2234 | Since it unloads Tramp, it shall be the last test to run." | 2330 | Since it unloads Tramp, it shall be the last test to run." |
| 2235 | ;; Mark as failed until all symbols are unbound. | 2331 | ;; Mark as failed until all symbols are unbound. |
| @@ -2277,8 +2373,8 @@ Since it unloads Tramp, it shall be the last test to run." | |||
| 2277 | ;; * Fix `tramp-test15-copy-directory' for `smb'. Using tar in a pipe | 2373 | ;; * Fix `tramp-test15-copy-directory' for `smb'. Using tar in a pipe |
| 2278 | ;; doesn't work well when an interactive password must be provided. | 2374 | ;; doesn't work well when an interactive password must be provided. |
| 2279 | ;; * Fix `tramp-test27-start-file-process' on MS Windows (`process-send-eof'?). | 2375 | ;; * Fix `tramp-test27-start-file-process' on MS Windows (`process-send-eof'?). |
| 2280 | ;; * Fix Bug#16928. Set expected error of `tramp-test33-asynchronous-requests'. | 2376 | ;; * Fix Bug#16928. Set expected error of `tramp-test34-asynchronous-requests'. |
| 2281 | ;; * Fix `tramp-test35-unload' (Not all symbols are unbound). Set | 2377 | ;; * Fix `tramp-test36-unload' (Not all symbols are unbound). Set |
| 2282 | ;; expected error. | 2378 | ;; expected error. |
| 2283 | 2379 | ||
| 2284 | (defun tramp-test-all (&optional interactive) | 2380 | (defun tramp-test-all (&optional interactive) |