[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/compat 394028541e 3/6: Add test for exec-path
From: |
ELPA Syncer |
Subject: |
[elpa] externals/compat 394028541e 3/6: Add test for exec-path |
Date: |
Mon, 16 Jan 2023 11:57:29 -0500 (EST) |
branch: externals/compat
commit 394028541e1326e9cd138b93c134bfec7506f8f1
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Add test for exec-path
---
compat-27.el | 46 ++++++++++++++++++++--------------------------
compat-tests.el | 11 ++++++++---
2 files changed, 28 insertions(+), 29 deletions(-)
diff --git a/compat-27.el b/compat-27.el
index 41686f340a..0dbad6ed57 100644
--- a/compat-27.el
+++ b/compat-27.el
@@ -413,37 +413,31 @@ in all cases, since that is the standard symbol for byte."
(if (string= prefixed-unit "") "" (or space ""))
prefixed-unit))))
-(compat-defun exec-path () ;; <UNTESTED>
+(compat-defun exec-path () ;; <compat-tests:exec-path>
"Return list of directories to search programs to run in remote subprocesses.
The remote host is identified by `default-directory'. For remote
hosts that do not support subprocesses, this returns nil.
If `default-directory' is a local directory, this function returns
the value of the variable `exec-path'."
- (cond
- ((let ((handler (find-file-name-handler default-directory 'exec-path)))
- ;; FIXME: The handler was added in 27.1, and this compatibility
- ;; function only applies to versions of Emacs before that.
- (when handler
- (condition-case nil
- (funcall handler 'exec-path)
- (error nil)))))
- ((file-remote-p default-directory)
- ;; TODO: This is not completely portable, even if "sh" and
- ;; "getconf" should be provided on every POSIX system, the chance
- ;; of this not working are greater than zero.
- ;;
- ;; FIXME: This invokes a shell process every time exec-path is
- ;; called. It should instead be cached on a host-local basis.
- (with-temp-buffer
- (if (condition-case nil
- (zerop (process-file "sh" nil t nil "-c" "getconf PATH"))
- (file-missing t))
- (list "/bin" "/usr/bin")
- (let (path)
- (while (re-search-forward "\\([^:]+?\\)[\n:]" nil t)
- (push (match-string 1) path))
- (nreverse path)))))
- (exec-path)))
+ ;; NOTE: We cannot use the 'exec-path file name handler here since it didn't
+ ;; exist before Emacs 27.1.
+ (if (file-remote-p default-directory)
+ ;; TODO: This is not completely portable, even if "sh" and
+ ;; "getconf" should be provided on every POSIX system, the chance
+ ;; of this not working are greater than zero.
+ ;;
+ ;; FIXME: This invokes a shell process every time exec-path is
+ ;; called. It should instead be cached on a host-local basis.
+ (with-temp-buffer
+ (if (condition-case nil
+ (zerop (process-file "sh" nil t nil "-c" "getconf PATH"))
+ (file-missing t))
+ (list "/bin" "/usr/bin")
+ (let (path)
+ (while (re-search-forward "\\([^:]+?\\)[\n:]" nil t)
+ (push (match-string 1) path))
+ (nreverse path))))
+ exec-path))
(compat-defun executable-find (command &optional remote) ;;
<compat-tests:executable-find>
"Search for COMMAND in `exec-path' and return the absolute file name.
diff --git a/compat-tests.el b/compat-tests.el
index 5d035f5b15..f1b630f30f 100644
--- a/compat-tests.el
+++ b/compat-tests.el
@@ -1235,9 +1235,14 @@
(ert-deftest executable-find ()
(should (member (executable-find "sh") '("/usr/bin/sh" "/bin/sh")))
(should (member (executable-find "ls") '("/usr/bin/ls" "/bin/ls")))
- ;; TODO These dummy calls are executed locally, test Tramp!
- (should (member (compat-call executable-find "sh" t) '("/usr/bin/sh"
"/bin/sh")))
- (should (member (compat-call executable-find "ls" t) '("/usr/bin/ls"
"/bin/ls"))))
+ (let ((default-directory (format "/sudo:%s@localhost:/" user-login-name)))
+ (should (member (compat-call executable-find "sh" t) '("/usr/bin/sh"
"/bin/sh")))
+ (should (member (compat-call executable-find "ls" t) '("/usr/bin/ls"
"/bin/ls")))))
+
+(ert-deftest exec-path ()
+ (should-equal (exec-path) exec-path)
+ (let ((default-directory (format "/sudo:%s@localhost:/" user-login-name)))
+ (should (file-directory-p (car (exec-path))))))
(ert-deftest with-existing-directory ()
(let ((dir (make-temp-name "/tmp/not-exist-")))
- [elpa] externals/compat updated (fcb99b1b1e -> 47953b014f), ELPA Syncer, 2023/01/16
- [elpa] externals/compat aea1ccfa92 1/6: Update documentation, test coverage is now 100%., ELPA Syncer, 2023/01/16
- [elpa] externals/compat 47953b014f 6/6: Add test for file-backup-file-names, ELPA Syncer, 2023/01/16
- [elpa] externals/compat 74ec2c1c56 5/6: Add test for make-nearby-temp-file, ELPA Syncer, 2023/01/16
- [elpa] externals/compat 041122b305 4/6: Update NEWS, ELPA Syncer, 2023/01/16
- [elpa] externals/compat b93ab4c0e0 2/6: Add test for executable-find, ELPA Syncer, 2023/01/16
- [elpa] externals/compat 394028541e 3/6: Add test for exec-path,
ELPA Syncer <=