summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2019-02-22 15:24:34 +0000
committerw0rp <devw0rp@gmail.com>2019-02-22 15:24:34 +0000
commitf53b25d2567a2f7495dab444680596f48de427d1 (patch)
tree87768bc6ddaceaf5502df785b6b9fee6c5e516d6 /test
parentf8aeb5c5a45b57a35d1572176e345173c6e4de61 (diff)
downloadale-f53b25d2567a2f7495dab444680596f48de427d1.zip
#2132 - Implement project_root as a replacement for project_root_callback
Diffstat (limited to 'test')
-rw-r--r--test/test_linter_defintion_processing.vader68
1 files changed, 68 insertions, 0 deletions
diff --git a/test/test_linter_defintion_processing.vader b/test/test_linter_defintion_processing.vader
index a78b9838..cd32ebc8 100644
--- a/test/test_linter_defintion_processing.vader
+++ b/test/test_linter_defintion_processing.vader
@@ -1,4 +1,10 @@
Before:
+ Save g:ale_lsp_root
+ Save b:ale_lsp_root
+
+ let g:ale_lsp_root = {}
+ unlet! b:ale_lsp_root
+
let g:linter = {}
After:
@@ -558,6 +564,68 @@ Execute(PreProcess should complain about invalid address values):
\})
AssertEqual '`address` must be a String or Function if defined', g:vader_exception
+Execute(PreProcess should accept allow the project root be set as a String):
+ let g:linter = ale#linter#PreProcess('testft', {
+ \ 'name': 'x',
+ \ 'lsp': 'socket',
+ \ 'address': 'foo:123',
+ \ 'language': 'x',
+ \ 'project_root': '/foo/bar',
+ \})
+
+ AssertEqual '/foo/bar', ale#lsp_linter#FindProjectRoot(0, g:linter)
+
+Execute(PreProcess should accept allow the project root be set as a Function):
+ let g:linter = ale#linter#PreProcess('testft', {
+ \ 'name': 'x',
+ \ 'lsp': 'socket',
+ \ 'address': 'foo:123',
+ \ 'language': 'x',
+ \ 'project_root': {-> '/foo/bar'},
+ \})
+
+ AssertEqual '/foo/bar', ale#lsp_linter#FindProjectRoot(0, g:linter)
+
+Execute(PreProcess should complain when the project_root valid is invalid):
+ AssertThrows call ale#linter#PreProcess('testft', {
+ \ 'name': 'x',
+ \ 'lsp': 'socket',
+ \ 'address': 'foo:123',
+ \ 'language': 'x',
+ \ 'project_root': 0,
+ \})
+ AssertEqual '`project_root` must be a String or Function if defined', g:vader_exception
+
+Execute(PreProcess should accept project_root_callback as a String):
+ call ale#linter#PreProcess('testft', {
+ \ 'name': 'x',
+ \ 'lsp': 'socket',
+ \ 'address': 'foo:123',
+ \ 'language': 'x',
+ \ 'project_root_callback': 'Foobar',
+ \})
+
+Execute(PreProcess should accept project_root_callback as a Function):
+ let g:linter = ale#linter#PreProcess('testft', {
+ \ 'name': 'x',
+ \ 'lsp': 'socket',
+ \ 'address': 'foo:123',
+ \ 'language': 'x',
+ \ 'project_root_callback': {-> '/foo/bar'},
+ \})
+
+ AssertEqual '/foo/bar', ale#lsp_linter#FindProjectRoot(0, g:linter)
+
+Execute(PreProcess should complain when the project_root_callback valid is invalid):
+ AssertThrows call ale#linter#PreProcess('testft', {
+ \ 'name': 'x',
+ \ 'lsp': 'socket',
+ \ 'address': 'foo:123',
+ \ 'language': 'x',
+ \ 'project_root_callback': 0,
+ \})
+ AssertEqual '`project_root_callback` must be a callback if defined', g:vader_exception
+
Execute(PreProcess should complain about using initialization_options and initialization_options_callback together):
let g:linter = {
\ 'name': 'x',