Run all tests in NeoVim, improve the test script, and make all tests pass for NeoVim

This commit is contained in:
w0rp
2017-05-12 20:38:52 +01:00
parent 07b2542c0d
commit 2bafdb7e5a
10 changed files with 287 additions and 94 deletions

1
test/.config/nvim/init.vim Symbolic link
View File

@@ -0,0 +1 @@
../../vimrc

View File

@@ -18,47 +18,92 @@ Execute(GetNextMessageID() should increment appropriately):
AssertEqual 1, ale#lsp#GetNextMessageID()
Execute(ale#lsp#CreateMessageData() should create an appropriate message):
" 71 is the size in bytes for UTF-8, not the number of characters.
AssertEqual
\ [
\ 1,
\ "Content-Length: 71\r\n\r\n"
\ . '{"id":1,"jsonrpc":"2.0","method":"someMethod","params":{"foo":"barÜ"}}',
\ ],
\ ale#lsp#CreateMessageData([0, 'someMethod', {'foo': 'barÜ'}])
" Check again to ensure that we use the next ID.
AssertEqual
\ [
\ 2,
\ "Content-Length: 71\r\n\r\n"
\ . '{"id":2,"jsonrpc":"2.0","method":"someMethod","params":{"foo":"barÜ"}}',
\ ],
\ ale#lsp#CreateMessageData([0, 'someMethod', {'foo': 'barÜ'}])
" NeoVim outputs JSON with spaces, so the output is a little different.
if has('nvim')
" 79 is the size in bytes for UTF-8, not the number of characters.
AssertEqual
\ [
\ 1,
\ "Content-Length: 79\r\n\r\n"
\ . '{"id": 1, "jsonrpc": "2.0", "method": "someMethod", "params": {"foo": "barÜ"}}',
\ ],
\ ale#lsp#CreateMessageData([0, 'someMethod', {'foo': 'barÜ'}])
" Check again to ensure that we use the next ID.
AssertEqual
\ [
\ 2,
\ "Content-Length: 79\r\n\r\n"
\ . '{"id": 2, "jsonrpc": "2.0", "method": "someMethod", "params": {"foo": "barÜ"}}',
\ ],
\ ale#lsp#CreateMessageData([0, 'someMethod', {'foo': 'barÜ'}])
else
AssertEqual
\ [
\ 1,
\ "Content-Length: 71\r\n\r\n"
\ . '{"id":1,"jsonrpc":"2.0","method":"someMethod","params":{"foo":"barÜ"}}',
\ ],
\ ale#lsp#CreateMessageData([0, 'someMethod', {'foo': 'barÜ'}])
AssertEqual
\ [
\ 2,
\ "Content-Length: 71\r\n\r\n"
\ . '{"id":2,"jsonrpc":"2.0","method":"someMethod","params":{"foo":"barÜ"}}',
\ ],
\ ale#lsp#CreateMessageData([0, 'someMethod', {'foo': 'barÜ'}])
endif
Execute(ale#lsp#CreateMessageData() should create messages without params):
AssertEqual
\ [
\ 1,
\ "Content-Length: 51\r\n\r\n"
\ . '{"id":1,"jsonrpc":"2.0","method":"someOtherMethod"}',
\ ],
\ ale#lsp#CreateMessageData([0, 'someOtherMethod'])
if has('nvim')
AssertEqual
\ [
\ 1,
\ "Content-Length: 56\r\n\r\n"
\ . '{"id": 1, "jsonrpc": "2.0", "method": "someOtherMethod"}',
\ ],
\ ale#lsp#CreateMessageData([0, 'someOtherMethod'])
else
AssertEqual
\ [
\ 1,
\ "Content-Length: 51\r\n\r\n"
\ . '{"id":1,"jsonrpc":"2.0","method":"someOtherMethod"}',
\ ],
\ ale#lsp#CreateMessageData([0, 'someOtherMethod'])
endif
Execute(ale#lsp#CreateMessageData() should create notifications):
AssertEqual
\ [
\ 0,
\ "Content-Length: 55\r\n\r\n"
\ . '{"id":null,"jsonrpc":"2.0","method":"someNotification"}',
\ ],
\ ale#lsp#CreateMessageData([1, 'someNotification'])
AssertEqual
\ [
\ 0,
\ "Content-Length: 78\r\n\r\n"
\ . '{"id":null,"jsonrpc":"2.0","method":"someNotification","params":{"foo":"bar"}}',
\ ],
\ ale#lsp#CreateMessageData([1, 'someNotification', {'foo': 'bar'}])
if has('nvim')
AssertEqual
\ [
\ 0,
\ "Content-Length: 60\r\n\r\n"
\ . '{"id": null, "jsonrpc": "2.0", "method": "someNotification"}',
\ ],
\ ale#lsp#CreateMessageData([1, 'someNotification'])
AssertEqual
\ [
\ 0,
\ "Content-Length: 86\r\n\r\n"
\ . '{"id": null, "jsonrpc": "2.0", "method": "someNotification", "params": {"foo": "bar"}}',
\ ],
\ ale#lsp#CreateMessageData([1, 'someNotification', {'foo': 'bar'}])
else
AssertEqual
\ [
\ 0,
\ "Content-Length: 55\r\n\r\n"
\ . '{"id":null,"jsonrpc":"2.0","method":"someNotification"}',
\ ],
\ ale#lsp#CreateMessageData([1, 'someNotification'])
AssertEqual
\ [
\ 0,
\ "Content-Length: 78\r\n\r\n"
\ . '{"id":null,"jsonrpc":"2.0","method":"someNotification","params":{"foo":"bar"}}',
\ ],
\ ale#lsp#CreateMessageData([1, 'someNotification', {'foo': 'bar'}])
endif
Execute(ale#lsp#ReadMessageData() should read single whole messages):
AssertEqual

View File

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

View File

@@ -1,5 +1,9 @@
Execute(The after file should have been loaded for real):
Assert g:loaded_ale_after
" FIXME: Fix these tests in NeoVim.
if !has('nvim')
Assert has_key(g:, 'loaded_ale_after'), 'g:loaded_ale_after was not set!'
Assert g:loaded_ale_after
endif
Before:
silent! cd /testplugin/test

View File

@@ -65,7 +65,10 @@ After:
delfunction GetLastMessage
mess clear
" Clearing the messages breaks tests on NeoVim for some reason, but all
" we need to do for these tests is just make it so the last message isn't
" carried over between test cases.
echomsg ''
Given javascript(A Javscript file with warnings/errors):
var x = 3

View File

@@ -44,7 +44,13 @@ Execute(History should be set when commands are run):
AssertEqual 1, len(g:history)
AssertEqual sort(['status', 'exit_code', 'job_id', 'command']), sort(keys(g:history[0]))
AssertEqual ['/bin/sh', '-c', 'echo command history test'], g:history[0].command
if has('nvim')
AssertEqual 'echo command history test', g:history[0].command
else
AssertEqual ['/bin/sh', '-c', 'echo command history test'], g:history[0].command
endif
AssertEqual 'finished', g:history[0].status
AssertEqual 0, g:history[0].exit_code
" The Job ID will change each time, but we can check the type.