summaryrefslogtreecommitdiff
path: root/test/lisp
diff options
context:
space:
mode:
authorMichael Albinus <michael.albinus@gmx.de>2016-12-23 09:31:23 +0100
committerMichael Albinus <michael.albinus@gmx.de>2016-12-23 09:31:23 +0100
commit831bef1a469356b82892c163f33c9c65ccd75c7c (patch)
tree0c8461a0e6533db1b126dba7489fb1195ec82504 /test/lisp
parentc4e38581d3b4d6b19921f0db81f319d19ae4fb9e (diff)
downloademacs-831bef1a469356b82892c163f33c9c65ccd75c7c.tar.gz
* test/lisp/net/tramp-tests.el (tramp--test-check-files): Make it robust.
Diffstat (limited to 'test/lisp')
-rw-r--r--test/lisp/net/tramp-tests.el53
1 files changed, 17 insertions, 36 deletions
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 3d92dff3811..22b60db04f5 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -2169,18 +2169,6 @@ This requires restrictions of file name syntax."
(process-environment process-environment))
(unwind-protect
(progn
- ;; 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-cleanup-connection
- (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.
- (shell-command-to-string
- (format
- "cat <<%s >%s\n$%s\n%s"
- heredoc (file-remote-p file1 'localname) envvar heredoc))
- (with-temp-buffer
- (insert-file-contents file1)
- (should
- (string-equal
- (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")
+ (with-temp-buffer
+ (should (zerop (process-file "env" nil t nil)))
+ (goto-char (point-min))
+ (should
+ (re-search-forward
+ (format
+ "^%s=%s$"
+ (regexp-quote envvar)
+ (regexp-quote (getenv envvar))))))))))
;; Cleanup.
(ignore-errors (delete-directory tmp-name1 'recursive))