-
Notifications
You must be signed in to change notification settings - Fork 223
/
emacs-test.el
71 lines (59 loc) · 2.46 KB
/
emacs-test.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
;;; emacs-test.el --- Integration testing script -*- lexical-binding: t; -*-
;; Copyright (c) Microsoft Corporation.
;; Licensed under the MIT License.
;; Author: Andy Jordan <andy.jordan@microsoft.com>
;; Keywords: PowerShell, LSP
;;; Code:
;; Avoid using old packages.
(setq load-prefer-newer t)
;; Improved TLS Security.
(with-eval-after-load 'gnutls
(custom-set-variables
'(gnutls-verify-error t)
'(gnutls-min-prime-bits 3072)))
;; Package setup.
(require 'package)
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/") t)
(package-initialize)
(package-refresh-contents)
(require 'ert)
(require 'flymake)
(unless (package-installed-p 'powershell)
(package-install 'powershell))
(require 'powershell)
(unless (package-installed-p 'eglot)
(package-install 'eglot))
(require 'eglot)
(ert-deftest powershell-editor-services ()
"Eglot should connect to PowerShell Editor Services."
(let* ((repo (project-root (project-current)))
(start-script (expand-file-name "module/PowerShellEditorServices/Start-EditorServices.ps1" repo))
(module-path (expand-file-name "module" repo))
(log-path (expand-file-name "test/emacs-test.log" repo))
(session-path (expand-file-name "test/emacs-session.json" repo))
(test-script (expand-file-name "test/PowerShellEditorServices.Test.Shared/Debugging/VariableTest.ps1" repo))
(eglot-sync-connect t))
(add-to-list
'eglot-server-programs
`(powershell-mode
. ("pwsh" "-NoLogo" "-NoProfile" "-Command" ,start-script
"-HostName" "Emacs" "-HostProfileId" "Emacs" "-HostVersion" "1.0.0"
"-BundledModulesPath" ,module-path
"-LogPath" ,log-path "-LogLevel" "Diagnostic"
"-SessionDetailsPath" ,session-path
"-Stdio")))
(with-current-buffer (find-file-noselect test-script)
(should (eq major-mode 'powershell-mode))
(should (apply #'eglot--connect (eglot--guess-contact)))
(should (eglot-current-server))
(let ((lsp (eglot-current-server)))
(should (string= (eglot--project-nickname lsp) "PowerShellEditorServices"))
(should (member (cons 'powershell-mode "powershell") (eglot--languages lsp))))
(sleep-for 5) ; TODO: Wait for "textDocument/publishDiagnostics" instead
(flymake-start)
(goto-char (point-min))
(flymake-goto-next-error)
(should (eq 'flymake-warning (face-at-point))))))
(provide 'emacs-test)
;;; emacs-test.el ends here