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

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

[elpa] externals/eglot 05fe647 7/8: Per #667: add a passing test demonst


From: Stefan Monnier
Subject: [elpa] externals/eglot 05fe647 7/8: Per #667: add a passing test demonstrating clangd + TRAMP works
Date: Wed, 14 Apr 2021 18:53:08 -0400 (EDT)

branch: externals/eglot
commit 05fe6472cb1766e4dafae7562b8793d96d0bb271
Author: JoΓ£o TΓ‘vora <joaotavora@gmail.com>
Commit: JoΓ£o TΓ‘vora <joaotavora@gmail.com>

    Per #667: add a passing test demonstrating clangd + TRAMP works
    
    ... It works at least within the minimal, well-controlled reproducible
    settings of this test.  Maybe if we knew something more about the
    setup of the user who submitted this report we would be able to
    concoct a failing test, but we don't.
    
    * eglot-tests.el (subr-x): Require it
    (eglot--make-file-or-dir): Return expanded file name.
    (eglot-tests--lsp-abiding-column-1): New helper.
    (eglot-lsp-abiding-column): Use it.
    (eglot--tramp-test): Fix `skip-unless` condition.
    (eglot--tramp-test-2): New test.
---
 eglot-tests.el | 30 +++++++++++++++++++++++++-----
 eglot.el       | 11 ++++++++++-
 2 files changed, 35 insertions(+), 6 deletions(-)

diff --git a/eglot-tests.el b/eglot-tests.el
index dac953b..6e9ceeb 100644
--- a/eglot-tests.el
+++ b/eglot-tests.el
@@ -30,6 +30,7 @@
 (require 'edebug)
 (require 'python) ; python-mode-hook
 (require 'company nil t)
+(require 'subr-x)
 
 ;;; Helpers
 
@@ -63,7 +64,7 @@ then restored."
            (with-temp-buffer
              (insert content)
              (write-region nil nil file-or-dir-name nil 'nomessage))
-           (list file-or-dir-name))
+           (list (expand-file-name file-or-dir-name)))
           (t
            (eglot--error "Expected a string or a directory spec")))))
 
@@ -722,9 +723,7 @@ pyls prefers autopep over yafp, despite its README stating 
the contrary."
         (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'"
-  (skip-unless (executable-find "clangd"))
+(defun eglot-tests--lsp-abiding-column-1 ()
   (eglot--with-fixture
       '(("project" .
          (("foo.c" . "const char write_data[] = 
u8\"πŸš‚πŸšƒπŸš„πŸš…πŸš†πŸšˆπŸš‡πŸšˆπŸš‰πŸšŠπŸš‹πŸšŒπŸšŽπŸšπŸšžπŸšŸπŸš πŸš‘πŸ›€πŸ›²\";"))))
@@ -746,6 +745,11 @@ pyls prefers autopep over yafp, despite its README stating 
the contrary."
           (funcall eglot-move-to-column-function 71)
           (should (looking-at "p")))))))
 
+(ert-deftest eglot-lsp-abiding-column ()
+  "Test basic `eglot-lsp-abiding-column' and 
`eglot-move-to-lsp-abiding-column'"
+  (skip-unless (executable-find "clangd"))
+  (eglot-tests--lsp-abiding-column-1))
+
 (ert-deftest eglot-ensure ()
   "Test basic `eglot-ensure' functionality"
   (skip-unless (executable-find "pyls"))
@@ -1103,7 +1107,7 @@ will assume it exists."
 
 (ert-deftest eglot--tramp-test ()
   "Ensure LSP servers can be used over TRAMP."
-  (skip-unless (or (>= emacs-major-version 27) (executable-find "pyls")))
+  (skip-unless (and (>= emacs-major-version 27) (executable-find "pyls")))
   ;; Set up a loopback TRAMP method that’s just a shell so the remote
   ;; host is really just the local host.
   (let ((tramp-remote-path (cons 'tramp-own-remote-path tramp-remote-path))
@@ -1118,6 +1122,22 @@ will assume it exists."
     ;; method, fixtures will be automatically made β€œremote".
     (eglot-tests--auto-detect-running-server-1)))
 
+(ert-deftest eglot--tramp-test-2 ()
+  "Ensure LSP servers can be used over TRAMP."
+  (skip-unless (or (>= emacs-major-version 27) (executable-find "clangd")))
+  ;; Set up a loopback TRAMP method that’s just a shell so the remote
+  ;; host is really just the local host.
+  (let ((tramp-remote-path (cons 'tramp-own-remote-path tramp-remote-path))
+        (tramp-methods '(("loopback"
+                          (tramp-login-program "/bin/sh")
+                          (tramp-remote-shell "/bin/sh")
+                          (tramp-remote-shell-login ("-l"))
+                          (tramp-remote-shell-args ("-c")))))
+        (temporary-file-directory (concat "/loopback::"
+                                          temporary-file-directory))
+        (eglot-server-programs '((c-mode "clangd"))))
+    (eglot-tests--lsp-abiding-column-1) ))
+
 (ert-deftest eglot--path-to-uri-windows ()
   (should (string-prefix-p "file:///"
                            (eglot--path-to-uri "c:/Users/Foo/bar.lisp")))
diff --git a/eglot.el b/eglot.el
index cbde1b7..20f5995 100644
--- a/eglot.el
+++ b/eglot.el
@@ -25,7 +25,7 @@
 ;;; Commentary:
 
 ;; Simply M-x eglot should be enough to get you started, but here's a
-;; little info (see the accompanying README.md or the URL for more).
+ ;; little info (see the accompanying README.md or the URL for more).
 ;;
 ;; M-x eglot starts a server via a shell-command guessed from
 ;; `eglot-server-programs', using the current major-mode (for whatever
@@ -2791,6 +2791,15 @@ If NOERROR, return predicate, else erroring function."
                  if (file-directory-p f) append (eglot--files-recursively f)
                  else collect (expand-file-name f))))
 
+(defun eglot--directories-recursively (&optional dir)
+  "Because `directory-files-recursively' isn't complete in 26.3."
+  (cons (setq dir (expand-file-name (or dir default-directory)))
+        (cl-loop with default-directory = dir
+                 with completion-regexp-list = '("^[^.]")
+                 for f in (file-name-all-completions "" dir)
+                 if (file-directory-p f) append (eglot--files-recursively f)
+                 else collect (expand-file-name f))))
+
 (defun eglot--directories-matched-by-globs (dir globs)
   "Discover subdirectories of DIR with files matched by one of GLOBS.
 Each element of GLOBS is either an uncompiled glob-string or a



reply via email to

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