Skip to content

Commit

Permalink
Add end-to-end integration test with Vim (#1874)
Browse files Browse the repository at this point in the history
  • Loading branch information
andyleejordan authored Aug 8, 2022
1 parent c31a39f commit f3c504c
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/emacs-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:

jobs:
test:
name: Test PSES with Emacs via Eglot
name: Test via Eglot
runs-on: ubuntu-latest
steps:
- name: Checkout repository
Expand Down
53 changes: 53 additions & 0 deletions .github/workflows/vim-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: "Vim"

on:
push:
branches: [ main ]
tags: [ v* ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
paths-ignore: [ '**/*.md' ]

jobs:
test:
name: Test via LanguageClient-neovim
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Build PSES
shell: pwsh
run: tools/azurePipelinesBuild.ps1

- name: Install Vim
uses: rhysd/action-setup-vim@v1
id: vim

- name: Checkout vim-ps1
uses: actions/checkout@v3
with:
repository: PProvost/vim-ps1
path: vim-ps1

- name: Checkout LanguageClient-neovim
uses: actions/checkout@v3
with:
repository: autozimu/LanguageClient-neovim
path: LanguageClient-neovim

- name: Install LanguageClient-neovim
run: ./install.sh
working-directory: LanguageClient-neovim

- name: Checkout Themis
uses: actions/checkout@v3
with:
repository: thinca/vim-themis
path: vim-themis

- name: Run Themis
env:
THEMIS_VIM: ${{ steps.vim.outputs.executable }}
run: ./vim-themis/bin/themis ./test/vim-test.vim
6 changes: 6 additions & 0 deletions test/.themisrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
filetype plugin on

let g:repo_root = fnamemodify(expand('<sfile>'), ':h:h')

call themis#option('runtimepath', g:repo_root . '/LanguageClient-neovim')
call themis#option('runtimepath', g:repo_root . '/vim-ps1')
1 change: 1 addition & 0 deletions test/vim-test.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
function Do-Work {}
44 changes: 44 additions & 0 deletions test/vim-test.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
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',
\ '-HostName', 'vim', '-HostProfileId', 'vim', '-HostVersion', '1.0.0',
\ '-BundledModulesPath', l:pses_path, '-Stdio',
\ '-LogPath', g:repo_root . '/pses.log', '-LogLevel', 'Diagnostic',
\ '-SessionDetailsPath', g:repo_root . '/pses_session.json' ]
\ }
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

0 comments on commit f3c504c

Please sign in to comment.