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
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
ENV PACKAGES="\

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,9 +1,20 @@
Before:
Save g:ale_set_signs
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_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()
sign unplace *
@ -122,8 +133,7 @@ Given testft(A file with warnings/errors):
fifth line
Execute(The current signs should be set for running a job):
call ale#Lint()
call ale#engine#WaitForJobs(2000)
ALELint
AssertEqual
\ [

View File

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

View File

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

View File

@ -110,13 +110,9 @@ Given foobar (Some imaginary filetype):
baz
Execute(ALEToggle should reset everything and then run again):
" Run this test asynchrously.
let g:ale_run_synchronously = 0
AssertEqual 'foobar', &filetype
call ale#Lint()
call ale#engine#WaitForJobs(2000)
ALELint
" First check that everything is there...
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.
ALEToggle
call ale#engine#WaitForJobs(2000)
AssertEqual g:expected_loclist, getloclist(0)
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
Execute(ALEToggle should skip filename keys and preserve them):
" Run this test asynchrously.
let g:ale_run_synchronously = 0
AssertEqual 'foobar', &filetype
let g:ale_buffer_info['/foo/bar/baz.txt'] = {
@ -164,8 +156,7 @@ Execute(ALEToggle should skip filename keys and preserve them):
\ 'history': [],
\}
call ale#Lint()
call ale#engine#WaitForJobs(2000)
ALELint
" Now Toggle ALE off.
ALEToggle
@ -183,7 +174,6 @@ Execute(ALEToggle should skip filename keys and preserve them):
" Toggle ALE on again.
ALEToggle
call ale#engine#WaitForJobs(2000)
AssertEqual
\ {
@ -197,7 +187,7 @@ Execute(ALEToggle should skip filename keys and preserve them):
\ get(g:ale_buffer_info, '/foo/bar/baz.txt', {})
Execute(ALEDisable should reset everything and stay disabled):
call ale#Lint()
ALELint
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):
AssertEqual 'foobar', &filetype
call ale#Lint()
ALELint
" First check that everything is there...
AssertEqual g:expected_loclist, getloclist(0)
@ -244,13 +234,9 @@ Execute(ALEReset should reset everything for a buffer):
AssertEqual 1, g:ale_enabled
Execute(ALEToggleBuffer should reset everything and then run again):
" Run this test asynchrously.
let g:ale_run_synchronously = 0
AssertEqual 'foobar', &filetype
call ale#Lint()
call ale#engine#WaitForJobs(2000)
ALELint
" First check that everything is there...
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.
ALEToggleBuffer
call ale#engine#WaitForJobs(2000)
AssertEqual g:expected_loclist, getloclist(0)
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
Execute(ALEDisableBuffer should reset everything and stay disabled):
call ale#Lint()
ALELint
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):
AssertEqual 'foobar', &filetype
call ale#Lint()
ALELint
" First check that everything is there...
AssertEqual g:expected_loclist, getloclist(0)

View File

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

View File

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

View File

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

View File

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

View File

@ -1,31 +1,24 @@
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
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 = [
\ {
\ '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,
\ }
\]
" We want to check that sign IDs are set for this test.
let g:ale_set_signs = 1
let g:ale_set_loclist = 1
" Disable features we don't need for these tests.
let g:ale_set_quickfix = 0
let g:ale_set_highlights = 0
let g:ale_echo_cursor = 0
let g:ale_run_synchronously = 1
let g:ale_set_lists_synchronously = 1
let g:ale_buffer_info = {}
function! TestCallback(buffer, output)
return [
@ -54,22 +47,47 @@ Before:
sign unplace *
call ale#engine#Cleanup(bufnr(''))
After:
Restore
delfunction TestCallback
unlet! g:expected_data
let g:ale_buffer_info = {}
call ale#linter#Reset()
sign unplace *
Given foobar (Some JavaScript with problems):
var y = 3+3;
var y = 3
Execute(The loclist should be updated after linting is done):
call ale#Lint()
call ale#engine#WaitForJobs(2000)
ALELint
AssertEqual ['' . bufnr('%')], keys(g:ale_buffer_info)
AssertEqual g:expected_data, g:ale_buffer_info[bufnr('%')].loclist
AssertEqual
\ [
\ {
\ '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', [])