Commit 831bef1a authored by Michael Albinus's avatar Michael Albinus
Browse files

* test/lisp/net/tramp-tests.el (tramp--test-check-files): Make it robust.

parent c4e38581
......@@ -2169,18 +2169,6 @@ This requires restrictions of file name syntax."
(process-environment process-environment))
;; Add environment variables.
(dolist (elt files)
;; The check command (heredoc file) does not support
;; environment variables with leading spaces.
(let* ((elt (replace-regexp-in-string "^\\s-+" "" elt))
(envvar (concat "VAR_" (upcase (md5 elt)))))
(setenv envvar elt)))
;; We force a reconnect, in order to have a clean environment.
(tramp-dissect-file-name tramp-test-temporary-file-directory)
'keep-debug 'keep-password)
(make-directory tmp-name1)
(make-directory tmp-name2)
......@@ -2310,30 +2298,23 @@ This requires restrictions of file name syntax."
;; Check, that environment variables are set correctly.
(when (and tramp--test-expensive-test (tramp--test-sh-p))
(dolist (elt process-environment)
(when (string-match "^VAR_" elt)
(let* ((default-directory tramp-test-temporary-file-directory)
(shell-file-name "/bin/sh")
(heredoc (md5 (current-time-string)))
(envvar (car (split-string elt "=" t)))
(file1 (tramp-compat-file-name-unquote
(expand-file-name "bar" tmp-name1))))
;; Cleanup.
(ignore-errors (delete-file file1))
;; Save the variable in a file. The echo command
;; does not work properly, it suppresses leading/
;; trailing spaces as well as tabs.
"cat <<%s >%s\n$%s\n%s"
heredoc (file-remote-p file1 'localname) envvar heredoc))
(insert-file-contents file1)
(buffer-string) (concat (getenv envvar) "\n"))))
(delete-file file1)
(should-not (file-exists-p file1)))))))
(dolist (elt files)
(let ((envvar (concat "VAR_" (upcase (md5 elt))))
(default-directory tramp-test-temporary-file-directory)
(process-environment process-environment))
(setenv envvar elt)
;; The value of PS1 could confuse Tramp's detection
;; of process output. So we unset it temporarily.
(setenv "PS1")
(should (zerop (process-file "env" nil t nil)))
(goto-char (point-min))
(regexp-quote envvar)
(regexp-quote (getenv envvar))))))))))
;; Cleanup.
(ignore-errors (delete-directory tmp-name1 'recursive))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment