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
16 changed files with 132 additions and 77 deletions

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', [])