emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/eglot ae37c2a 35/62: Add a test for eglot-ensure. Make


From: Stefan Monnier
Subject: [elpa] externals/eglot ae37c2a 35/62: Add a test for eglot-ensure. Make
Date: Sat, 29 Sep 2018 17:13:33 -0400 (EDT)

branch: externals/eglot
commit ae37c2aa5eb6886cd522ec160c4c3cf210c2322b
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>

    Add a test for eglot-ensure.  Make
    
    sure it runs last, since a bug in the python-flymake backend may
    trigger a sentinel error that interferes with other tests.
    
    * eglot-tests.el (zzz-eglot-ensure): New test.
    (python, ert-x): Require it.
---
 eglot-tests.el | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/eglot-tests.el b/eglot-tests.el
index 26ddf1f..33d96a5 100644
--- a/eglot-tests.el
+++ b/eglot-tests.el
@@ -26,7 +26,9 @@
 (require 'eglot)
 (require 'cl-lib)
 (require 'ert)
+(require 'ert-x) ; ert-simulate-command
 (require 'edebug)
+(require 'python) ; python-mode-hook
 
 ;; Helpers
 
@@ -431,6 +433,29 @@ Pass TIMEOUT to `eglot--with-timeout'."
                                  (= severity 1))
                                diagnostics)))))))))
 
+(ert-deftest zzz-eglot-ensure ()
+  "Test basic `eglot-ensure' functionality"
+  (skip-unless (executable-find "pyls"))
+  (eglot--with-dirs-and-files
+      '(("project" . (("foo.py" . "import sys\nsys.exi")
+                      ("bar.py" . "import sys\nsys.exi"))))
+    (let ((saved-python-mode-hook python-mode-hook)
+          server)
+      (unwind-protect
+          (progn
+            (add-hook 'python-mode-hook 'eglot-ensure)
+            ;; need `ert-simulate-command' because `eglot-ensure'
+            ;; relies on `post-command-hook'.
+            (with-current-buffer
+                (ert-simulate-command
+                 '(find-file "project/foo.py"))
+              (should (setq server (eglot--current-server))))
+            (with-current-buffer
+                (ert-simulate-command
+                 '(find-file "project/bar.py"))
+              (should (eq server (eglot--current-server)))))
+        (setq python-mode-hook saved-python-mode-hook)))))
+
 (provide 'eglot-tests)
 ;;; eglot-tests.el ends here
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]