mirror of
https://github.com/mattn/vim-lsp-settings.git
synced 2025-12-12 20:35:54 +01:00
Add tests
This commit is contained in:
46
.github/workflows/linux_vim.yml
vendored
Normal file
46
.github/workflows/linux_vim.yml
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
name: linux_vim
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest]
|
||||
name: [vim-v82-x64, vim-v81-x64]
|
||||
include:
|
||||
- name: vim-v82-x64
|
||||
os: ubuntu-latest
|
||||
vim_version: 8.2.0037
|
||||
glibc_version: 2.15
|
||||
- name: vim-v81-x64
|
||||
os: ubuntu-latest
|
||||
vim_version: 8.1.2414
|
||||
glibc_version: 2.15
|
||||
runs-on: ${{matrix.os}}
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Download vim
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p ~/vim/bin
|
||||
curl -L https://github.com/vim/vim-appimage/releases/download/v${{matrix.vim_version}}/GVim-v${{matrix.vim_version}}.glibc${{matrix.glibc_version}}-x86_64.AppImage -o ~/vim/bin/vim
|
||||
chmod u+x ~/vim/bin/vim
|
||||
- name: Download test runner
|
||||
shell: bash
|
||||
run: git clone --depth 1 --branch v1.5.4 --single-branch https://github.com/thinca/vim-themis ~/themis
|
||||
- name: Run tests
|
||||
shell: bash
|
||||
run: |
|
||||
export PATH=~/vim/bin:$PATH
|
||||
export PATH=~/themis/bin:$PATH
|
||||
export THEMIS_VIM=vim
|
||||
vim --version
|
||||
themis --reporter spec
|
||||
@@ -6,6 +6,7 @@ function! lsp_settings#utils#msg(msg) abort
|
||||
endfunction
|
||||
|
||||
function! lsp_settings#utils#error(msg) abort
|
||||
redraw
|
||||
echohl Error
|
||||
echomsg a:msg
|
||||
echohl None
|
||||
@@ -19,9 +20,9 @@ function! lsp_settings#utils#group_name(ft) abort
|
||||
return printf('vim_lsp_suggest_%s', a:ft)
|
||||
endfunction
|
||||
|
||||
function! lsp_settings#utils#first_one(cmd) abort
|
||||
if empty(a:cmd)
|
||||
function! lsp_settings#utils#first_one(lines) abort
|
||||
if empty(a:lines)
|
||||
return ''
|
||||
endif
|
||||
return fnamemodify(split(a:cmd, "\n")[0], ':p')
|
||||
return fnamemodify(split(a:lines, "\n")[0], ':p')
|
||||
endfunction
|
||||
|
||||
3
test/.themisrc
Normal file
3
test/.themisrc
Normal file
@@ -0,0 +1,3 @@
|
||||
set encoding=utf-8
|
||||
call themis#option('recursive', 1)
|
||||
call themis#helper('command').with(themis#helper('assert'))
|
||||
43
test/lsp_settings/utils.vimspec
Normal file
43
test/lsp_settings/utils.vimspec
Normal file
@@ -0,0 +1,43 @@
|
||||
Describe lsp_settings#utils
|
||||
Describe lsp_settings#utils#first_one
|
||||
It should return first item in lines
|
||||
Assert Equals(lsp_settings#utils#first_one("\nfoo"), fnamemodify('foo', ':p'))
|
||||
Assert Equals(lsp_settings#utils#first_one('foo'), fnamemodify('foo', ':p'))
|
||||
Assert Equals(lsp_settings#utils#first_one("foo\nbar\n"), fnamemodify('foo', ':p'))
|
||||
End
|
||||
End
|
||||
|
||||
Describe lsp_settings#utils#group_name
|
||||
It should return autocmd group name
|
||||
Assert Equals(lsp_settings#utils#group_name('foo'), 'vim_lsp_suggest_foo')
|
||||
End
|
||||
End
|
||||
|
||||
Describe lsp_settings#utils#valid_name
|
||||
It should return whether the command is valid
|
||||
Assert Equals(lsp_settings#utils#valid_name('foo'), 1)
|
||||
Assert Equals(lsp_settings#utils#valid_name('foo bar'), 0)
|
||||
Assert Equals(lsp_settings#utils#valid_name(' foo'), 0)
|
||||
Assert Equals(lsp_settings#utils#valid_name(' foo '), 0)
|
||||
Assert Equals(lsp_settings#utils#valid_name('foo '), 0)
|
||||
Assert Equals(lsp_settings#utils#valid_name('foo-bar'), 1)
|
||||
Assert Equals(lsp_settings#utils#valid_name('foo_bar'), 1)
|
||||
Assert Equals(lsp_settings#utils#valid_name('foo&bar'), 0)
|
||||
Assert Equals(lsp_settings#utils#valid_name('foo#bar'), 0)
|
||||
End
|
||||
End
|
||||
|
||||
Describe lsp_settings#utils#msg
|
||||
It should display information
|
||||
Assert Equals(execute("call lsp_settings#utils#msg('foo')"), "\nfoo")
|
||||
Assert Equals(execute("call lsp_settings#utils#msg('foo')"), "\nfoo")
|
||||
End
|
||||
End
|
||||
|
||||
Describe lsp_settings#utils#error
|
||||
It should display information
|
||||
Assert Equals(execute("call lsp_settings#utils#error('foo')"), "\nfoo")
|
||||
Assert Equals(execute("call lsp_settings#utils#error('foo')"), "\nfoo")
|
||||
End
|
||||
End
|
||||
End
|
||||
Reference in New Issue
Block a user