diff options
| author | Michael Albinus | 2020-05-04 13:09:32 +0200 |
|---|---|---|
| committer | Michael Albinus | 2020-05-04 13:09:32 +0200 |
| commit | 2db70edd9cc8b52cb32c97fe2ff0ae008f02a31c (patch) | |
| tree | 6803ae6dc6721e01eaefc2c463338eb4ba533fe7 /test | |
| parent | 221e6a9bcdd50a3a134f09840f4a894ff73fb3e6 (diff) | |
| download | emacs-2db70edd9cc8b52cb32c97fe2ff0ae008f02a31c.tar.gz emacs-2db70edd9cc8b52cb32c97fe2ff0ae008f02a31c.zip | |
Adapt Tramp tests
* test/lisp/net/tramp-tests.el (tramp-test33-environment-variables):
Adapt test.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/net/tramp-tests.el | 118 |
1 files changed, 62 insertions, 56 deletions
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 75a0167da7f..28d20e39f8c 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el | |||
| @@ -4869,65 +4869,71 @@ INPUT, if non-nil, is a string sent to the process." | |||
| 4869 | (envvar (concat "VAR_" (upcase (md5 (current-time-string))))) | 4869 | (envvar (concat "VAR_" (upcase (md5 (current-time-string))))) |
| 4870 | kill-buffer-query-functions) | 4870 | kill-buffer-query-functions) |
| 4871 | 4871 | ||
| 4872 | (unwind-protect | 4872 | ;; Check INSIDE_EMACS. |
| 4873 | ;; Set a value. | 4873 | (should |
| 4874 | (let ((process-environment | 4874 | (string-equal |
| 4875 | (cons (concat envvar "=foo") process-environment))) | 4875 | (format "%s,tramp:%s" emacs-version tramp-version) |
| 4876 | ;; Default value. | 4876 | (funcall this-shell-command-to-string "echo -n ${INSIDE_EMACS:-bla}"))) |
| 4877 | (should | 4877 | (let ((process-environment |
| 4878 | (string-match | 4878 | (cons (format "INSIDE_EMACS=%s,foo" emacs-version) |
| 4879 | "foo" | 4879 | process-environment))) |
| 4880 | (funcall | 4880 | (should |
| 4881 | this-shell-command-to-string | 4881 | (string-equal |
| 4882 | (format "echo -n ${%s:-bla}" envvar)))))) | 4882 | (format "%s,foo,tramp:%s" emacs-version tramp-version) |
| 4883 | 4883 | (funcall | |
| 4884 | (unwind-protect | 4884 | this-shell-command-to-string "echo -n ${INSIDE_EMACS:-bla}")))) |
| 4885 | ;; Set the empty value. | 4885 | |
| 4886 | (let ((process-environment | 4886 | ;; Set a value. |
| 4887 | (cons (concat envvar "=") process-environment))) | 4887 | (let ((process-environment |
| 4888 | ;; Value is null. | 4888 | (cons (concat envvar "=foo") process-environment))) |
| 4889 | (should | 4889 | ;; Default value. |
| 4890 | (string-match | 4890 | (should |
| 4891 | "bla" | 4891 | (string-match |
| 4892 | (funcall | 4892 | "foo" |
| 4893 | this-shell-command-to-string | 4893 | (funcall |
| 4894 | (format "echo -n ${%s:-bla}" envvar)))) | 4894 | this-shell-command-to-string (format "echo -n ${%s:-bla}" envvar))))) |
| 4895 | ;; Variable is set. | 4895 | |
| 4896 | (should | 4896 | ;; Set the empty value. |
| 4897 | (string-match | 4897 | (let ((process-environment |
| 4898 | (regexp-quote envvar) | 4898 | (cons (concat envvar "=") process-environment))) |
| 4899 | (funcall this-shell-command-to-string "set"))))) | 4899 | ;; Value is null. |
| 4900 | (should | ||
| 4901 | (string-match | ||
| 4902 | "bla" | ||
| 4903 | (funcall | ||
| 4904 | this-shell-command-to-string (format "echo -n ${%s:-bla}" envvar)))) | ||
| 4905 | ;; Variable is set. | ||
| 4906 | (should | ||
| 4907 | (string-match | ||
| 4908 | (regexp-quote envvar) | ||
| 4909 | (funcall this-shell-command-to-string "set")))) | ||
| 4900 | 4910 | ||
| 4901 | ;; We force a reconnect, in order to have a clean environment. | 4911 | ;; We force a reconnect, in order to have a clean environment. |
| 4902 | (tramp-cleanup-connection tramp-test-vec 'keep-debug 'keep-password) | 4912 | (tramp-cleanup-connection tramp-test-vec 'keep-debug 'keep-password) |
| 4903 | (unwind-protect | 4913 | ;; Unset the variable. |
| 4904 | ;; Unset the variable. | 4914 | (let ((tramp-remote-process-environment |
| 4905 | (let ((tramp-remote-process-environment | 4915 | (cons (concat envvar "=foo") tramp-remote-process-environment))) |
| 4906 | (cons (concat envvar "=foo") | 4916 | ;; Set the initial value, we want to unset below. |
| 4907 | tramp-remote-process-environment))) | 4917 | (should |
| 4908 | ;; Set the initial value, we want to unset below. | 4918 | (string-match |
| 4909 | (should | 4919 | "foo" |
| 4910 | (string-match | 4920 | (funcall |
| 4911 | "foo" | 4921 | this-shell-command-to-string (format "echo -n ${%s:-bla}" envvar)))) |
| 4912 | (funcall | 4922 | (let ((process-environment (cons envvar process-environment))) |
| 4913 | this-shell-command-to-string | 4923 | ;; Variable is unset. |
| 4914 | (format "echo -n ${%s:-bla}" envvar)))) | 4924 | (should |
| 4915 | (let ((process-environment | 4925 | (string-match |
| 4916 | (cons envvar process-environment))) | 4926 | "bla" |
| 4917 | ;; Variable is unset. | 4927 | (funcall |
| 4918 | (should | 4928 | this-shell-command-to-string |
| 4919 | (string-match | 4929 | (format "echo -n ${%s:-bla}" envvar)))) |
| 4920 | "bla" | 4930 | ;; Variable is unset. |
| 4921 | (funcall | 4931 | (should-not |
| 4922 | this-shell-command-to-string | 4932 | (string-match |
| 4923 | (format "echo -n ${%s:-bla}" envvar)))) | 4933 | (regexp-quote envvar) |
| 4924 | ;; Variable is unset. | 4934 | ;; We must remove PS1, the output is truncated otherwise. |
| 4925 | (should-not | 4935 | (funcall |
| 4926 | (string-match | 4936 | this-shell-command-to-string "printenv | grep -v PS1")))))))) |
| 4927 | (regexp-quote envvar) | ||
| 4928 | ;; We must remove PS1, the output is truncated otherwise. | ||
| 4929 | (funcall | ||
| 4930 | this-shell-command-to-string "printenv | grep -v PS1"))))))))) | ||
| 4931 | 4937 | ||
| 4932 | ;; This test is inspired by Bug#27009. | 4938 | ;; This test is inspired by Bug#27009. |
| 4933 | (ert-deftest tramp-test33-environment-variables-and-port-numbers () | 4939 | (ert-deftest tramp-test33-environment-variables-and-port-numbers () |