branch: externals/elpa
commit a807b4f30b6128f64d1ad44271e62a39a9623dc8
Author: João Távora <[email protected]>
Commit: João Távora <[email protected]>
Some test-related cleanup
* Makefile (ELPADEPS): Change order of ELPADEPS.
* eglot-tests.el (eglot--call-with-fixture): Bind
python-indent-guess-indent-offset-verbose here.
(eglot--tests--python-mode-bindings): Remove.
(auto-detect-running-server, auto-shutdown, auto-reconnect)
(basic-diagnostics, rename-a-symbol, basic-completions, basic-xref)
(snippet-completions, snippet-completions-with-company)
(hover-after-completions, hover-multiline-doc-locus)
(python-autopep-formatting, python-yapf-formatting, json-basic)
(eglot-ensure, slow-sync-connection-wait, slow-sync-connection-intime)
(slow-async-connection, slow-sync-timeout): Don't use
eglot--tests--python-mode-bindings.
(eglot--guessing-contact): Reindent.
---
Makefile | 4 +-
eglot-tests.el | 117 ++++++++++++++++++++++++---------------------------------
2 files changed, 51 insertions(+), 70 deletions(-)
diff --git a/Makefile b/Makefile
index 1a39c65..dfbd69f 100644
--- a/Makefile
+++ b/Makefile
@@ -13,11 +13,11 @@ ELCFILES := $(ELFILES:.el=.elc)
ELPADEPS ?=--eval '(package-initialize)' \
--eval '(package-refresh-contents)' \
- --eval '(package-install (quote company))' \
--eval '(package-install (quote jsonrpc))' \
- --eval '(package-install (quote xref))' \
--eval '(package-install (quote project))' \
+ --eval '(package-install (quote xref))' \
--eval '(package-install (quote eldoc))' \
+ --eval '(package-install (quote company))' \
--eval '(package-install (quote yasnippet))' \
--eval '(package-install \
(cadr (assoc (quote flymake) \
diff --git a/eglot-tests.el b/eglot-tests.el
index f701a01..059a565 100644
--- a/eglot-tests.el
+++ b/eglot-tests.el
@@ -88,6 +88,8 @@ then restored."
;; Prevent user-configuration to have an influence on
;; language servers. (See github#441)
(cons "XDG_CONFIG_HOME=/dev/null" process-environment))
+ ;; Prevent "Can't guess python-indent-offset ..." messages.
+ (python-indent-guess-indent-offset-verbose . nil)
(eglot-server-initialized-hook
(lambda (server) (push server new-servers))))
(setq created-files (mapcan #'eglot--make-file-or-dir file-specs))
@@ -257,11 +259,6 @@ Pass TIMEOUT to `eglot--with-timeout'."
(eglot-connect-timeout timeout))
(apply #'eglot--connect (eglot--guess-contact))))
-(defvar eglot--tests--python-mode-bindings
- '(;; Prevent "Can't guess python-indent-offset ..." messages.
- (python-indent-guess-indent-offset-verbose . nil))
- "Alist of variable bindings to be used in tests involving `python-mode'.")
-
;;; Unit tests
@@ -313,8 +310,7 @@ Pass TIMEOUT to `eglot--with-timeout'."
(eglot--with-fixture
`(("project" . (("coiso.py" . "bla")
("merdix.py" . "bla")))
- ("anotherproject" . (("cena.py" . "bla")))
- ,@eglot--tests--python-mode-bindings)
+ ("anotherproject" . (("cena.py" . "bla"))))
(with-current-buffer
(eglot--find-file-noselect "project/coiso.py")
(should (setq server (eglot--tests-connect)))
@@ -333,8 +329,7 @@ Pass TIMEOUT to `eglot--with-timeout'."
(let (server
buffer)
(eglot--with-fixture
- `(("project" . (("coiso.py" . "def coiso: pass")))
- ,@eglot--tests--python-mode-bindings)
+ `(("project" . (("coiso.py" . "def coiso: pass"))))
(with-current-buffer
(setq buffer (eglot--find-file-noselect "project/coiso.py"))
(should (setq server (eglot--tests-connect)))
@@ -353,8 +348,7 @@ Pass TIMEOUT to `eglot--with-timeout'."
(let (server (eglot-autoreconnect 1))
(eglot--with-fixture
`(("project" . (("coiso.py" . "bla")
- ("merdix.py" . "bla")))
- ,@eglot--tests--python-mode-bindings)
+ ("merdix.py" . "bla"))))
(with-current-buffer
(eglot--find-file-noselect "project/coiso.py")
(should (setq server (eglot--tests-connect)))
@@ -412,8 +406,8 @@ Pass TIMEOUT to `eglot--with-timeout'."
(skip-unless (executable-find "pyls"))
(eglot--with-fixture
`(("diag-project" .
- (("main.py" . "def foo(): if True pass"))) ; colon missing after True
- ,@eglot--tests--python-mode-bindings)
+ ; colon missing after True
+ (("main.py" . "def foo(): if True pass"))))
(with-current-buffer
(eglot--find-file-noselect "diag-project/main.py")
(eglot--sniffing (:server-notifications s-notifs)
@@ -466,8 +460,7 @@ Pass TIMEOUT to `eglot--with-timeout'."
(eglot--with-fixture
`(("rename-project"
. (("main.py" .
- "def foo (bar) : 1 + bar\n\ndef bar() : pass")))
- ,@eglot--tests--python-mode-bindings)
+ "def foo (bar) : 1 + bar\n\ndef bar() : pass"))))
(with-current-buffer
(eglot--find-file-noselect "rename-project/main.py")
(eglot--tests-connect)
@@ -480,8 +473,7 @@ Pass TIMEOUT to `eglot--with-timeout'."
"Test basic autocompletion in a python LSP"
(skip-unless (executable-find "pyls"))
(eglot--with-fixture
- `(("project" . (("something.py" . "import sys\nsys.exi")))
- ,@eglot--tests--python-mode-bindings)
+ `(("project" . (("something.py" . "import sys\nsys.exi"))))
(with-current-buffer
(eglot--find-file-noselect "project/something.py")
(should (eglot--tests-connect))
@@ -493,8 +485,7 @@ Pass TIMEOUT to `eglot--with-timeout'."
"Test basic xref functionality in a python LSP"
(skip-unless (executable-find "pyls"))
(eglot--with-fixture
- `(("project" . (("something.py" . "def foo(): pass\ndef bar(): foo()")))
- ,@eglot--tests--python-mode-bindings)
+ `(("project" . (("something.py" . "def foo(): pass\ndef bar(): foo()"))))
(with-current-buffer
(eglot--find-file-noselect "project/something.py")
(should (eglot--tests-connect))
@@ -513,8 +504,7 @@ def foobazquuz(d, e, f): pass
(skip-unless (and (executable-find "pyls")
(functionp 'yas-minor-mode)))
(eglot--with-fixture
- `(("project" . (("something.py" . ,eglot--test-python-buffer)))
- ,@eglot--tests--python-mode-bindings)
+ `(("project" . (("something.py" . ,eglot--test-python-buffer))))
(with-current-buffer
(eglot--find-file-noselect "project/something.py")
(yas-minor-mode 1)
@@ -535,8 +525,7 @@ def foobazquuz(d, e, f): pass
(functionp 'yas-minor-mode)
(functionp 'company-complete)))
(eglot--with-fixture
- `(("project" . (("something.py" . ,eglot--test-python-buffer)))
- ,@eglot--tests--python-mode-bindings)
+ `(("project" . (("something.py" . ,eglot--test-python-buffer))))
(with-current-buffer
(eglot--find-file-noselect "project/something.py")
(yas-minor-mode 1)
@@ -561,25 +550,23 @@ def foobazquuz(d, e, f): pass
;; `eglot-put-doc-in-help-buffer' to nil.
(let ((eglot-put-doc-in-help-buffer nil))
(eglot--with-fixture
- `(("project" . (("something.py" . "import sys\nsys.exi")))
- ,@eglot--tests--python-mode-bindings)
- (with-current-buffer
- (eglot--find-file-noselect "project/something.py")
- (should (eglot--tests-connect))
- (goto-char (point-max))
- (setq eldoc-last-message nil)
- (completion-at-point)
- (should (looking-back "sys.exit"))
- (while (not eldoc-last-message) (accept-process-output nil 0.1))
- (should (string-match "^exit" eldoc-last-message))))))
+ `(("project" . (("something.py" . "import sys\nsys.exi"))))
+ (with-current-buffer
+ (eglot--find-file-noselect "project/something.py")
+ (should (eglot--tests-connect))
+ (goto-char (point-max))
+ (setq eldoc-last-message nil)
+ (completion-at-point)
+ (should (looking-back "sys.exit"))
+ (while (not eldoc-last-message) (accept-process-output nil 0.1))
+ (should (string-match "^exit" eldoc-last-message))))))
(ert-deftest hover-multiline-doc-locus ()
"Test if suitable amount of lines of hover info are shown."
(skip-unless (executable-find "pyls"))
(eglot--with-fixture
`(("project" . (("hover-first.py" . "from datetime import datetime")))
- (eglot-put-doc-in-help-buffer nil)
- ,@eglot--tests--python-mode-bindings)
+ (eglot-put-doc-in-help-buffer nil))
(with-current-buffer
(eglot--find-file-noselect "project/hover-first.py")
(should (eglot--tests-connect))
@@ -607,8 +594,7 @@ pyls prefers autopep over yafp, despite its README stating
the contrary."
(skip-unless (and (executable-find "pyls")
(executable-find "autopep8")))
(eglot--with-fixture
- `(("project" . (("something.py" . "def a():pass\n\ndef b():pass")))
- ,@eglot--tests--python-mode-bindings)
+ `(("project" . (("something.py" . "def a():pass\n\ndef b():pass"))))
(with-current-buffer
(eglot--find-file-noselect "project/something.py")
(should (eglot--tests-connect))
@@ -629,8 +615,7 @@ pyls prefers autopep over yafp, despite its README stating
the contrary."
(not (executable-find "autopep8"))
(executable-find "yapf")))
(eglot--with-fixture
- `(("project" . (("something.py" . "def a():pass\ndef b():pass")))
- ,@eglot--tests--python-mode-bindings)
+ `(("project" . (("something.py" . "def a():pass\ndef b():pass"))))
(with-current-buffer
(eglot--find-file-noselect "project/something.py")
(should (eglot--tests-connect))
@@ -678,23 +663,23 @@ pyls prefers autopep over yafp, despite its README
stating the contrary."
"Test basic autocompletion in vscode-json-languageserver"
(skip-unless (executable-find "vscode-json-languageserver"))
(eglot--with-fixture
- '(("project" .
- (("p.json" . "{\"foo.b")
- ("s.json" . "{\"properties\":{\"foo.bar\":{\"default\":\"fb\"}}}")
- (".git" . nil))))
- (with-current-buffer
- (eglot--find-file-noselect "project/p.json")
- (yas-minor-mode)
- (goto-char 2)
- (insert "\"$schema\": \"file://"
- (file-name-directory buffer-file-name) "s.json\",")
- (let ((eglot-server-programs
- '((js-mode . ("vscode-json-languageserver" "--stdio")))))
- (goto-char (point-max))
- (should (eglot--tests-connect))
- (completion-at-point)
- (should (looking-back "\"foo.bar\": \""))
- (should (looking-at "fb\"$"))))))
+ '(("project" .
+ (("p.json" . "{\"foo.b")
+ ("s.json" . "{\"properties\":{\"foo.bar\":{\"default\":\"fb\"}}}")
+ (".git" . nil))))
+ (with-current-buffer
+ (eglot--find-file-noselect "project/p.json")
+ (yas-minor-mode)
+ (goto-char 2)
+ (insert "\"$schema\": \"file://"
+ (file-name-directory buffer-file-name) "s.json\",")
+ (let ((eglot-server-programs
+ '((js-mode . ("vscode-json-languageserver" "--stdio")))))
+ (goto-char (point-max))
+ (should (eglot--tests-connect))
+ (completion-at-point)
+ (should (looking-back "\"foo.bar\": \""))
+ (should (looking-at "fb\"$"))))))
(ert-deftest eglot-lsp-abiding-column ()
"Test basic `eglot-lsp-abiding-column' and
`eglot-move-to-lsp-abiding-column'"
@@ -729,8 +714,7 @@ pyls prefers autopep over yafp, despite its README stating
the contrary."
(python-mode-hook
(eglot-ensure
(lambda ()
- (remove-hook 'flymake-diagnostic-functions 'python-flymake))))
- ,@eglot--tests--python-mode-bindings)
+ (remove-hook 'flymake-diagnostic-functions 'python-flymake)))))
(let (server)
;; need `ert-simulate-command' because `eglot-ensure'
;; relies on `post-command-hook'.
@@ -747,8 +731,7 @@ pyls prefers autopep over yafp, despite its README stating
the contrary."
"Connect with `eglot-sync-connect' set to t."
(skip-unless (executable-find "pyls"))
(eglot--with-fixture
- `(("project" . (("something.py" . "import sys\nsys.exi")))
- ,@eglot--tests--python-mode-bindings)
+ `(("project" . (("something.py" . "import sys\nsys.exi"))))
(with-current-buffer
(eglot--find-file-noselect "project/something.py")
(let ((eglot-sync-connect t)
@@ -760,8 +743,7 @@ pyls prefers autopep over yafp, despite its README stating
the contrary."
"Connect synchronously with `eglot-sync-connect' set to 2."
(skip-unless (executable-find "pyls"))
(eglot--with-fixture
- `(("project" . (("something.py" . "import sys\nsys.exi")))
- ,@eglot--tests--python-mode-bindings)
+ `(("project" . (("something.py" . "import sys\nsys.exi"))))
(with-current-buffer
(eglot--find-file-noselect "project/something.py")
(let ((eglot-sync-connect 2)
@@ -773,8 +755,7 @@ pyls prefers autopep over yafp, despite its README stating
the contrary."
"Connect asynchronously with `eglot-sync-connect' set to 2."
(skip-unless (executable-find "pyls"))
(eglot--with-fixture
- `(("project" . (("something.py" . "import sys\nsys.exi")))
- ,@eglot--tests--python-mode-bindings)
+ `(("project" . (("something.py" . "import sys\nsys.exi"))))
(with-current-buffer
(eglot--find-file-noselect "project/something.py")
(let ((eglot-sync-connect 1)
@@ -790,8 +771,7 @@ pyls prefers autopep over yafp, despite its README stating
the contrary."
"Failed attempt at connection synchronously."
(skip-unless (executable-find "pyls"))
(eglot--with-fixture
- `(("project" . (("something.py" . "import sys\nsys.exi")))
- ,@eglot--tests--python-mode-bindings)
+ `(("project" . (("something.py" . "import sys\nsys.exi"))))
(with-current-buffer
(eglot--find-file-noselect "project/something.py")
(let ((eglot-sync-connect t)
@@ -906,7 +886,8 @@ pyls prefers autopep over yafp, despite its README stating
the contrary."
(((CodeAction) title command)
(list title command)))))))
-(cl-defmacro eglot--guessing-contact ((interactive-sym prompt-args-sym
+(cl-defmacro eglot--guessing-contact ((interactive-sym
+ prompt-args-sym
guessed-class-sym guessed-contact-sym)
&body body)
"Evaluate BODY twice, binding results of `eglot--guess-contact'.