[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/urgrep 559b2c07cd 091/115: Add a unit test for getting
|
From: |
ELPA Syncer |
|
Subject: |
[elpa] externals/urgrep 559b2c07cd 091/115: Add a unit test for getting the preferred tool on multiple hosts |
|
Date: |
Wed, 10 May 2023 03:00:47 -0400 (EDT) |
branch: externals/urgrep
commit 559b2c07cd18ba23cee729b9b1b7f92b6fecc9f5
Author: Jim Porter <jporterbugs@gmail.com>
Commit: Jim Porter <jporterbugs@gmail.com>
Add a unit test for getting the preferred tool on multiple hosts
---
urgrep-tests.el | 40 +++++++++++++++++++++++++++++++++++++++-
1 file changed, 39 insertions(+), 1 deletion(-)
diff --git a/urgrep-tests.el b/urgrep-tests.el
index 3b83a6c770..47e97fc635 100644
--- a/urgrep-tests.el
+++ b/urgrep-tests.el
@@ -24,11 +24,25 @@
;;; Code:
-(require 'ert)
+;; FIXME: Work around Emacs bug#58265.
+(let ((orig-home (getenv "HOME")))
+ (require 'ert)
+ (require 'tramp)
+ (require 'ert-x)
+ (setenv "HOME" orig-home))
(unless (fboundp 'always)
(defun always (&rest _) t))
+(defun urgrep-tests-remote-accessible-p ()
+ "Return whether a test involving remote files can proceed."
+ (let ((inhibit-message t))
+ (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)))))
+
(ert-deftest urgrep-tests-common-prefix ()
(should (equal (urgrep--common-prefix "foo" "bar") ""))
(should (equal (urgrep--common-prefix "bar" "baz") "ba")))
@@ -502,6 +516,30 @@
(should (equal (urgrep--get-prop 'executable-name tool) "gf"))
(should (equal urgrep--host-defaults nil)))))
+(ert-deftest urgrep-tests-get-tool-remote-host ()
+ (skip-unless (urgrep-tests-remote-accessible-p))
+ (connection-local-set-profile-variables
+ 'urgrep-test-ripgrep
+ '((urgrep-preferred-tools . (ripgrep))))
+ (let ((default-directory ert-remote-temporary-file-directory))
+ (connection-local-set-profiles
+ (connection-local-criteria-for-default-directory) 'urgrep-test-ripgrep))
+ (cl-letf (((symbol-function #'executable-find) #'always)
+ (urgrep--host-defaults nil))
+ ;; Get the preferred tool on the local host.
+ (let ((tool (with-connection-local-variables (urgrep-get-tool))))
+ (should (equal (car tool) 'ugrep))
+ (should (equal (urgrep--get-prop 'executable-name tool) "ugrep")))
+ ;; Now try on a remote host.
+ (let* ((default-directory ert-remote-temporary-file-directory)
+ (tool (with-connection-local-variables (urgrep-get-tool))))
+ (should (equal (car tool) 'ripgrep))
+ (should (equal (urgrep--get-prop 'executable-name tool) "rg")))
+ ;; Try again on the local host to make sure it didn't change.
+ (let ((tool (with-connection-local-variables (urgrep-get-tool))))
+ (should (equal (car tool) 'ugrep))
+ (should (equal (urgrep--get-prop 'executable-name tool) "ugrep")))))
+
(defun urgrep-tests--check-match-at-point ()
(let* ((line (string-to-number (current-word)))
(loc
- [elpa] externals/urgrep 3599ad1a56 033/115: Update comment, (continued)
- [elpa] externals/urgrep 3599ad1a56 033/115: Update comment, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep ba2b01b91b 042/115: Remove no-longer-needed `post-arguments', ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 3643c933c4 055/115: Add support for ugrep, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 0de93bfdb9 068/115: Fix use of wgrep on long urgrep results, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep e2e8898ab2 074/115: Update copyright, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 0c966b2001 075/115: Ensure `default-directory' stays in sync, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep c15be33112 076/115: Wrap shell argument quoting with `with-connection-local-variables`, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep e63c6c5173 089/115: Add link to wgrep package and clarify the README, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 61478da305 077/115: Improve reliability of running urgrep over Tramp, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 77fcfc1916 090/115: Use `push` instead of `add-to-list`, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 559b2c07cd 091/115: Add a unit test for getting the preferred tool on multiple hosts,
ELPA Syncer <=
- [elpa] externals/urgrep fe13a3cbb5 081/115: Fix project-root call on Emacs 27, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep f2c87e7520 080/115: Improve robustness of tests for grep command generation, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep b03a3d84ec 098/115: Add `suffix` argument to `urgrep--get-prop(-pcase)?`, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep eb5191bfd5 097/115: Update copyright year, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 43c82e84ec 082/115: Add CI for Emacs 27.1, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 3082d89bd9 099/115: Add support for abbreviating the command in urgrep buffers, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep b5b426e9ca 084/115: Fix hiding excessive part of rgrep command in Emacs 28, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 56acdfe434 087/115: Improve how we wait for urgrep to finish in tests, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 30cc9e363e 085/115: Fix context-line detection for find/grep, ELPA Syncer, 2023/05/10
- [elpa] externals/urgrep 0b036cdcf4 100/115: Improve explanation of `C-u C-u` for choosing directory, ELPA Syncer, 2023/05/10