Adapt Tramp tests
* test/lisp/net/tramp-tests.el (tramp-test33-environment-variables): Adapt test.
This commit is contained in:
parent
221e6a9bcd
commit
2db70edd9c
1 changed files with 61 additions and 55 deletions
|
@ -4869,65 +4869,71 @@ INPUT, if non-nil, is a string sent to the process."
|
|||
(envvar (concat "VAR_" (upcase (md5 (current-time-string)))))
|
||||
kill-buffer-query-functions)
|
||||
|
||||
(unwind-protect
|
||||
;; Set a value.
|
||||
(let ((process-environment
|
||||
(cons (concat envvar "=foo") process-environment)))
|
||||
;; Default value.
|
||||
(should
|
||||
(string-match
|
||||
"foo"
|
||||
(funcall
|
||||
this-shell-command-to-string
|
||||
(format "echo -n ${%s:-bla}" envvar))))))
|
||||
;; Check INSIDE_EMACS.
|
||||
(should
|
||||
(string-equal
|
||||
(format "%s,tramp:%s" emacs-version tramp-version)
|
||||
(funcall this-shell-command-to-string "echo -n ${INSIDE_EMACS:-bla}")))
|
||||
(let ((process-environment
|
||||
(cons (format "INSIDE_EMACS=%s,foo" emacs-version)
|
||||
process-environment)))
|
||||
(should
|
||||
(string-equal
|
||||
(format "%s,foo,tramp:%s" emacs-version tramp-version)
|
||||
(funcall
|
||||
this-shell-command-to-string "echo -n ${INSIDE_EMACS:-bla}"))))
|
||||
|
||||
(unwind-protect
|
||||
;; Set the empty value.
|
||||
(let ((process-environment
|
||||
(cons (concat envvar "=") process-environment)))
|
||||
;; Value is null.
|
||||
(should
|
||||
(string-match
|
||||
"bla"
|
||||
(funcall
|
||||
this-shell-command-to-string
|
||||
(format "echo -n ${%s:-bla}" envvar))))
|
||||
;; Variable is set.
|
||||
(should
|
||||
(string-match
|
||||
(regexp-quote envvar)
|
||||
(funcall this-shell-command-to-string "set")))))
|
||||
;; Set a value.
|
||||
(let ((process-environment
|
||||
(cons (concat envvar "=foo") process-environment)))
|
||||
;; Default value.
|
||||
(should
|
||||
(string-match
|
||||
"foo"
|
||||
(funcall
|
||||
this-shell-command-to-string (format "echo -n ${%s:-bla}" envvar)))))
|
||||
|
||||
;; Set the empty value.
|
||||
(let ((process-environment
|
||||
(cons (concat envvar "=") process-environment)))
|
||||
;; Value is null.
|
||||
(should
|
||||
(string-match
|
||||
"bla"
|
||||
(funcall
|
||||
this-shell-command-to-string (format "echo -n ${%s:-bla}" envvar))))
|
||||
;; Variable is set.
|
||||
(should
|
||||
(string-match
|
||||
(regexp-quote envvar)
|
||||
(funcall this-shell-command-to-string "set"))))
|
||||
|
||||
;; We force a reconnect, in order to have a clean environment.
|
||||
(tramp-cleanup-connection tramp-test-vec 'keep-debug 'keep-password)
|
||||
(unwind-protect
|
||||
;; Unset the variable.
|
||||
(let ((tramp-remote-process-environment
|
||||
(cons (concat envvar "=foo")
|
||||
tramp-remote-process-environment)))
|
||||
;; Set the initial value, we want to unset below.
|
||||
(should
|
||||
(string-match
|
||||
"foo"
|
||||
(funcall
|
||||
this-shell-command-to-string
|
||||
(format "echo -n ${%s:-bla}" envvar))))
|
||||
(let ((process-environment
|
||||
(cons envvar process-environment)))
|
||||
;; Variable is unset.
|
||||
(should
|
||||
(string-match
|
||||
"bla"
|
||||
(funcall
|
||||
this-shell-command-to-string
|
||||
(format "echo -n ${%s:-bla}" envvar))))
|
||||
;; Variable is unset.
|
||||
(should-not
|
||||
(string-match
|
||||
(regexp-quote envvar)
|
||||
;; We must remove PS1, the output is truncated otherwise.
|
||||
(funcall
|
||||
this-shell-command-to-string "printenv | grep -v PS1")))))))))
|
||||
;; Unset the variable.
|
||||
(let ((tramp-remote-process-environment
|
||||
(cons (concat envvar "=foo") tramp-remote-process-environment)))
|
||||
;; Set the initial value, we want to unset below.
|
||||
(should
|
||||
(string-match
|
||||
"foo"
|
||||
(funcall
|
||||
this-shell-command-to-string (format "echo -n ${%s:-bla}" envvar))))
|
||||
(let ((process-environment (cons envvar process-environment)))
|
||||
;; Variable is unset.
|
||||
(should
|
||||
(string-match
|
||||
"bla"
|
||||
(funcall
|
||||
this-shell-command-to-string
|
||||
(format "echo -n ${%s:-bla}" envvar))))
|
||||
;; Variable is unset.
|
||||
(should-not
|
||||
(string-match
|
||||
(regexp-quote envvar)
|
||||
;; We must remove PS1, the output is truncated otherwise.
|
||||
(funcall
|
||||
this-shell-command-to-string "printenv | grep -v PS1"))))))))
|
||||
|
||||
;; This test is inspired by Bug#27009.
|
||||
(ert-deftest tramp-test33-environment-variables-and-port-numbers ()
|
||||
|
|
Loading…
Add table
Reference in a new issue