Skip to content

Commit f3c504c

Browse files
Add end-to-end integration test with Vim (#1874)
1 parent c31a39f commit f3c504c

File tree

5 files changed

+105
-1
lines changed

5 files changed

+105
-1
lines changed

.github/workflows/emacs-test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111

1212
jobs:
1313
test:
14-
name: Test PSES with Emacs via Eglot
14+
name: Test via Eglot
1515
runs-on: ubuntu-latest
1616
steps:
1717
- name: Checkout repository

.github/workflows/vim-test.yml

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: "Vim"
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
tags: [ v* ]
7+
pull_request:
8+
# The branches below must be a subset of the branches above
9+
branches: [ main ]
10+
paths-ignore: [ '**/*.md' ]
11+
12+
jobs:
13+
test:
14+
name: Test via LanguageClient-neovim
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v3
19+
20+
- name: Build PSES
21+
shell: pwsh
22+
run: tools/azurePipelinesBuild.ps1
23+
24+
- name: Install Vim
25+
uses: rhysd/action-setup-vim@v1
26+
id: vim
27+
28+
- name: Checkout vim-ps1
29+
uses: actions/checkout@v3
30+
with:
31+
repository: PProvost/vim-ps1
32+
path: vim-ps1
33+
34+
- name: Checkout LanguageClient-neovim
35+
uses: actions/checkout@v3
36+
with:
37+
repository: autozimu/LanguageClient-neovim
38+
path: LanguageClient-neovim
39+
40+
- name: Install LanguageClient-neovim
41+
run: ./install.sh
42+
working-directory: LanguageClient-neovim
43+
44+
- name: Checkout Themis
45+
uses: actions/checkout@v3
46+
with:
47+
repository: thinca/vim-themis
48+
path: vim-themis
49+
50+
- name: Run Themis
51+
env:
52+
THEMIS_VIM: ${{ steps.vim.outputs.executable }}
53+
run: ./vim-themis/bin/themis ./test/vim-test.vim

test/.themisrc

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
filetype plugin on
2+
3+
let g:repo_root = fnamemodify(expand('<sfile>'), ':h:h')
4+
5+
call themis#option('runtimepath', g:repo_root . '/LanguageClient-neovim')
6+
call themis#option('runtimepath', g:repo_root . '/vim-ps1')

test/vim-test.ps1

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
function Do-Work {}

test/vim-test.vim

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
let s:suite = themis#suite('pses')
2+
let s:assert = themis#helper('assert')
3+
4+
function s:suite.before()
5+
let l:pses_path = g:repo_root . '/module'
6+
let g:LanguageClient_serverCommands = {
7+
\ 'ps1': ['pwsh', '-NoLogo', '-NoProfile', '-Command',
8+
\ l:pses_path . '/PowerShellEditorServices/Start-EditorServices.ps1',
9+
\ '-HostName', 'vim', '-HostProfileId', 'vim', '-HostVersion', '1.0.0',
10+
\ '-BundledModulesPath', l:pses_path, '-Stdio',
11+
\ '-LogPath', g:repo_root . '/pses.log', '-LogLevel', 'Diagnostic',
12+
\ '-SessionDetailsPath', g:repo_root . '/pses_session.json' ]
13+
\ }
14+
let g:LanguageClient_serverStderr = 'DEBUG'
15+
let g:LanguageClient_loggingFile = g:repo_root . '/LanguageClient.log'
16+
let g:LanguageClient_serverStderr = g:repo_root . '/LanguageServer.log'
17+
endfunction
18+
19+
function s:suite.has_language_client()
20+
call s:assert.includes(&runtimepath, g:repo_root . '/LanguageClient-neovim')
21+
call s:assert.cmd_exists('LanguageClientStart')
22+
call s:assert.not_empty(g:LanguageClient_serverCommands)
23+
call s:assert.true(LanguageClient#HasCommand('ps1'))
24+
endfunction
25+
26+
function s:suite.analyzes_powershell_file()
27+
view test/vim-test.ps1 " This must not use quotes!
28+
29+
let l:bufnr = bufnr('vim-test.ps1$')
30+
call s:assert.not_equal(l:bufnr, -1)
31+
let l:bufinfo = getbufinfo(l:bufnr)[0]
32+
33+
call s:assert.equal(l:bufinfo.name, g:repo_root . '/test/vim-test.ps1')
34+
call s:assert.includes(getbufline(l:bufinfo.name, 1), 'function Do-Work {}')
35+
" TODO: This shouldn't be necessary, vim-ps1 works locally but not in CI.
36+
call setbufvar(l:bufinfo.bufnr, '&filetype', 'ps1')
37+
call s:assert.equal(getbufvar(l:bufinfo.bufnr, '&filetype'), 'ps1')
38+
39+
execute 'LanguageClientStart'
40+
execute 'sleep' 5
41+
call s:assert.equal(getbufvar(l:bufinfo.name, 'LanguageClient_isServerRunning'), 1)
42+
call s:assert.equal(getbufvar(l:bufinfo.name, 'LanguageClient_projectRoot'), g:repo_root)
43+
call s:assert.equal(getbufvar(l:bufinfo.name, 'LanguageClient_statusLineDiagnosticsCounts'), {'E': 0, 'W': 1, 'H': 0, 'I': 0})
44+
endfunction

0 commit comments

Comments
 (0)