[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/eglot 433361e 10/15: Add some completion tests for pyls
From: |
Jo�o T�vora |
Subject: |
[elpa] externals/eglot 433361e 10/15: Add some completion tests for pyls |
Date: |
Sun, 20 May 2018 19:59:03 -0400 (EDT) |
branch: externals/eglot
commit 433361ee9bb607961ffe13b3a560a7a9001ba216
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Add some completion tests for pyls
* eglot-tests.el (edebug): Require it.
(eglot--call-with-dirs-and-files): Simplify.
(eglot--call-with-test-timeout): Don't timeout if edebug.
(auto-detect-running-server, auto-reconnect): Skip unless rls is
found.
(basic-completions): New test.
(hover-after-completions): New failing test.
* eglot.el (eglot-eldoc-function): Force write
eldoc-last-message, for tests sake.
---
eglot-tests.el | 74 +++++++++++++++++++++++++++++++++++++++++++---------------
eglot.el | 4 ++--
2 files changed, 57 insertions(+), 21 deletions(-)
diff --git a/eglot-tests.el b/eglot-tests.el
index accb113..3f06732 100644
--- a/eglot-tests.el
+++ b/eglot-tests.el
@@ -26,6 +26,7 @@
(require 'eglot)
(require 'cl-lib)
(require 'ert)
+(require 'edebug)
;; Helpers
@@ -51,24 +52,24 @@
(defun eglot--call-with-dirs-and-files (dirs fn)
(let* ((default-directory (make-temp-file "eglot--fixture" t))
new-buffers new-processes)
- (with-temp-message ""
- (unwind-protect
- (let ((find-file-hook
- (cons (lambda () (push (current-buffer) new-buffers))
- find-file-hook))
- (eglot-connect-hook
- (lambda (proc) (push proc new-processes))))
- (mapc #'eglot--make-file-or-dirs dirs)
- (funcall fn))
- (eglot--message "Killing buffers %s, deleting %s, killing %s"
- (mapconcat #'buffer-name new-buffers ", ")
- default-directory
- new-processes)
- (delete-directory default-directory 'recursive)
- (let ((eglot-autoreconnect nil))
- (mapc #'eglot-shutdown
- (cl-remove-if-not #'process-live-p new-processes)))
- (mapc #'kill-buffer new-buffers)))))
+ (unwind-protect
+ (let ((find-file-hook
+ (cons (lambda () (push (current-buffer) new-buffers))
+ find-file-hook))
+ (eglot-connect-hook
+ (lambda (proc) (push proc new-processes))))
+ (mapc #'eglot--make-file-or-dirs dirs)
+ (funcall fn))
+ (eglot--message "Killing buffers %s, deleting %s, killing %s"
+ (mapconcat #'buffer-name new-buffers ", ")
+ default-directory
+ new-processes)
+ (let ((eglot-autoreconnect nil))
+ (mapc #'eglot-shutdown
+ (cl-remove-if-not #'process-live-p new-processes)))
+ (dolist (buf new-buffers) ;; have to save otherwise will get prompted
+ (with-current-buffer buf (save-buffer) (kill-buffer)))
+ (delete-directory default-directory 'recursive))))
(cl-defmacro eglot--with-test-timeout (timeout &body body)
(declare (indent 1) (debug t))
@@ -85,7 +86,9 @@
(catch tag
(setq timer
(run-with-timer timeout nil
- (lambda () (throw tag timed-out))))
+ (lambda ()
+ (unless edebug-active
+ (throw tag timed-out)))))
(funcall fn)))
(cancel-timer timer)
(when (eq retval timed-out)
@@ -108,6 +111,7 @@
(ert-deftest auto-detect-running-server ()
"Visit a file and M-x eglot, then visit a neighbour. "
+ (skip-unless (executable-find "rls"))
(let (proc)
(eglot--with-test-timeout 2
(eglot--with-dirs-and-files
@@ -130,6 +134,7 @@
(ert-deftest auto-reconnect ()
"Start a server. Kill it. Watch it reconnect."
+ (skip-unless (executable-find "rls"))
(let (proc
(eglot-autoreconnect 1))
(eglot--with-test-timeout 3
@@ -152,6 +157,37 @@
(while (process-live-p proc) (accept-process-output nil 0.5))
(should (not (eglot--current-process))))))))
+(ert-deftest basic-completions ()
+ "Test basic autocompletion in a python LSP"
+ (skip-unless (executable-find "pyls"))
+ (unwind-protect
+ (eglot--with-test-timeout 10
+ (eglot--with-dirs-and-files
+ '(("project" . (("something.py" . "import sys\nsys.exi"))))
+ (with-current-buffer
+ (eglot--find-file-noselect "project/something.py")
+ (eglot 'python-mode `(transient . ,default-directory) '("pyls"))
+ (goto-char (point-max))
+ (completion-at-point)
+ (should (looking-back "sys.exit"))
+ )))))
+
+(ert-deftest hover-after-completions ()
+ "Test basic autocompletion in a python LSP"
+ (skip-unless (executable-find "pyls"))
+ (eglot--with-test-timeout 3
+ (eglot--with-dirs-and-files
+ '(("project" . (("something.py" . "import sys\nsys.exi"))))
+ (with-current-buffer
+ (eglot--find-file-noselect "project/something.py")
+ (eglot 'python-mode `(transient . ,default-directory) '("pyls"))
+ (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))))))
+
(provide 'eglot-tests)
;;; eglot-tests.el ends here
diff --git a/eglot.el b/eglot.el
index 5829aff..e9da523 100644
--- a/eglot.el
+++ b/eglot.el
@@ -1429,8 +1429,8 @@ If SKIP-SIGNATURE, don't try to send
textDocument/signatureHelp."
proc :textDocument/hover position-params
:success-fn (eglot--lambda (&key contents range)
(unless sig-showing
- (when-buffer-window
- (eldoc-message (eglot--hover-info contents range)))))
+ (setq eldoc-last-message (eglot--hover-info contents
range))
+ (when-buffer-window (eldoc-message
eldoc-last-message))))
:deferred :textDocument/hover))
(when (eglot--server-capable :documentHighlightProvider)
(eglot--async-request
- [elpa] externals/eglot 258fb98 12/15: Travis now runs python-language-server tests, (continued)
- [elpa] externals/eglot 258fb98 12/15: Travis now runs python-language-server tests, Jo�o T�vora, 2018/05/20
- [elpa] externals/eglot 99686a9 11/15: * eglot.el (Version): Bump to 0.4, Jo�o T�vora, 2018/05/20
- [elpa] externals/eglot 6894ed7 13/15: Tweak tests, hopefully stabilize pyls tests on Travis, Jo�o T�vora, 2018/05/20
- [elpa] externals/eglot 4b9f4da 03/15: If we're going to send rootPath, better send an absolute one, Jo�o T�vora, 2018/05/20
- [elpa] externals/eglot 2ede684 06/15: Better decide what text exactly to present as completions, Jo�o T�vora, 2018/05/20
- [elpa] externals/eglot 17b7740 05/15: * eglot.el (eglot-clear-status): Remember to update modeline, Jo�o T�vora, 2018/05/20
- [elpa] externals/eglot b45cb80 02/15: Robustify timer handling for eglot--async-request, Jo�o T�vora, 2018/05/20
- [elpa] externals/eglot ace6fce 07/15: Check capabilities before sending :completionItem/resolve, Jo�o T�vora, 2018/05/20
- [elpa] externals/eglot 24877ae 15/15: Fix a bug introduced in the previous commit, Jo�o T�vora, 2018/05/20
- [elpa] externals/eglot 95c2052 09/15: Handle managed buffers in own process var, Jo�o T�vora, 2018/05/20
- [elpa] externals/eglot 433361e 10/15: Add some completion tests for pyls,
Jo�o T�vora <=
- [elpa] externals/eglot 50b974f 14/15: Rewrite a couple of defs and shave a yak, Jo�o T�vora, 2018/05/20