[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/elpa e690e8c 32/71: Per #474, #478: add more tests for
From: |
João Távora |
Subject: |
[elpa] externals/elpa e690e8c 32/71: Per #474, #478: add more tests for `eglot--guess-contact' |
Date: |
Wed, 16 Dec 2020 11:42:19 -0500 (EST) |
branch: externals/elpa
commit e690e8cc27e148c5c743c21d96c201e864686ab8
Author: Dan Davison <dandavison7@gmail.com>
Commit: João Távora <joaotavora@gmail.com>
Per #474, #478: add more tests for `eglot--guess-contact'
Modify eglot--guessing-contact so that (1) each test is run once with
eglot--guessing-contact INTERACTIVE argument set to t, and again with
it set to nil; (2) executable-find is mocked, and (3) arguments passed
to read-shell-command are captured and made available to tests.
Co-authored-by: João Távora <joaotavora@gmail.com>
* eglot-tests.el (eglot--guessing-contact): Rework.
(eglot-server-programs-simple-existing-executable): New test.
(eglot-server-programs-simple-executable)
(eglot-server-programs-executable-multiple-major-modes)
(eglot-server-programs-executable-with-arg)
(eglot-server-programs-executable-with-args-and-autoport)
(eglot-server-programs-host-and-port)
(eglot-server-programs-host-and-port-and-tcp-args)
(eglot-server-programs-class-name-and-plist)
(eglot-server-programs-class-name-and-contact-spec)
(eglot-server-programs-function): Add new test assertions.
---
eglot-tests.el | 69 ++++++++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 53 insertions(+), 16 deletions(-)
diff --git a/eglot-tests.el b/eglot-tests.el
index 909770c..919fc97 100644
--- a/eglot-tests.el
+++ b/eglot-tests.el
@@ -880,34 +880,65 @@ pyls prefers autopep over yafp, despite its README
stating the contrary."
(((CodeAction) title command)
(list title command)))))))
-(cl-defmacro eglot--guessing-contact ((guessed-class-sym guessed-contact-sym)
+(cl-defmacro eglot--guessing-contact ((interactive-sym prompt-args-sym
+ guessed-class-sym guessed-contact-sym)
&body body)
- "Bind the result of `eglot--guess-contact' then evaluate BODY."
+ "Evaluate BODY twice, binding results of `eglot--guess-contact'.
+
+INTERACTIVE-SYM is bound to the boolean passed to
+`eglot--guess-contact' each time. If the user would have been
+prompted, PROMPT-ARGS-SYM is bound to the list of arguments that
+would have been passed to `read-shell-command', else nil.
+GUESSED-CLASS-SYM and GUESSED-CONTACT-SYM are bound to the useful
+return values of `eglot--guess-contact'. Unless the server
+program evaluates to \"a-missing-executable.exe\", this macro
+will assume it exists."
(declare (indent 1) (debug t))
- `(let ((buffer-file-name "_"))
- (cl-destructuring-bind
- (_ _ ,guessed-class-sym ,guessed-contact-sym)
- (eglot--guess-contact)
- ,@body)))
+ (let ((i-sym (cl-gensym)))
+ `(dolist (,i-sym '(nil t))
+ (let ((,interactive-sym ,i-sym)
+ (buffer-file-name "_")
+ (,prompt-args-sym nil))
+ (cl-letf (((symbol-function 'executable-find)
+ (lambda (name) (unless (string-equal
+ name "a-missing-executable.exe")
+ (format "/totally-mock-bin/%s" name))))
+ ((symbol-function 'read-shell-command)
+ (lambda (&rest args) (setq ,prompt-args-sym args) "")))
+ (cl-destructuring-bind
+ (_ _ ,guessed-class-sym ,guessed-contact-sym)
+ (eglot--guess-contact ,i-sym)
+ ,@body))))))
(ert-deftest eglot-server-programs-simple-executable ()
(let ((eglot-server-programs '((foo-mode "some-executable")))
(major-mode 'foo-mode))
- (eglot--guessing-contact (guessed-class guessed-contact)
+ (eglot--guessing-contact (_ prompt-args guessed-class guessed-contact)
+ (should (not prompt-args))
(should (equal guessed-class 'eglot-lsp-server))
(should (equal guessed-contact '("some-executable"))))))
+(ert-deftest eglot-server-programs-simple-missing-executable ()
+ (let ((eglot-server-programs '((foo-mode "a-missing-executable.exe")))
+ (major-mode 'foo-mode))
+ (eglot--guessing-contact (interactive-p prompt-args guessed-class
guessed-contact)
+ (should (equal (not prompt-args) (not interactive-p)))
+ (should (equal guessed-class 'eglot-lsp-server))
+ (should (equal guessed-contact '("a-missing-executable.exe"))))))
+
(ert-deftest eglot-server-programs-executable-multiple-major-modes ()
(let ((eglot-server-programs '(((bar-mode foo-mode) "some-executable")))
(major-mode 'foo-mode))
- (eglot--guessing-contact (guessed-class guessed-contact)
+ (eglot--guessing-contact (_ prompt-args guessed-class guessed-contact)
+ (should (not prompt-args))
(should (equal guessed-class 'eglot-lsp-server))
(should (equal guessed-contact '("some-executable"))))))
(ert-deftest eglot-server-programs-executable-with-arg ()
(let ((eglot-server-programs '((foo-mode "some-executable" "arg1")))
(major-mode 'foo-mode))
- (eglot--guessing-contact (guessed-class guessed-contact)
+ (eglot--guessing-contact (_ prompt-args guessed-class guessed-contact)
+ (should (not prompt-args))
(should (equal guessed-class 'eglot-lsp-server))
(should (equal guessed-contact '("some-executable" "arg1"))))))
@@ -915,7 +946,8 @@ pyls prefers autopep over yafp, despite its README stating
the contrary."
(let ((eglot-server-programs '((foo-mode "some-executable" "arg1"
:autoport "arg2")))
(major-mode 'foo-mode))
- (eglot--guessing-contact (guessed-class guessed-contact)
+ (eglot--guessing-contact (_ prompt-args guessed-class guessed-contact)
+ (should (not prompt-args))
(should (equal guessed-class 'eglot-lsp-server))
(should (equal guessed-contact '("some-executable" "arg1"
:autoport "arg2"))))))
@@ -923,7 +955,8 @@ pyls prefers autopep over yafp, despite its README stating
the contrary."
(ert-deftest eglot-server-programs-host-and-port ()
(let ((eglot-server-programs '((foo-mode "somehost.example.com" 7777)))
(major-mode 'foo-mode))
- (eglot--guessing-contact (guessed-class guessed-contact)
+ (eglot--guessing-contact (_ prompt-args guessed-class guessed-contact)
+ (should (not prompt-args))
(should (equal guessed-class 'eglot-lsp-server))
(should (equal guessed-contact '("somehost.example.com" 7777))))))
@@ -931,7 +964,8 @@ pyls prefers autopep over yafp, despite its README stating
the contrary."
(let ((eglot-server-programs '((foo-mode "somehost.example.com" 7777
:type network)))
(major-mode 'foo-mode))
- (eglot--guessing-contact (guessed-class guessed-contact)
+ (eglot--guessing-contact (_ prompt-args guessed-class guessed-contact)
+ (should (not prompt-args))
(should (equal guessed-class 'eglot-lsp-server))
(should (equal guessed-contact '("somehost.example.com" 7777
:type network))))))
@@ -939,7 +973,8 @@ pyls prefers autopep over yafp, despite its README stating
the contrary."
(ert-deftest eglot-server-programs-class-name-and-plist ()
(let ((eglot-server-programs '((foo-mode bar-class :init-key init-val)))
(major-mode 'foo-mode))
- (eglot--guessing-contact (guessed-class guessed-contact)
+ (eglot--guessing-contact (_ prompt-args guessed-class guessed-contact)
+ (should (not prompt-args))
(should (equal guessed-class 'bar-class))
(should (equal guessed-contact '(:init-key init-val))))))
@@ -947,7 +982,8 @@ pyls prefers autopep over yafp, despite its README stating
the contrary."
(let ((eglot-server-programs '((foo-mode bar-class "some-executable" "arg1"
:autoport "arg2")))
(major-mode 'foo-mode))
- (eglot--guessing-contact (guessed-class guessed-contact)
+ (eglot--guessing-contact (_ prompt-args guessed-class guessed-contact)
+ (should (not prompt-args))
(should (equal guessed-class 'bar-class))
(should (equal guessed-contact '("some-executable" "arg1"
:autoport "arg2"))))))
@@ -956,7 +992,8 @@ pyls prefers autopep over yafp, despite its README stating
the contrary."
(let ((eglot-server-programs '((foo-mode . (lambda (&optional _)
'("some-executable")))))
(major-mode 'foo-mode))
- (eglot--guessing-contact (guessed-class guessed-contact)
+ (eglot--guessing-contact (_ prompt-args guessed-class guessed-contact)
+ (should (not prompt-args))
(should (equal guessed-class 'eglot-lsp-server))
(should (equal guessed-contact '("some-executable"))))))
- [elpa] externals/elpa 8dd0a15 67/71: Fix #367: Robustify previous fix of onChange breakage, (continued)
- [elpa] externals/elpa 8dd0a15 67/71: Fix #367: Robustify previous fix of onChange breakage, João Távora, 2020/12/16
- [elpa] externals/elpa a2fa9ab 21/71: Per #408: fontify markdown source code blocks by default, João Távora, 2020/12/16
- [elpa] externals/elpa c9230e8 20/71: Close #408: Declare markdown support iff gfm-view-mode installed, João Távora, 2020/12/16
- [elpa] externals/elpa 3483a2f 10/71: Tests: print contents of *EGLOT ...* buffers in batch mode., João Távora, 2020/12/16
- [elpa] externals/elpa e1e7362 07/71: Fix #445: don't reupdate help buffer if already rendered, João Távora, 2020/12/16
- [elpa] externals/elpa f7a7e33 15/71: Tweak docstring of eglot-server-programs, João Távora, 2020/12/16
- [elpa] externals/elpa eb29f7c 19/71: Close #450: always string-trim markup, João Távora, 2020/12/16
- [elpa] externals/elpa da04fdc 14/71: Close #303: support hierarchical DocumentSymbol in eglot-imenu, João Távora, 2020/12/16
- [elpa] externals/elpa 50f9a69 25/71: Fix #433: survive hover responses with empty markdown strings, João Távora, 2020/12/16
- [elpa] externals/elpa d244cc5 22/71: Per #443: tweak handling of eldoc-echo-area-use-multiline-p, João Távora, 2020/12/16
- [elpa] externals/elpa e690e8c 32/71: Per #474, #478: add more tests for `eglot--guess-contact',
João Távora <=
- [elpa] externals/elpa bb51d47 30/71: Close #409: make a test more robust, João Távora, 2020/12/16
- [elpa] externals/elpa 1cfcef4 37/71: Close #471: add support for erlang_ls, João Távora, 2020/12/16
- [elpa] externals/elpa da7ff48 31/71: Fix #468: don't call flymake report function if flymake is disabled, João Távora, 2020/12/16
- [elpa] externals/elpa e514f9e 29/71: Close #461: make CI fail if byte compiler warns, João Távora, 2020/12/16
- [elpa] externals/elpa ffe79b9 34/71: Pin pyls to 0.31.10, João Távora, 2020/12/16
- [elpa] externals/elpa b0bfbfb 38/71: Fix #488: fix type error in eglot--xref-make-match, João Távora, 2020/12/16
- [elpa] externals/elpa 3634402 36/71: Fix #479: correctly place diagnostics in narrowed buffers, João Távora, 2020/12/16
- [elpa] externals/elpa e7a43e2 40/71: Fix #480: also consider label of a CompletionItem for snippets, João Távora, 2020/12/16
- [elpa] externals/elpa a807b4f 43/71: Some test-related cleanup, João Távora, 2020/12/16
- [elpa] externals/elpa 9874456 42/71: Close #482: use filter-buffer-substring to get buffer text, João Távora, 2020/12/16