diff options
Diffstat (limited to 'test')
l--------- | test/.config/nvim/init.vim | 1 | ||||
-rw-r--r-- | test/handler/test_ghc_mod_handler.vader | 27 | ||||
-rw-r--r-- | test/handler/test_gometalinter_handler.vader | 25 | ||||
-rw-r--r-- | test/lsp/test_lsp_connections.vader | 119 | ||||
-rw-r--r-- | test/sign/test_linting_sets_signs.vader | 1 | ||||
-rw-r--r-- | test/smoke_test.vader | 3 | ||||
-rw-r--r-- | test/test_ale_toggle.vader | 5 | ||||
-rw-r--r-- | test/test_command_chain.vader | 7 | ||||
-rw-r--r-- | test/test_conflicting_plugin_warnings.vader | 6 | ||||
-rw-r--r-- | test/test_cursor_warnings.vader | 5 | ||||
-rw-r--r-- | test/test_line_join.vader | 2 | ||||
-rw-r--r-- | test/test_vim8_processid_parsing.vader | 8 |
12 files changed, 157 insertions, 52 deletions
diff --git a/test/.config/nvim/init.vim b/test/.config/nvim/init.vim new file mode 120000 index 00000000..90f52f07 --- /dev/null +++ b/test/.config/nvim/init.vim @@ -0,0 +1 @@ +../../vimrc
\ No newline at end of file diff --git a/test/handler/test_ghc_mod_handler.vader b/test/handler/test_ghc_mod_handler.vader new file mode 100644 index 00000000..f9b44b33 --- /dev/null +++ b/test/handler/test_ghc_mod_handler.vader @@ -0,0 +1,27 @@ +Execute(HandleGhcFormat should handle ghc-mod problems): + AssertEqual + \ [ + \ { + \ 'lnum': 2, + \ 'col': 1, + \ 'type': 'E', + \ 'text': 'Failed to load interface for ‘Missing’Use -v to see a list of the files searched for.', + \ }, + \ { + \ 'lnum': 2, + \ 'col': 1, + \ 'type': 'E', + \ 'text': ' Suggestion: Use camelCaseFound: my_variable = ...Why not: myVariable = ...', + \ }, + \ { + \ 'lnum': 6, + \ 'col': 1, + \ 'type': 'E', + \ 'text': ' Warning: Eta reduceFound: myFunc x = succ xWhy not: myFunc = succ', + \ }, + \ ], + \ ale#handlers#haskell#HandleGHCFormat(bufnr(''), [ + \ 'check1.hs:2:1:Failed to load interface for ‘Missing’Use -v to see a list of the files searched for.', + \ 'check2.hs:2:1: Suggestion: Use camelCaseFound: my_variable = ...Why not: myVariable = ...', + \ 'check2.hs:6:1: Warning: Eta reduceFound: myFunc x = succ xWhy not: myFunc = succ', + \ ]) diff --git a/test/handler/test_gometalinter_handler.vader b/test/handler/test_gometalinter_handler.vader index 3b622130..52a4fc96 100644 --- a/test/handler/test_gometalinter_handler.vader +++ b/test/handler/test_gometalinter_handler.vader @@ -30,7 +30,7 @@ Execute (The gometalinter handler should handle names with spaces): \ ]), 'v:val[1:5]') Execute (The gometalinter handler should handle relative paths correctly): - :file! /foo/bar/baz.go + silent file /foo/bar/baz.go AssertEqual \ [ @@ -47,7 +47,28 @@ Execute (The gometalinter handler should handle relative paths correctly): \ 'type': 'E', \ }, \ ], - \ ale_linters#go#gometalinter#Handler(42, [ + \ ale_linters#go#gometalinter#Handler(bufnr(''), [ \ 'baz.go:12:3:warning: expected ''package'', found ''IDENT'' gibberish (staticcheck)', \ 'baz.go:37:5:error: expected ''package'', found ''IDENT'' gibberish (golint)', \ ]) + + +Execute (The gometalinter handler should filter out errors from other files): + silent file! /some/path/sql.go + + AssertEqual + \ [], + \ ale_linters#go#gometalinter#Handler(bufnr(''), [ + \ '/some/path/interface_implementation_test.go:417::warning: cyclomatic complexity 24 of function testGetUserHeaders() is high (> 10) (gocyclo)', + \ '/some/path/sql_helpers.go:38::warning: cyclomatic complexity 11 of function CreateTestUserMetadataDB() is high (> 10) (gocyclo)', + \ '/some/path/sql_alpha.go:560:7:warning: ineffectual assignment to err (ineffassign)', + \ '/some/path/sql_alpha.go:589:7:warning: ineffectual assignment to err (ineffassign)', + \ '/some/path/sql_test.go:124:9:warning: should not use basic type untyped string as key in context.WithValue (golint)', + \ '/some/path/interface_implementation_test.go:640::warning: declaration of "cfg" shadows declaration at sql_test.go:21 (vetshadow)', + \ '/some/path/sql_helpers.go:55::warning: declaration of "err" shadows declaration at sql_helpers.go:48 (vetshadow)', + \ '/some/path/sql_helpers.go:91::warning: declaration of "err" shadows declaration at sql_helpers.go:48 (vetshadow)', + \ '/some/path/sql_helpers.go:108::warning: declaration of "err" shadows declaration at sql_helpers.go:48 (vetshadow)', + \ '/some/path/user_metadata_db.go:149::warning: declaration of "err" shadows declaration at user_metadata_db.go:140 (vetshadow)', + \ '/some/path/user_metadata_db.go:188::warning: declaration of "err" shadows declaration at user_metadata_db.go:179 (vetshadow)', + \ '/some/path/queries_alpha.go:62::warning: Potential hardcoded credentials,HIGH,LOW (gas)', + \ ]) diff --git a/test/lsp/test_lsp_connections.vader b/test/lsp/test_lsp_connections.vader index 36a21bd2..d5ed7702 100644 --- a/test/lsp/test_lsp_connections.vader +++ b/test/lsp/test_lsp_connections.vader @@ -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 diff --git a/test/sign/test_linting_sets_signs.vader b/test/sign/test_linting_sets_signs.vader index 0654be47..1530847e 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#linter#Reset() Execute(The signs should be updated after linting is done): call ale#Lint() diff --git a/test/smoke_test.vader b/test/smoke_test.vader index 18b74cf0..30f32534 100644 --- a/test/smoke_test.vader +++ b/test/smoke_test.vader @@ -11,11 +11,12 @@ Before: \}] endfunction + " Running the command in another subshell seems to help here. call ale#linter#Define('foobar', { \ 'name': 'testlinter', \ 'callback': 'TestCallback', \ 'executable': 'echo', - \ 'command': 'echo foo bar', + \ 'command': '/bin/sh -c ''echo foo bar''', \}) After: diff --git a/test/test_ale_toggle.vader b/test/test_ale_toggle.vader index cbb31857..5d27c864 100644 --- a/test/test_ale_toggle.vader +++ b/test/test_ale_toggle.vader @@ -26,7 +26,7 @@ Before: \ 'lnum': 2, \ 'vcol': 0, \ 'col': 3, - \ 'text': a:output[0], + \ 'text': 'foo bar', \ 'type': 'E', \ 'nr': -1, \}] @@ -56,7 +56,8 @@ Before: \ 'name': 'testlinter', \ 'callback': 'ToggleTestCallback', \ 'executable': 'echo', - \ 'command': 'echo foo bar', + \ 'command': 'echo', + \ 'read_buffer': 0, \}) After: diff --git a/test/test_command_chain.vader b/test/test_command_chain.vader index 7b5e83ca..16472041 100644 --- a/test/test_command_chain.vader +++ b/test/test_command_chain.vader @@ -1,4 +1,7 @@ Before: + Save &shell, g:ale_run_synchronously + let g:ale_run_synchronously = 1 + set shell=/bin/sh let g:linter_output = [] let g:first_echo_called = 0 let g:second_echo_called = 0 @@ -39,6 +42,7 @@ Before: \}) After: + Restore unlet! g:first_echo_called unlet! g:second_echo_called unlet! g:final_callback_called @@ -55,9 +59,6 @@ Given foobar (Some imaginary filetype): Execute(Check the results of running the chain): AssertEqual 'foobar', &filetype call ale#Lint() - " Sleep a little. This allows the commands to complete a little better. - sleep 50m - call ale#engine#WaitForJobs(2000) Assert g:first_echo_called, 'The first chain item was not called' Assert g:second_echo_called, 'The second chain item was not called' diff --git a/test/test_conflicting_plugin_warnings.vader b/test/test_conflicting_plugin_warnings.vader index ebf53c8a..08a4c412 100644 --- a/test/test_conflicting_plugin_warnings.vader +++ b/test/test_conflicting_plugin_warnings.vader @@ -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 diff --git a/test/test_cursor_warnings.vader b/test/test_cursor_warnings.vader index 09081b12..6018dabd 100644 --- a/test/test_cursor_warnings.vader +++ b/test/test_cursor_warnings.vader @@ -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 diff --git a/test/test_line_join.vader b/test/test_line_join.vader index 26abb7c9..63d8d338 100644 --- a/test/test_line_join.vader +++ b/test/test_line_join.vader @@ -18,6 +18,6 @@ After: Execute (Join the lines): let joined_result = [] for item in g:test_output - call ale#engine#JoinNeovimOutput(joined_result, item) + call ale#job#JoinNeovimOutput(joined_result, item) endfor AssertEqual g:expected_result, joined_result diff --git a/test/test_vim8_processid_parsing.vader b/test/test_vim8_processid_parsing.vader index 5ec564e0..26416b15 100644 --- a/test/test_vim8_processid_parsing.vader +++ b/test/test_vim8_processid_parsing.vader @@ -1,5 +1,5 @@ Execute(Vim8 Process ID parsing should work): - AssertEqual 123, ale#engine#ParseVim8ProcessID('process 123 run') - AssertEqual 347, ale#engine#ParseVim8ProcessID('process 347 failed') - AssertEqual 789, ale#engine#ParseVim8ProcessID('process 789 dead') - AssertEqual 0, ale#engine#ParseVim8ProcessID('no process') + AssertEqual 123, ale#job#ParseVim8ProcessID('process 123 run') + AssertEqual 347, ale#job#ParseVim8ProcessID('process 347 failed') + AssertEqual 789, ale#job#ParseVim8ProcessID('process 789 dead') + AssertEqual 0, ale#job#ParseVim8ProcessID('no process') |