summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2018-06-28 13:53:49 +0100
committerw0rp <devw0rp@gmail.com>2018-06-28 13:53:49 +0100
commitd581fca35e2a09afc68dd43baa290c695f8a66a7 (patch)
treecf7be787ea8b1afacf9cd70482aa16f3a26b108a /test
parent8b407ed0e7f3913e1ef582042321067ebd72c127 (diff)
downloadale-d581fca35e2a09afc68dd43baa290c695f8a66a7.zip
Get tests running and passing with NeoVim 0.2 and 0.3
Diffstat (limited to 'test')
-rwxr-xr-xtest/script/custom-checks3
-rwxr-xr-xtest/script/run-vader-tests3
-rwxr-xr-xtest/script/run-vint3
-rw-r--r--test/sign/test_linting_sets_signs.vader1
-rw-r--r--test/sign/test_sign_placement.vader18
-rw-r--r--test/smoke_test.vader1
-rw-r--r--test/test_ale_lint_command.vader4
-rw-r--r--test/test_ale_toggle.vader29
-rw-r--r--test/test_format_temporary_file_creation.vader2
-rw-r--r--test/test_history_saving.vader5
-rw-r--r--test/test_lint_file_linters.vader2
-rw-r--r--test/test_linting_blacklist.vader2
-rw-r--r--test/test_linting_updates_loclist.vader78
13 files changed, 86 insertions, 65 deletions
diff --git a/test/script/custom-checks b/test/script/custom-checks
index 76b9bc86..d4027fec 100755
--- a/test/script/custom-checks
+++ b/test/script/custom-checks
@@ -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'
diff --git a/test/script/run-vader-tests b/test/script/run-vader-tests
index 3e7e815c..e952faf0 100755
--- a/test/script/run-vader-tests
+++ b/test/script/run-vader-tests
@@ -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'
diff --git a/test/script/run-vint b/test/script/run-vint
index 0d5b6e11..ce42ad41 100755
--- a/test/script/run-vint
+++ b/test/script/run-vint
@@ -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'
diff --git a/test/sign/test_linting_sets_signs.vader b/test/sign/test_linting_sets_signs.vader
index c23b4002..2f9be7b2 100644
--- a/test/sign/test_linting_sets_signs.vader
+++ b/test/sign/test_linting_sets_signs.vader
@@ -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):
diff --git a/test/sign/test_sign_placement.vader b/test/sign/test_sign_placement.vader
index 19267fe7..e2d95ff0 100644
--- a/test/sign/test_sign_placement.vader
+++ b/test/sign/test_sign_placement.vader
@@ -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
\ [
diff --git a/test/smoke_test.vader b/test/smoke_test.vader
index 843bddab..7f9dfd03 100644
--- a/test/smoke_test.vader
+++ b/test/smoke_test.vader
@@ -35,6 +35,7 @@ After:
delfunction TestCallback
delfunction TestCallback2
+ call ale#engine#Cleanup(bufnr(''))
call ale#linter#Reset()
Given foobar (Some imaginary filetype):
diff --git a/test/test_ale_lint_command.vader b/test/test_ale_lint_command.vader
index 7b4f7613..15f1f054 100644
--- a/test/test_ale_lint_command.vader
+++ b/test/test_ale_lint_command.vader
@@ -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):
diff --git a/test/test_ale_toggle.vader b/test/test_ale_toggle.vader
index cac762b4..3b3c509c 100644
--- a/test/test_ale_toggle.vader
+++ b/test/test_ale_toggle.vader
@@ -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)
diff --git a/test/test_format_temporary_file_creation.vader b/test/test_format_temporary_file_creation.vader
index 1afaba30..fc43e2a1 100644
--- a/test/test_format_temporary_file_creation.vader
+++ b/test/test_format_temporary_file_creation.vader
@@ -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):
diff --git a/test/test_history_saving.vader b/test/test_history_saving.vader
index 7dabcd9d..8764b74c 100644
--- a/test/test_history_saving.vader
+++ b/test/test_history_saving.vader
@@ -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
diff --git a/test/test_lint_file_linters.vader b/test/test_lint_file_linters.vader
index 2e992e13..14339e21 100644
--- a/test/test_lint_file_linters.vader
+++ b/test/test_lint_file_linters.vader
@@ -85,7 +85,7 @@ Before:
After:
if !g:ale_run_synchronously
- call ale#engine#WaitForJobs(2000)
+ call ale#engine#Cleanup(bufnr(''))
endif
Restore
diff --git a/test/test_linting_blacklist.vader b/test/test_linting_blacklist.vader
index 9960264d..2d9ed585 100644
--- a/test/test_linting_blacklist.vader
+++ b/test/test_linting_blacklist.vader
@@ -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):
diff --git a/test/test_linting_updates_loclist.vader b/test/test_linting_updates_loclist.vader
index 29ca05d4..921cdb08 100644
--- a/test/test_linting_updates_loclist.vader
+++ b/test/test_linting_updates_loclist.vader
@@ -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
+ Save g:ale_run_synchronously
+ Save g:ale_set_lists_synchronously
+ Save g:ale_buffer_info
+
+ " 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: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,
- \ }
- \]
+ 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', [])