]> git.eshelyaron.com Git - emacs.git/commitdiff
* test/lisp/net/tramp-tests.el (tramp--test-check-files): Make it robust.
authorMichael Albinus <michael.albinus@gmx.de>
Fri, 23 Dec 2016 08:31:23 +0000 (09:31 +0100)
committerMichael Albinus <michael.albinus@gmx.de>
Fri, 23 Dec 2016 08:31:23 +0000 (09:31 +0100)
test/lisp/net/tramp-tests.el

index 3d92dff38113a0c09144009c5efc44ff54aa9bac..22b60db04f5f66f0ead371ff864904281f1dbf88 100644 (file)
@@ -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))