Files
vim-lsp-mirror/test/utils/autoload/lsp/test.vim
Linda_pp 8a39ef5904 Add integration tests with gopls instead of rust-analyzer (#1108)
* Revert "remove flaky integration tests (#1098)"

This reverts commit 78c107085a.

* use gopls for integration tests instead of rust-analyzer

* specific Go and gopls versions via envvar on CI

* remove unused test helper for Rust test project

based on https://github.com/prabirshrestha/vim-lsp/pull/1108#discussion_r595689580

* include multibyte text in integration test case

based on https://github.com/prabirshrestha/vim-lsp/pull/1108#discussion_r595690354

* cache gopls binary on running CI workflows

* update doc to run integ tests
2021-03-20 10:54:17 -07:00

51 lines
1.3 KiB
VimL

function! lsp#test#projectdir(name) abort
if a:name ==# 'rust'
return expand('%:p:h') .'/test/testproject-rust'
elseif a:name ==# 'go'
return expand('%:p:h') .'/test/testproject-go'
else
throw 'projectdir not supported for ' . a:name
endif
endfunction
function! lsp#test#openproject(name, options) abort
if a:name ==# 'go'
filetype on
call lsp#register_server({
\ 'name': 'gopls',
\ 'cmd': ['gopls'],
\ 'allowlist': ['go'],
\ })
call lsp#enable()
" open .go file to trigger gopls then close it
execute printf('keepalt keepjumps edit %s', lsp#test#projectdir(a:name) . '/documentformat.go')
" wait for server starting
call lsp#test#wait(10000, {-> lsp#get_server_status('gopls') ==# 'running' })
%bwipeout!
else
throw 'open project not not supported for ' . a:name
endif
endfunction
function! lsp#test#closeproject(name) abort
if lsp#test#hasproject(a:name)
silent! call lsp#stop_sserver(a:name)
endif
endfunction
function! lsp#test#hasproject(name) abort
if a:name ==# 'go' && executable('gopls')
return 1
else
return 0
endif
endfunction
function! lsp#test#wait(timeout, condition) abort
call lsp#utils#_wait(a:timeout, a:condition)
endfunction