Get tests running and passing with NeoVim 0.2 and 0.3

This commit is contained in:
w0rp 2018-06-28 13:53:49 +01:00
parent 8b407ed0e7
commit d581fca35e
No known key found for this signature in database
GPG Key ID: 0FC1ECAA8C81CD83
16 changed files with 132 additions and 77 deletions

View File

@ -1,7 +1,7 @@
FROM tweekmonster/vim-testbed:latest FROM tweekmonster/vim-testbed:latest
RUN install_vim -tag v8.0.0027 -build \ RUN install_vim -tag v8.0.0027 -build \
-tag neovim:v0.2.1 -build \ -tag neovim:v0.2.0 -build \
-tag neovim:v0.3.0 -build -tag neovim:v0.3.0 -build
ENV PACKAGES="\ ENV PACKAGES="\

View File

@ -34,7 +34,11 @@ function! ale#balloon#Expr() abort
endfunction endfunction
function! ale#balloon#Disable() abort function! ale#balloon#Disable() abort
set noballooneval noballoonevalterm if has('balloon_eval_term')
set noballoonevalterm
endif
set noballooneval
set balloonexpr= set balloonexpr=
endfunction endfunction

View File

@ -12,14 +12,20 @@ set -u
# --neovim-only Run tests only for NeoVim # --neovim-only Run tests only for NeoVim
# --vim-only Run tests only for Vim # --vim-only Run tests only for Vim
current_image_id=d5a1b5915b09
image=w0rp/ale image=w0rp/ale
current_image_id=13b990377be9
current_digest=sha256:4b0f7c69e5a8cbb4e401aee039e5b468d6d9ad6cd01de62e918d98f0df1a5340
# Used in all test scripts for running the selected Docker image.
DOCKER_RUN_IMAGE="$image:$current_image_id"
export DOCKER_RUN_IMAGE
tests='test/*.vader test/*/*.vader test/*/*/*.vader test/*/*/*.vader' tests='test/*.vader test/*/*.vader test/*/*/*.vader test/*/*/*.vader'
# These flags are forwarded to the script for running Vader tests. # These flags are forwarded to the script for running Vader tests.
verbose_flag='' verbose_flag=''
quiet_flag='' quiet_flag=''
run_neovim_tests=1 run_neovim_02_tests=1
run_neovim_03_tests=1
run_vim_tests=1 run_vim_tests=1
run_vint=1 run_vint=1
run_custom_checks=1 run_custom_checks=1
@ -40,8 +46,23 @@ while [ $# -ne 0 ]; do
run_custom_checks=0 run_custom_checks=0
shift shift
;; ;;
--neovim-02-only)
run_neovim_03_tests=0
run_vim_tests=0
run_vint=0
run_custom_checks=0
shift
;;
--neovim-03-only)
run_neovim_02_tests=0
run_vim_tests=0
run_vint=0
run_custom_checks=0
shift
;;
--vim-only) --vim-only)
run_neovim_tests=0 run_neovim_02_tests=0
run_neovim_03_tests=0
run_vint=0 run_vint=0
run_custom_checks=0 run_custom_checks=0
shift shift
@ -52,7 +73,8 @@ while [ $# -ne 0 ]; do
;; ;;
--vint-only) --vint-only)
run_vim_tests=0 run_vim_tests=0
run_neovim_tests=0 run_neovim_02_tests=0
run_neovim_03_tests=0
run_custom_checks=0 run_custom_checks=0
shift shift
;; ;;
@ -62,7 +84,8 @@ while [ $# -ne 0 ]; do
;; ;;
--custom-checks-only) --custom-checks-only)
run_vim_tests=0 run_vim_tests=0
run_neovim_tests=0 run_neovim_02_tests=0
run_neovim_03_tests=0
run_vint=0 run_vint=0
shift shift
;; ;;
@ -90,8 +113,7 @@ fi
# Delete .swp files in the test directory, which cause Vim 8 to hang. # Delete .swp files in the test directory, which cause Vim 8 to hang.
find test -name '*.swp' -delete find test -name '*.swp' -delete
docker images -q w0rp/ale | grep "^$current_image_id" > /dev/null \ docker pull "$image"@"$current_digest"
|| docker pull "$image"
output_dir=$(mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir') output_dir=$(mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir')
@ -100,8 +122,10 @@ trap '{ rm -rf "$output_dir"; }' EXIT
file_number=0 file_number=0
pid_list='' pid_list=''
for vim in $(docker run --rm "$image" ls /vim-build/bin | grep '^neovim\|^vim' ); do for vim in $(docker run --rm "$DOCKER_RUN_IMAGE" ls /vim-build/bin | grep '^neovim\|^vim' ); do
if ((run_vim_tests)) || [[ $vim =~ ^neovim ]] && ((run_neovim_tests)); then if ( [[ $vim =~ ^vim ]] && ((run_vim_tests)) ) \
|| ( [[ $vim =~ ^neovim-v0.2 ]] && ((run_neovim_02_tests)) ) \
|| ( [[ $vim =~ ^neovim-v0.3 ]] && ((run_neovim_03_tests)) ); then
echo "Starting Vim: $vim..." echo "Starting Vim: $vim..."
file_number=$((file_number+1)) file_number=$((file_number+1))
test/script/run-vader-tests $quiet_flag $verbose_flag "$vim" "$tests" \ test/script/run-vader-tests $quiet_flag $verbose_flag "$vim" "$tests" \
@ -139,4 +163,10 @@ for pid in $pid_list; do
cat "$output_dir/$index" cat "$output_dir/$index"
done done
if ((failed)); then
echo 'Something went wrong!'
else
echo 'All tests passed!'
fi
exit $failed exit $failed

View File

@ -4,8 +4,7 @@ set -e
set -u set -u
exit_code=0 exit_code=0
image=w0rp/ale docker_flags=(--rm -v "$PWD:/testplugin" -v "$PWD/test:/home" -w /testplugin "$DOCKER_RUN_IMAGE")
docker_flags=(--rm -v "$PWD:/testplugin" -v "$PWD/test:/home" -w /testplugin "$image")
echo '========================================' echo '========================================'
echo 'Running custom linting rules' echo 'Running custom linting rules'

View File

@ -3,8 +3,7 @@
set -e set -e
set -u set -u
image=w0rp/ale docker_flags=(--rm -v "$PWD:/testplugin" -v "$PWD/test:/home" -w /testplugin "$DOCKER_RUN_IMAGE")
docker_flags=(--rm -v "$PWD:/testplugin" -v "$PWD/test:/home" -w /testplugin "$image")
red='\033[0;31m' red='\033[0;31m'
green='\033[0;32m' green='\033[0;32m'
nc='\033[0m' nc='\033[0m'

View File

@ -4,8 +4,7 @@ set -e
set -u set -u
exit_code=0 exit_code=0
image=w0rp/ale docker_flags=(--rm -v "$PWD:/testplugin" -v "$PWD/test:/home" -w /testplugin "$DOCKER_RUN_IMAGE")
docker_flags=(--rm -v "$PWD:/testplugin" -v "$PWD/test:/home" -w /testplugin "$image")
echo '========================================' echo '========================================'
echo 'Running Vint to lint our code' echo 'Running Vint to lint our code'

View File

@ -44,6 +44,7 @@ After:
sign unplace * sign unplace *
let g:ale_buffer_info = {} let g:ale_buffer_info = {}
call ale#engine#Cleanup(bufnr(''))
call ale#linter#Reset() call ale#linter#Reset()
Execute(The signs should be updated after linting is done): Execute(The signs should be updated after linting is done):

View File

@ -1,9 +1,20 @@
Before: Before:
Save g:ale_set_signs
Save g:ale_buffer_info Save g:ale_buffer_info
Save g:ale_echo_cursor
Save g:ale_run_synchronously
Save g:ale_set_highlights
Save g:ale_set_loclist
Save g:ale_set_quickfix
Save g:ale_set_signs
let g:ale_set_signs = 1
let g:ale_buffer_info = {} let g:ale_buffer_info = {}
let g:ale_run_synchronously = 1
let g:ale_set_signs = 1
" Disable features we don't need for these tests.
let g:ale_set_quickfix = 0
let g:ale_set_loclist = 0
let g:ale_set_highlights = 0
let g:ale_echo_cursor = 0
call ale#linter#Reset() call ale#linter#Reset()
sign unplace * sign unplace *
@ -122,8 +133,7 @@ Given testft(A file with warnings/errors):
fifth line fifth line
Execute(The current signs should be set for running a job): Execute(The current signs should be set for running a job):
call ale#Lint() ALELint
call ale#engine#WaitForJobs(2000)
AssertEqual AssertEqual
\ [ \ [

View File

@ -35,6 +35,7 @@ After:
delfunction TestCallback delfunction TestCallback
delfunction TestCallback2 delfunction TestCallback2
call ale#engine#Cleanup(bufnr(''))
call ale#linter#Reset() call ale#linter#Reset()
Given foobar (Some imaginary filetype): Given foobar (Some imaginary filetype):

View File

@ -39,9 +39,11 @@ After:
unlet! g:expected_loclist unlet! g:expected_loclist
let g:ale_buffer_info = {} call ale#engine#Cleanup(bufnr(''))
call ale#linter#Reset() call ale#linter#Reset()
let g:ale_buffer_info = {}
delfunction ToggleTestCallback delfunction ToggleTestCallback
Given foobar (Some imaginary filetype): Given foobar (Some imaginary filetype):

View File

@ -110,13 +110,9 @@ Given foobar (Some imaginary filetype):
baz baz
Execute(ALEToggle should reset everything and then run again): Execute(ALEToggle should reset everything and then run again):
" Run this test asynchrously.
let g:ale_run_synchronously = 0
AssertEqual 'foobar', &filetype AssertEqual 'foobar', &filetype
call ale#Lint() ALELint
call ale#engine#WaitForJobs(2000)
" First check that everything is there... " First check that everything is there...
AssertEqual g:expected_loclist, getloclist(0) AssertEqual g:expected_loclist, getloclist(0)
@ -139,7 +135,6 @@ Execute(ALEToggle should reset everything and then run again):
" Toggle ALE on, everything should be set up and run again. " Toggle ALE on, everything should be set up and run again.
ALEToggle ALEToggle
call ale#engine#WaitForJobs(2000)
AssertEqual g:expected_loclist, getloclist(0) AssertEqual g:expected_loclist, getloclist(0)
AssertEqual [0, [[2, 1000001, 'ALEErrorSign']]], ale#sign#FindCurrentSigns(bufnr('%')) AssertEqual [0, [[2, 1000001, 'ALEErrorSign']]], ale#sign#FindCurrentSigns(bufnr('%'))
@ -150,9 +145,6 @@ Execute(ALEToggle should reset everything and then run again):
AssertEqual [{'lnum': 2, 'bufnr': bufnr(''), 'col': 3, 'linter_name': 'testlinter', 'vcol': 0, 'nr': -1, 'type': 'E', 'text': 'foo bar', 'sign_id': 1000001}], g:ale_buffer_info[bufnr('')].loclist AssertEqual [{'lnum': 2, 'bufnr': bufnr(''), 'col': 3, 'linter_name': 'testlinter', 'vcol': 0, 'nr': -1, 'type': 'E', 'text': 'foo bar', 'sign_id': 1000001}], g:ale_buffer_info[bufnr('')].loclist
Execute(ALEToggle should skip filename keys and preserve them): Execute(ALEToggle should skip filename keys and preserve them):
" Run this test asynchrously.
let g:ale_run_synchronously = 0
AssertEqual 'foobar', &filetype AssertEqual 'foobar', &filetype
let g:ale_buffer_info['/foo/bar/baz.txt'] = { let g:ale_buffer_info['/foo/bar/baz.txt'] = {
@ -164,8 +156,7 @@ Execute(ALEToggle should skip filename keys and preserve them):
\ 'history': [], \ 'history': [],
\} \}
call ale#Lint() ALELint
call ale#engine#WaitForJobs(2000)
" Now Toggle ALE off. " Now Toggle ALE off.
ALEToggle ALEToggle
@ -183,7 +174,6 @@ Execute(ALEToggle should skip filename keys and preserve them):
" Toggle ALE on again. " Toggle ALE on again.
ALEToggle ALEToggle
call ale#engine#WaitForJobs(2000)
AssertEqual AssertEqual
\ { \ {
@ -197,7 +187,7 @@ Execute(ALEToggle should skip filename keys and preserve them):
\ get(g:ale_buffer_info, '/foo/bar/baz.txt', {}) \ get(g:ale_buffer_info, '/foo/bar/baz.txt', {})
Execute(ALEDisable should reset everything and stay disabled): Execute(ALEDisable should reset everything and stay disabled):
call ale#Lint() ALELint
AssertEqual g:expected_loclist, getloclist(0) AssertEqual g:expected_loclist, getloclist(0)
@ -222,7 +212,7 @@ Execute(ALEEnable should enable ALE and lint again):
Execute(ALEReset should reset everything for a buffer): Execute(ALEReset should reset everything for a buffer):
AssertEqual 'foobar', &filetype AssertEqual 'foobar', &filetype
call ale#Lint() ALELint
" First check that everything is there... " First check that everything is there...
AssertEqual g:expected_loclist, getloclist(0) AssertEqual g:expected_loclist, getloclist(0)
@ -244,13 +234,9 @@ Execute(ALEReset should reset everything for a buffer):
AssertEqual 1, g:ale_enabled AssertEqual 1, g:ale_enabled
Execute(ALEToggleBuffer should reset everything and then run again): Execute(ALEToggleBuffer should reset everything and then run again):
" Run this test asynchrously.
let g:ale_run_synchronously = 0
AssertEqual 'foobar', &filetype AssertEqual 'foobar', &filetype
call ale#Lint() ALELint
call ale#engine#WaitForJobs(2000)
" First check that everything is there... " First check that everything is there...
AssertEqual g:expected_loclist, getloclist(0) AssertEqual g:expected_loclist, getloclist(0)
@ -271,7 +257,6 @@ Execute(ALEToggleBuffer should reset everything and then run again):
" Toggle ALE on, everything should be set up and run again. " Toggle ALE on, everything should be set up and run again.
ALEToggleBuffer ALEToggleBuffer
call ale#engine#WaitForJobs(2000)
AssertEqual g:expected_loclist, getloclist(0) AssertEqual g:expected_loclist, getloclist(0)
AssertEqual [0, [[2, 1000001, 'ALEErrorSign']]], ale#sign#FindCurrentSigns(bufnr('%')) AssertEqual [0, [[2, 1000001, 'ALEErrorSign']]], ale#sign#FindCurrentSigns(bufnr('%'))
@ -282,7 +267,7 @@ Execute(ALEToggleBuffer should reset everything and then run again):
AssertEqual [{'lnum': 2, 'bufnr': bufnr(''), 'col': 3, 'linter_name': 'testlinter', 'vcol': 0, 'nr': -1, 'type': 'E', 'text': 'foo bar', 'sign_id': 1000001}], g:ale_buffer_info[bufnr('')].loclist AssertEqual [{'lnum': 2, 'bufnr': bufnr(''), 'col': 3, 'linter_name': 'testlinter', 'vcol': 0, 'nr': -1, 'type': 'E', 'text': 'foo bar', 'sign_id': 1000001}], g:ale_buffer_info[bufnr('')].loclist
Execute(ALEDisableBuffer should reset everything and stay disabled): Execute(ALEDisableBuffer should reset everything and stay disabled):
call ale#Lint() ALELint
AssertEqual g:expected_loclist, getloclist(0) AssertEqual g:expected_loclist, getloclist(0)
@ -317,7 +302,7 @@ Execute(ALEEnableBuffer should complain when ALE is disabled globally):
Execute(ALEResetBuffer should reset everything for a buffer): Execute(ALEResetBuffer should reset everything for a buffer):
AssertEqual 'foobar', &filetype AssertEqual 'foobar', &filetype
call ale#Lint() ALELint
" First check that everything is there... " First check that everything is there...
AssertEqual g:expected_loclist, getloclist(0) AssertEqual g:expected_loclist, getloclist(0)

View File

@ -17,6 +17,8 @@ Before:
After: After:
unlet! g:output unlet! g:output
delfunction TestCallback delfunction TestCallback
call ale#engine#Cleanup(bufnr(''))
call ale#linter#Reset() call ale#linter#Reset()
Given foobar (Some imaginary filetype): Given foobar (Some imaginary filetype):

View File

@ -52,9 +52,12 @@ After:
let g:ale_history_enabled = 1 let g:ale_history_enabled = 1
let g:ale_history_log_output = 0 let g:ale_history_log_output = 0
unlet g:history unlet g:history
call ale#engine#Cleanup(bufnr(''))
call ale#linter#Reset()
let g:ale_buffer_info = {} let g:ale_buffer_info = {}
let g:ale_max_buffer_history_size = 20 let g:ale_max_buffer_history_size = 20
call ale#linter#Reset()
delfunction TestFixer delfunction TestFixer
delfunction CollectResults delfunction CollectResults

View File

@ -85,7 +85,7 @@ Before:
After: After:
if !g:ale_run_synchronously if !g:ale_run_synchronously
call ale#engine#WaitForJobs(2000) call ale#engine#Cleanup(bufnr(''))
endif endif
Restore Restore

View File

@ -2,6 +2,8 @@ Before:
let g:ale_buffer_info = {} let g:ale_buffer_info = {}
After: After:
call ale#engine#Cleanup(bufnr(''))
let g:ale_buffer_info = {} let g:ale_buffer_info = {}
Given unite (A Unite.vim file): Given unite (A Unite.vim file):

View File

@ -1,31 +1,24 @@
Before: Before:
Save g:ale_echo_cursor
Save g:ale_set_highlights
Save g:ale_set_loclist
Save g:ale_set_quickfix
Save g:ale_set_signs Save g:ale_set_signs
let g:ale_set_signs = 1 Save g:ale_run_synchronously
Save g:ale_set_lists_synchronously
Save g:ale_buffer_info
let g:expected_data = [ " We want to check that sign IDs are set for this test.
\ { let g:ale_set_signs = 1
\ 'lnum': 1, let g:ale_set_loclist = 1
\ 'bufnr': bufnr('%'), " Disable features we don't need for these tests.
\ 'vcol': 0, let g:ale_set_quickfix = 0
\ 'linter_name': 'testlinter', let g:ale_set_highlights = 0
\ 'nr': -1, let g:ale_echo_cursor = 0
\ 'type': 'W',
\ 'col': 10, let g:ale_run_synchronously = 1
\ 'text': 'Infix operators must be spaced. [Warning/space-infix-ops]', let g:ale_set_lists_synchronously = 1
\ 'sign_id': 1000001, let g:ale_buffer_info = {}
\ },
\ {
\ 'lnum': 2,
\ 'bufnr': bufnr('%'),
\ 'vcol': 0,
\ 'linter_name': 'testlinter',
\ 'nr': -1,
\ 'type': 'E',
\ 'col': 10,
\ 'text': 'Missing semicolon. [Error/semi]',
\ 'sign_id': 1000002,
\ }
\]
function! TestCallback(buffer, output) function! TestCallback(buffer, output)
return [ return [
@ -54,22 +47,47 @@ Before:
sign unplace * sign unplace *
call ale#engine#Cleanup(bufnr(''))
After: After:
Restore Restore
delfunction TestCallback delfunction TestCallback
unlet! g:expected_data
let g:ale_buffer_info = {}
call ale#linter#Reset() call ale#linter#Reset()
sign unplace *
Given foobar (Some JavaScript with problems): Given foobar (Some JavaScript with problems):
var y = 3+3; var y = 3+3;
var y = 3 var y = 3
Execute(The loclist should be updated after linting is done): Execute(The loclist should be updated after linting is done):
call ale#Lint() ALELint
call ale#engine#WaitForJobs(2000)
AssertEqual ['' . bufnr('%')], keys(g:ale_buffer_info) AssertEqual
AssertEqual g:expected_data, g:ale_buffer_info[bufnr('%')].loclist \ [
\ {
\ 'lnum': 1,
\ 'bufnr': bufnr('%'),
\ 'vcol': 0,
\ 'linter_name': 'testlinter',
\ 'nr': -1,
\ 'type': 'W',
\ 'col': 10,
\ 'text': 'Infix operators must be spaced. [Warning/space-infix-ops]',
\ 'sign_id': 1000001,
\ },
\ {
\ 'lnum': 2,
\ 'bufnr': bufnr('%'),
\ 'vcol': 0,
\ 'linter_name': 'testlinter',
\ 'nr': -1,
\ 'type': 'E',
\ 'col': 10,
\ 'text': 'Missing semicolon. [Error/semi]',
\ 'sign_id': 1000002,
\ }
\ ],
\ get(get(g:ale_buffer_info, bufnr('%'), {}), 'loclist', [])