This repository has been archived on 2024-07-19. You can view files and clone it, but cannot push or open issues or pull requests.
ale/test/smoke_test.vader
Horacio Sanson bafe1c0fd6
3560 add vim 8.2 and nvim 0.4 to ci tests (#3561)
* Add vim82 and neovim04 to CI tests.

* Fix test_sign_column_hightlighting test.

In vim82 with verbose=1 the output of highlight command changes breaking
the ale#sign#SetUpDefaultColumnWithoutErrorsHighlight(). This commit
forces verbose=0 when the method starts and restores the previous value
before exiting.

* No return values in vim82 returns a numeric value instead of a empty string.

* Fix test_reek_handler test

The FuzzyJSONDecode() method catches E474 when it fails to parse the
input as JSON but Vim8.2 throws E491 instead. This commit modifies the
function to catch both E474 or E491.

* Fix perl6 handler test.

Perl6 handler catches json parse errors using the E474 error but in
Vim82 it changed to E491. This commit modifies the handler so both
errors are considered.

* Fix list opening tests.

In Vim 8.2 the call `range(1, bufnr('$'))` always returns quickfix
buffers no matter if they are closed or not. Using `ls` does not show
them but the above range will always include them.

This new behavior breaks the ale#list#IsQuickfixOpen() method that in
turn breaks many other things. This commit fixes this by using the
getqflist() and getloclist() methods instead.

* Fix test updates loclist test.

For some reason in Vim 8.2 the sign offset seems to not reset between
tests causing the sign_id to not match in the Assert. When the test is
run individually it passes but when run as part of the whole suite the
sign_id is off by one.

Forcing the offset in the test setup seems to fix the issue.

* Fix omnifunc completion test.

For unknown reasons the SetCompletionResponse tests fail in Neovim 0.2
and 0.4. Unfortunatelly the only solution I found is to disable them
for neovim.

* Fix linter warnings

* Fix smoker test.

Add vim 8.2 to the list of versions that need some retires due to
randomly failing tests.

* Add docker image build job.

Trying some clever trick to build the docker image if not available
locally or in Docker hub. It uses the Dockerfile md5 checksum as tag so
only when changes on that file occur will the image be downloaded or
build.

* Add labels to Docker image

* Remove tests for middle versions 8.1 and 0.3.5

* Use same vader commit as appveyor

* Implement image push to Docker Hub

Co-authored-by: Horacio Sanson <horacio@allm.inc>
2021-01-27 19:52:24 +00:00

181 lines
4.1 KiB
Text

Before:
Save g:ale_enabled
Save g:ale_set_lists_synchronously
Save g:ale_buffer_info
Save &shell
let g:ale_enabled = 1
let g:ale_buffer_info = {}
let g:ale_set_lists_synchronously = 1
function! TestCallback(buffer, output)
" Windows adds extra spaces to the text from echo.
return [{
\ 'lnum': 2,
\ 'col': 3,
\ 'text': substitute(a:output[0], ' *$', '', ''),
\}]
endfunction
function! TestCallback2(buffer, output)
return [{
\ 'lnum': 3,
\ 'col': 4,
\ 'text': substitute(a:output[0], ' *$', '', ''),
\}]
endfunction
" Running the command in another subshell seems to help here.
call ale#linter#Define('foobar', {
\ 'name': 'testlinter',
\ 'callback': 'TestCallback',
\ 'executable': has('win32') ? 'cmd' : 'echo',
\ 'command': has('win32') ? 'echo foo bar' : '/bin/sh -c ''echo foo bar''',
\})
After:
Restore
unlet! g:i
unlet! g:results
unlet! g:expected_results
delfunction TestCallback
delfunction TestCallback2
call ale#engine#Cleanup(bufnr(''))
call ale#linter#Reset()
Given foobar (Some imaginary filetype):
foo
bar
baz
Execute(Linters should run with the default options):
AssertEqual 'foobar', &filetype
let g:expected_results = [{
\ 'bufnr': bufnr('%'),
\ 'lnum': 2,
\ 'vcol': 0,
\ 'col': 3,
\ 'text': 'foo bar',
\ 'type': 'E',
\ 'nr': -1,
\ 'pattern': '',
\ 'valid': 1,
\ }]
" Try the test a few times over in NeoVim 0.3 or Windows or Vim 8.2,
" where tests fail randomly.
for g:i in range(has('nvim-0.3') || has('win32') || has('patch-8.2.2401') ? 5 : 1)
call ale#Queue(0, '')
call ale#test#WaitForJobs(2000)
let g:results = ale#test#GetLoclistWithoutModule()
if g:results == g:expected_results
break
endif
endfor
AssertEqual g:expected_results, g:results
Execute(Linters should run in PowerShell too):
if has('win32')
set shell=powershell
AssertEqual 'foobar', &filetype
" Replace the callback to handle two lines.
function! TestCallback(buffer, output)
" Windows adds extra spaces to the text from echo.
return [
\ {
\ 'lnum': 1,
\ 'col': 3,
\ 'text': substitute(a:output[0], ' *$', '', ''),
\ },
\ {
\ 'lnum': 2,
\ 'col': 3,
\ 'text': substitute(a:output[1], ' *$', '', ''),
\ },
\]
endfunction
" Recreate the command string to use &&, which PowerShell does not support.
call ale#linter#Reset()
call ale#linter#Define('foobar', {
\ 'name': 'testlinter',
\ 'callback': 'TestCallback',
\ 'executable': 'cmd',
\ 'command': 'echo foo && echo bar',
\})
call ale#Queue(0, '')
call ale#test#WaitForJobs(4000)
AssertEqual [
\ {
\ 'bufnr': bufnr('%'),
\ 'lnum': 1,
\ 'vcol': 0,
\ 'col': 3,
\ 'text': 'foo',
\ 'type': 'E',
\ 'nr': -1,
\ 'pattern': '',
\ 'valid': 1,
\ },
\ {
\ 'bufnr': bufnr('%'),
\ 'lnum': 2,
\ 'vcol': 0,
\ 'col': 3,
\ 'text': 'bar',
\ 'type': 'E',
\ 'nr': -1,
\ 'pattern': '',
\ 'valid': 1,
\ },
\], ale#test#GetLoclistWithoutModule()
endif
Execute(Previous errors should be removed when linters change):
call ale#Queue(0, '')
call ale#test#WaitForJobs(2000)
call ale#linter#Reset()
call ale#linter#Define('foobar', {
\ 'name': 'testlinter2',
\ 'callback': 'TestCallback2',
\ 'executable': has('win32') ? 'cmd' : 'echo',
\ 'command': has('win32') ? 'echo baz boz' : '/bin/sh -c ''echo baz boz''',
\})
let g:expected_results = [{
\ 'bufnr': bufnr('%'),
\ 'lnum': 3,
\ 'vcol': 0,
\ 'col': 4,
\ 'text': 'baz boz',
\ 'type': 'E',
\ 'nr': -1,
\ 'pattern': '',
\ 'valid': 1,
\}]
" Try the test a few times over in NeoVim 0.3 or VIm 8.2 or Windows,
" where tests fail randomly.
for g:i in range(has('nvim-0.3') || has('win32') || has('patch-8.2.2401') ? 5 : 1)
call ale#Queue(0, '')
call ale#test#WaitForJobs(2000)
let g:results = ale#test#GetLoclistWithoutModule()
if g:results == g:expected_results
break
endif
endfor
AssertEqual g:expected_results, g:results