diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/progmodes/eglot-tests.el | 47 |
1 files changed, 36 insertions, 11 deletions
diff --git a/test/lisp/progmodes/eglot-tests.el b/test/lisp/progmodes/eglot-tests.el index 914f23bc9e3..4a75a1c5147 100644 --- a/test/lisp/progmodes/eglot-tests.el +++ b/test/lisp/progmodes/eglot-tests.el | |||
| @@ -230,7 +230,7 @@ directory hierarchy." | |||
| 230 | `(push message ,client-replies))))))))) | 230 | `(push message ,client-replies))))))))) |
| 231 | (unwind-protect | 231 | (unwind-protect |
| 232 | (progn | 232 | (progn |
| 233 | (add-hook 'jsonrpc-event-hook #',log-event-hook-sym) | 233 | (add-hook 'jsonrpc-event-hook #',log-event-hook-sym t) |
| 234 | ,@body) | 234 | ,@body) |
| 235 | (remove-hook 'jsonrpc-event-hook #',log-event-hook-sym)))))) | 235 | (remove-hook 'jsonrpc-event-hook #',log-event-hook-sym)))))) |
| 236 | 236 | ||
| @@ -452,17 +452,42 @@ directory hierarchy." | |||
| 452 | (find-file-noselect "symlink-project/main.cpp") | 452 | (find-file-noselect "symlink-project/main.cpp") |
| 453 | (make-symbolic-link "main.cpp" "mainlink.cpp") | 453 | (make-symbolic-link "main.cpp" "mainlink.cpp") |
| 454 | (eglot--tests-connect) | 454 | (eglot--tests-connect) |
| 455 | (find-file-noselect "mainlink.cpp") | 455 | (eglot--sniffing (:client-notifications c-notifs) |
| 456 | (let ((eglot-autoshutdown nil)) (kill-buffer (current-buffer))) | ||
| 457 | (eglot--wait-for (c-notifs 10) | ||
| 458 | (&key method &allow-other-keys) | ||
| 459 | (and (string= method "textDocument/didClose"))))) | ||
| 460 | (eglot--sniffing (:client-notifications c-notifs) | ||
| 456 | (with-current-buffer | 461 | (with-current-buffer |
| 457 | (find-file-noselect "foo.h") | 462 | (find-file-noselect "symlink-project/main.cpp") |
| 458 | (goto-char 5) | 463 | (should (eglot-current-server))) |
| 459 | (xref-find-references "foo") | 464 | (eglot--wait-for (c-notifs 10) |
| 460 | (with-current-buffer (get-buffer "*xref*") | 465 | (&rest whole &key params method &allow-other-keys) |
| 461 | (goto-char (point-max)) | 466 | (and (string= method "textDocument/didOpen") |
| 462 | ;; Expect xref buffer to not contain duplicate references to | 467 | (string-match "main.cpp$" |
| 463 | ;; main.c and mainlink.c. If it did, total lines would be 7. | 468 | (plist-get (plist-get params :textDocument) |
| 464 | ;; FIXME: make less brittle by counting actual references. | 469 | :uri))))) |
| 465 | (should (= (line-number-at-pos (point)) 5))))))) | 470 | ;; This last segment is deactivated, because it's likely not needed. |
| 471 | ;; The only way the server would answer with '3' references is if we | ||
| 472 | ;; had erroneously sent a 'didOpen' for anything other than | ||
| 473 | ;; `main.cpp', but if we got this far is because we've just asserted | ||
| 474 | ;; that we didn't. | ||
| 475 | (when nil | ||
| 476 | (with-current-buffer | ||
| 477 | (find-file-noselect "symlink-project/foo.h") | ||
| 478 | ;; Give clangd some time to settle its analysis so it can | ||
| 479 | ;; accurately respond to `textDocument/references' | ||
| 480 | (sleep-for 3) | ||
| 481 | (search-forward "foo") | ||
| 482 | (eglot--sniffing (:server-replies s-replies) | ||
| 483 | (call-interactively 'xref-find-references) | ||
| 484 | (eglot--wait-for (s-replies 10) | ||
| 485 | (&key method result &allow-other-keys) | ||
| 486 | ;; Expect xref buffer to not contain duplicate references to | ||
| 487 | ;; main.cpp and mainlink.cpp. If it did, 'result's length | ||
| 488 | ;; would be 3. | ||
| 489 | (and (string= method "textDocument/references") | ||
| 490 | (= (length result) 2)))))))) | ||
| 466 | 491 | ||
| 467 | (ert-deftest eglot-test-diagnostic-tags-unnecessary-code () | 492 | (ert-deftest eglot-test-diagnostic-tags-unnecessary-code () |
| 468 | "Test rendering of diagnostics tagged \"unnecessary\"." | 493 | "Test rendering of diagnostics tagged \"unnecessary\"." |