-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add sane defaults to
Start-EditorServices
and fix logs
We do not need to require so many CLI flags. This continues to run the existing Emacs and Vim tests utilizing those flags as a regression scenario, and adds an additional pair of tests that launch PSES with a minimal set of flags. This also fixes the log file path to be unique per process, and to use `LogPath` as a directory instead of a file.
- Loading branch information
1 parent
f77d222
commit fe7fe5a
Showing
8 changed files
with
152 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
;;; 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)) | ||
(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 "-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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
let s:suite = themis#suite('pses') | ||
let s:assert = themis#helper('assert') | ||
|
||
function s:suite.before() | ||
let l:pses_path = g:repo_root . '/module' | ||
let g:LanguageClient_serverCommands = { | ||
\ 'ps1': [ 'pwsh', '-NoLogo', '-NoProfile', '-Command', | ||
\ l:pses_path . '/PowerShellEditorServices/Start-EditorServices.ps1', '-Stdio' ] | ||
\ } | ||
let g:LanguageClient_serverStderr = 'DEBUG' | ||
let g:LanguageClient_loggingFile = g:repo_root . '/LanguageClient.log' | ||
let g:LanguageClient_serverStderr = g:repo_root . '/LanguageServer.log' | ||
endfunction | ||
|
||
function s:suite.has_language_client() | ||
call s:assert.includes(&runtimepath, g:repo_root . '/LanguageClient-neovim') | ||
call s:assert.cmd_exists('LanguageClientStart') | ||
call s:assert.not_empty(g:LanguageClient_serverCommands) | ||
call s:assert.true(LanguageClient#HasCommand('ps1')) | ||
endfunction | ||
|
||
function s:suite.analyzes_powershell_file() | ||
view test/vim-test.ps1 " This must not use quotes! | ||
|
||
let l:bufnr = bufnr('vim-test.ps1$') | ||
call s:assert.not_equal(l:bufnr, -1) | ||
let l:bufinfo = getbufinfo(l:bufnr)[0] | ||
|
||
call s:assert.equal(l:bufinfo.name, g:repo_root . '/test/vim-test.ps1') | ||
call s:assert.includes(getbufline(l:bufinfo.name, 1), 'function Do-Work {}') | ||
" TODO: This shouldn't be necessary, vim-ps1 works locally but not in CI. | ||
call setbufvar(l:bufinfo.bufnr, '&filetype', 'ps1') | ||
call s:assert.equal(getbufvar(l:bufinfo.bufnr, '&filetype'), 'ps1') | ||
|
||
execute 'LanguageClientStart' | ||
execute 'sleep' 5 | ||
call s:assert.equal(getbufvar(l:bufinfo.name, 'LanguageClient_isServerRunning'), 1) | ||
call s:assert.equal(getbufvar(l:bufinfo.name, 'LanguageClient_projectRoot'), g:repo_root) | ||
call s:assert.equal(getbufvar(l:bufinfo.name, 'LanguageClient_statusLineDiagnosticsCounts'), {'E': 0, 'W': 1, 'H': 0, 'I': 0}) | ||
endfunction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters