|
28 | 28 | (require 'eglot-fsharp)
|
29 | 29 | (require 'eglot-tests)
|
30 | 30 |
|
| 31 | +(defun eglot-fsharp--sniff-diagnostics () |
| 32 | + (eglot--sniffing (:server-notifications s-notifs) |
| 33 | + (eglot--wait-for (s-notifs 20) |
| 34 | + (&key _id method &allow-other-keys) |
| 35 | + (string= method "textDocument/publishDiagnostics")))) |
| 36 | + |
31 | 37 | (describe "F# LSP server"
|
32 | 38 | (it "Can be installed"
|
33 | 39 | (eglot-fsharp--maybe-install)
|
34 | 40 | (expect (file-exists-p (eglot-fsharp--path-to-server)) :to-be t))
|
| 41 | + (it "shows flymake errors" |
| 42 | + (with-current-buffer (eglot--find-file-noselect "test/Test1/Error.fs") |
| 43 | + (eglot--tests-connect 10) |
| 44 | + (search-forward "nonexisting") |
| 45 | + (flymake-mode t) |
| 46 | + (flymake-start) |
| 47 | + (goto-char (point-min)) |
| 48 | + (eglot-fsharp--sniff-diagnostics) |
| 49 | + (flymake-goto-next-error 1 '() t) |
| 50 | + (expect (face-at-point) :to-be 'flymake-error ))) |
35 | 51 | (it "is enabled on F# Files"
|
36 | 52 | (with-current-buffer (eglot--find-file-noselect "test/Test1/FileTwo.fs")
|
37 |
| - (eglot--tests-connect 30) |
38 | 53 | (expect (type-of (eglot--current-server-or-lose)) :to-be 'eglot-fsautocomplete)))
|
39 | 54 | (it "provides completion"
|
40 | 55 | (with-current-buffer (eglot--find-file-noselect "test/Test1/FileTwo.fs")
|
| 56 | + (eglot-fsharp--sniff-diagnostics) |
41 | 57 | (expect (plist-get (eglot--capabilities (eglot--current-server-or-lose)) :completionProvider) :not :to-be nil)))
|
42 | 58 | (it "completes function in other modules"
|
43 | 59 | (with-current-buffer (eglot--find-file-noselect "test/Test1/Program.fs")
|
44 | 60 | (search-forward "X.func")
|
45 | 61 | (delete-char -3)
|
46 | 62 | ;; ERROR in fsautocomplet.exe? Should block instead of "no type check results"
|
47 |
| - (eglot--sniffing (:server-notifications s-notifs) |
48 |
| - (eglot--wait-for (s-notifs 90) |
49 |
| - (&key _id method &allow-other-keys) |
50 |
| - (string= method "textDocument/publishDiagnostics"))) |
| 63 | + (eglot-fsharp--sniff-diagnostics) |
51 | 64 | (completion-at-point)
|
52 |
| - (expect (looking-back "X\\.func") :to-be t)))) |
| 65 | + (expect (looking-back "X\\.func") :to-be t))) |
| 66 | + (it "doesn't throw error when definition does not exist" |
| 67 | + (with-current-buffer (eglot--find-file-noselect "test/Test1/Program.fs") |
| 68 | + (eglot-fsharp--sniff-diagnostics) |
| 69 | + (goto-char 253) |
| 70 | + (expect (current-word) :to-equal "printfn") ;sanity check |
| 71 | + (expect |
| 72 | + (condition-case err |
| 73 | + (call-interactively #'xref-find-definitions) |
| 74 | + (user-error |
| 75 | + (cadr err))) |
| 76 | + :to-equal "No definitions found for: LSP identifier at point."))) |
| 77 | + (it "finds definitions in other files of Project" |
| 78 | + (with-current-buffer (eglot--find-file-noselect "test/Test1/Program.fs") |
| 79 | + (goto-char 150) |
| 80 | + (expect (current-word) :to-equal "NewObjectType") ;sanity check |
| 81 | + (call-interactively #'xref-find-definitions) |
| 82 | + (expect (file-name-nondirectory (buffer-file-name)) :to-equal "FileTwo.fs")))) |
53 | 83 |
|
54 | 84 | (provide 'integration-tests)
|
55 | 85 | ;;; integration-tests.el ends here
|
0 commit comments