diff options
author | Jim Porter <jporterbugs@gmail.com> | 2022-09-15 12:24:37 -0700 |
---|---|---|
committer | Jim Porter <jporterbugs@gmail.com> | 2022-10-17 18:48:52 -0700 |
commit | cee1cbfd54375cdece23d4741ced6b0c7091f6d9 (patch) | |
tree | 482d4bf98473742958b4ce4f1fba1c3e305aa093 /test/lisp/eshell/eshell-tests-helpers.el | |
parent | 7c41016fca5ab0638f1e2fed260e2ee41f3400c2 (diff) | |
download | emacs-cee1cbfd54375cdece23d4741ced6b0c7091f6d9.tar.gz emacs-cee1cbfd54375cdece23d4741ced6b0c7091f6d9.tar.bz2 emacs-cee1cbfd54375cdece23d4741ced6b0c7091f6d9.zip |
Improve handling of $PATH in Eshell for remote directories
* lisp/eshell/esh-util.el (eshell-path-env, eshell-parse-colon-path):
Make obsolete.
(eshell-path-env-list): New variable.
(eshell-connection-default-profile): New connection-local profile.
(eshell-get-path): Reimplement using 'eshell-path-env-list'; add
LITERAL-P argument.
(eshell-set-path): New function.
* lisp/eshell/esh-var.el (eshell-variable-aliases-list): Add entry for
$PATH.
(eshell-var-initialize): Add 'eshell-path-env-list' to
'eshell-subcommand-bindings'.
* lisp/eshell/esh-ext.el (eshell-search-path): Use 'file-name-concat'
instead of 'concat'.
(eshell/addpath): Use 'eshell-get-path' and 'eshell-set-path'.
* lisp/net/tramp-integration.el: Only apply Eshell hooks when
'eshell-path-env-list' is unbound.
* test/lisp/eshell/esh-var-tests.el
(esh-var-test/path-var/local-directory)
(esh-var-test/path-var/remote-directory, esh-var-test/path-var/set)
(esh-var-test/path-var/set-locally)
(esh-var-test/path-var-preserve-across-hosts): New tests.
* test/lisp/eshell/esh-ext-tests.el: New file.
* test/lisp/eshell/eshell-tests-helpers.el
(with-temp-eshell): Set 'eshell-last-dir-ring-file-name' to nil.
(eshell-tests-remote-accessible-p, eshell-last-input)
(eshell-last-output): New functions.
(eshell-match-output, eshell-match-output--explainer): Use
'eshell-last-input' and 'eshell-last-output'.
* doc/misc/eshell.texi (Variables): Document $PATH.
* etc/NEWS: Announce this change (bug#57556).
Diffstat (limited to 'test/lisp/eshell/eshell-tests-helpers.el')
-rw-r--r-- | test/lisp/eshell/eshell-tests-helpers.el | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/test/lisp/eshell/eshell-tests-helpers.el b/test/lisp/eshell/eshell-tests-helpers.el index e713e162ad0..1d9674070c0 100644 --- a/test/lisp/eshell/eshell-tests-helpers.el +++ b/test/lisp/eshell/eshell-tests-helpers.el @@ -31,11 +31,22 @@ (require 'eshell) (defvar eshell-history-file-name nil) +(defvar eshell-last-dir-ring-file-name nil) (defvar eshell-test--max-subprocess-time 5 "The maximum amount of time to wait for a subprocess to finish, in seconds. See `eshell-wait-for-subprocess'.") +(defun eshell-tests-remote-accessible-p () + "Return if a test involving remote files can proceed. +If using this function, be sure to load `tramp' near the +beginning of the test file." + (ignore-errors + (and + (file-remote-p ert-remote-temporary-file-directory) + (file-directory-p ert-remote-temporary-file-directory) + (file-writable-p ert-remote-temporary-file-directory)))) + (defmacro with-temp-eshell (&rest body) "Evaluate BODY in a temporary Eshell buffer." `(save-current-buffer @@ -44,6 +55,7 @@ See `eshell-wait-for-subprocess'.") ;; back on $HISTFILE. (process-environment (cons "HISTFILE" process-environment)) (eshell-history-file-name nil) + (eshell-last-dir-ring-file-name nil) (eshell-buffer (eshell t))) (unwind-protect (with-current-buffer eshell-buffer @@ -83,19 +95,25 @@ After inserting, call FUNC. If FUNC is nil, instead call (insert-and-inherit command) (funcall (or func 'eshell-send-input))) +(defun eshell-last-input () + "Return the input of the last Eshell command." + (buffer-substring-no-properties + eshell-last-input-start eshell-last-input-end)) + +(defun eshell-last-output () + "Return the output of the last Eshell command." + (buffer-substring-no-properties + (eshell-beginning-of-output) (eshell-end-of-output))) + (defun eshell-match-output (regexp) "Test whether the output of the last command matches REGEXP." - (string-match-p - regexp (buffer-substring-no-properties - (eshell-beginning-of-output) (eshell-end-of-output)))) + (string-match-p regexp (eshell-last-output))) (defun eshell-match-output--explainer (regexp) "Explain the result of `eshell-match-output'." `(mismatched-output - (command ,(buffer-substring-no-properties - eshell-last-input-start eshell-last-input-end)) - (output ,(buffer-substring-no-properties - (eshell-beginning-of-output) (eshell-end-of-output))) + (command ,(eshell-last-input)) + (output ,(eshell-last-output)) (regexp ,regexp))) (put 'eshell-match-output 'ert-explainer #'eshell-match-output--explainer) |