]> git.eshelyaron.com Git - emacs.git/commitdiff
Adapt Tramp tests
authorMichael Albinus <michael.albinus@gmx.de>
Mon, 4 May 2020 11:09:32 +0000 (13:09 +0200)
committerMichael Albinus <michael.albinus@gmx.de>
Mon, 4 May 2020 11:09:32 +0000 (13:09 +0200)
* test/lisp/net/tramp-tests.el (tramp-test33-environment-variables):
Adapt test.

test/lisp/net/tramp-tests.el

index 75a0167da7f3c459e989df5b749ad1a442e288b5..28d20e39f8c0cb4199707c518ca772f101c99273 100644 (file)
@@ -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))))))
-
-      (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")))))
+      ;; 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}"))))
+
+      ;; 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 ()