From acbe32abddd9740acd756419f068cb4bc345567c Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Thu, 15 Dec 2016 09:37:35 +0100 Subject: [PATCH] Check in tramp-tests.el, that environment variables are set correctly * test/lisp/net/tramp-tests.el (tramp--test-check-files): Check also, that environment variables are set correctly. --- test/lisp/net/tramp-tests.el | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index e80af422244..893dc543f3e 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -2283,7 +2283,34 @@ Several special characters do not work properly there." (delete-file file2) (should-not (file-exists-p file2)) (delete-directory file1) - (should-not (file-exists-p file1))))) + (should-not (file-exists-p file1)))) + + ;; Check, that environment variables are set correctly. + (when (and tramp--test-expensive-test (tramp--test-sh-p)) + (dolist (elt files) + ;; Tramp does not support environment variables with + ;; leading or trailing spaces. It also does not + ;; support the tab character. + (setq elt (replace-regexp-in-string "\t" " " elt) + elt (replace-regexp-in-string "^\\s-+\\|\\s-+$" "" elt)) + (let* ((default-directory tramp-test-temporary-file-directory) + (shell-file-name "/bin/sh") + (envvar + (concat "VAR_" (upcase (md5 (current-time-string))))) + (tramp-remote-process-environment + (cons + (format "%s=%s" envvar elt) + tramp-remote-process-environment))) + ;; We force a reconnect, in order to have a clean + ;; environment. + (tramp-cleanup-connection + (tramp-dissect-file-name tramp-test-temporary-file-directory) + 'keep-debug 'keep-password) + (should + (string-equal + elt + (shell-command-to-string + (format "echo -n $%s" envvar)))))))) ;; Cleanup. (ignore-errors (delete-directory tmp-name1 'recursive)) -- 2.39.2