summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/test_ale_info.vader26
-rw-r--r--test/test_linter_defintion_processing.vader42
-rw-r--r--test/test_linter_retrieval.vader70
3 files changed, 110 insertions, 28 deletions
diff --git a/test/test_ale_info.vader b/test/test_ale_info.vader
index 83d32cb0..3c4e2b16 100644
--- a/test/test_ale_info.vader
+++ b/test/test_ale_info.vader
@@ -209,6 +209,32 @@ Execute (ALEInfo should buffer-local linter variables):
\ . g:globals_string . g:command_header, g:output
Given testft.testft2 (Empty buffer with two filetypes):
+Execute (ALEInfo should output linter aliases):
+ let g:testlinter1.aliases = ['testftalias1', 'testftalias2']
+ let g:testlinter2.aliases = ['testftalias3', 'testftalias4']
+
+ let g:ale_testft2_testlinter2_foo = 123
+ let b:ale_testft2_testlinter2_foo = 456
+
+ call ale#linter#Define('testft', g:testlinter1)
+ call ale#linter#Define('testft2', g:testlinter2)
+ redir => g:output
+ silent ALEInfo
+ redir END
+ AssertEqual "\n
+ \ Current Filetype: testft.testft2\n
+ \Available Linters: ['testlinter1', 'testlinter2']\n
+ \ Linter Aliases:\n
+ \ 'testlinter1' -> ['testftalias1', 'testftalias2']\n
+ \ 'testlinter2' -> ['testftalias3', 'testftalias4']\n
+ \ Enabled Linters: ['testlinter1', 'testlinter2']\n
+ \ Linter Variables:\n
+ \\n
+ \let g:ale_testft2_testlinter2_foo = 123\n
+ \let b:ale_testft2_testlinter2_foo = 456"
+ \ . g:globals_string . g:command_header, g:output
+
+Given testft.testft2 (Empty buffer with two filetypes):
Execute (ALEInfo should return command history):
let g:ale_buffer_info[bufnr('%')] = {
\ 'history': [
diff --git a/test/test_linter_defintion_processing.vader b/test/test_linter_defintion_processing.vader
index 91667e01..09566557 100644
--- a/test/test_linter_defintion_processing.vader
+++ b/test/test_linter_defintion_processing.vader
@@ -323,3 +323,45 @@ Execute(PreProcess should set a default value for lint_file):
\}
AssertEqual 0, ale#linter#PreProcess(g:linter).lint_file
+
+Execute(PreProcess should set a default value for aliases):
+ let g:linter = {
+ \ 'name': 'x',
+ \ 'callback': 'x',
+ \ 'executable': 'x',
+ \ 'command': 'x',
+ \}
+
+ AssertEqual [], ale#linter#PreProcess(g:linter).aliases
+
+Execute(PreProcess should complain about invalid `aliases` values):
+ let g:linter = {
+ \ 'name': 'x',
+ \ 'callback': 'x',
+ \ 'executable': 'x',
+ \ 'command': 'x',
+ \ 'aliases': 'foo',
+ \}
+
+ AssertThrows call ale#linter#PreProcess(g:linter)
+ AssertEqual '`aliases` must be a List of String values', g:vader_exception
+
+ let g:linter.aliases = [1]
+
+ AssertThrows call ale#linter#PreProcess(g:linter)
+ AssertEqual '`aliases` must be a List of String values', g:vader_exception
+
+Execute(PreProcess should accept `aliases` lists):
+ let g:linter = {
+ \ 'name': 'x',
+ \ 'callback': 'x',
+ \ 'executable': 'x',
+ \ 'command': 'x',
+ \ 'aliases': [],
+ \}
+
+ AssertEqual [], ale#linter#PreProcess(g:linter).aliases
+
+ let g:linter.aliases = ['foo', 'bar']
+
+ AssertEqual ['foo', 'bar'], ale#linter#PreProcess(g:linter).aliases
diff --git a/test/test_linter_retrieval.vader b/test/test_linter_retrieval.vader
index ecbae8d2..39258be1 100644
--- a/test/test_linter_retrieval.vader
+++ b/test/test_linter_retrieval.vader
@@ -1,85 +1,99 @@
Before:
- let g:testlinter1 = {'name': 'testlinter1', 'executable': 'testlinter1', 'command': 'testlinter1', 'callback': 'testCB1', 'output_stream': 'stdout', 'read_buffer': 1, 'lint_file': 0}
- let g:testlinter2 = {'name': 'testlinter2', 'executable': 'testlinter2', 'command': 'testlinter2', 'callback': 'testCB2', 'output_stream': 'stdout', 'read_buffer': 0, 'lint_file': 1}
+ Save g:ale_linters, g:ale_linter_aliases
+ let g:testlinter1 = {'name': 'testlinter1', 'executable': 'testlinter1', 'command': 'testlinter1', 'callback': 'testCB1', 'output_stream': 'stdout', 'read_buffer': 1, 'lint_file': 0, 'aliases': []}
+ let g:testlinter2 = {'name': 'testlinter2', 'executable': 'testlinter2', 'command': 'testlinter2', 'callback': 'testCB2', 'output_stream': 'stdout', 'read_buffer': 0, 'lint_file': 1, 'aliases': []}
call ale#linter#Reset()
- let g:ale_linters = {}
- let g:ale_linter_aliases = {}
+
+After:
+ Restore
+
+ unlet! g:testlinter1
+ unlet! g:testlinter2
unlet! b:ale_linters
unlet! b:ale_linter_aliases
+ call ale#linter#Reset()
-Execute (Define a linter):
+Execute (You should be able to get a defined linter):
call ale#linter#Define('testft', g:testlinter1)
-Then (Get the defined linter):
AssertEqual [g:testlinter1], ale#linter#Get('testft')
-Execute (Define a couple linters, filtering one):
+Execute (You should be able get select a single linter):
call ale#linter#Define('testft', g:testlinter1)
call ale#linter#Define('testft', g:testlinter2)
let g:ale_linters = {'testft': ['testlinter1']}
-Then (Only the configured linter should be returned):
+
+ AssertEqual [g:testlinter1], ale#linter#Get('testft')
+
+Execute (You should be able to select a linter by an alias):
+ let g:testlinter1.aliases = ['foo', 'linter1alias']
+
+ call ale#linter#Define('testft', g:testlinter1)
+ call ale#linter#Define('testft', g:testlinter2)
+ let g:ale_linters = {'testft': ['linter1alias']}
+
AssertEqual [g:testlinter1], ale#linter#Get('testft')
-Execute (Define a couple linters, and set a buffer override):
+Execute (You should be able to select linters with a buffer option):
call ale#linter#Define('testft', g:testlinter1)
call ale#linter#Define('testft', g:testlinter2)
let g:ale_linters = {'testft': ['testlinter1', 'testlinter2']}
let b:ale_linters = {'testft': ['testlinter1']}
-Then (The buffer setting should be used):
+
AssertEqual [g:testlinter1], ale#linter#Get('testft')
-Execute (Define a couple linters, and set a buffer override for another filetype):
+Execute (Buffer settings shouldn't completely replace global settings):
call ale#linter#Define('testft', g:testlinter1)
call ale#linter#Define('testft', g:testlinter2)
let g:ale_linters = {'testft': ['testlinter1']}
let b:ale_linters = {'testft2': ['testlinter1', 'testlinter2']}
-Then (The global value should be used):
+
AssertEqual [g:testlinter1], ale#linter#Get('testft')
-Execute (Define a linter for a filetype, and create a filetype alias):
+Execute (You should be able to alias linters from one filetype to another):
call ale#linter#Define('testft1', g:testlinter1)
let g:ale_linter_aliases = {'testft2': 'testft1'}
-Then (Linters should be transparently aliased):
+
AssertEqual [g:testlinter1], ale#linter#Get('testft2')
-Execute (Define multiple linters, with filters and aliases):
+Execute (You should be able to filter aliased linters):
call ale#linter#Define('testft1', g:testlinter1)
call ale#linter#Define('testft1', g:testlinter2)
let g:ale_linters = {'testft1': ['testlinter1'], 'testft2': ['testlinter2']}
let g:ale_linter_aliases = {'testft2': 'testft1'}
-Then (Linters should be transparently filtered and aliased):
+
AssertEqual [g:testlinter1], ale#linter#Get('testft1')
AssertEqual [g:testlinter2], ale#linter#Get('testft2')
-Execute (Define multiple linters for different filetypes):
+Execute (Dot-separated filetypes should be handled correctly):
call ale#linter#Define('testft1', g:testlinter1)
call ale#linter#Define('testft2', g:testlinter2)
-Then (Linters for dot-seperated filetypes should be properly handled):
+
AssertEqual [g:testlinter1, g:testlinter2], ale#linter#Get('testft1.testft2')
-Execute (Define multiple aliases for a filetype):
+Execute (Linters for multiple aliases should be loaded):
call ale#linter#Define('testft1', g:testlinter1)
call ale#linter#Define('testft2', g:testlinter2)
let ale_linter_aliases = {'testft3': ['testft1', 'testft2']}
-Then (Linters should be transparently aliased):
+
AssertEqual [g:testlinter1, g:testlinter2], ale#linter#Get('testft3')
-Execute (Alias a filetype to itself plus another one):
+Execute (You should be able to alias filetypes to themselves and another):
call ale#linter#Define('testft1', g:testlinter1)
call ale#linter#Define('testft2', g:testlinter2)
let ale_linter_aliases = {'testft1': ['testft1', 'testft2']}
-Then (The original linters should still be there):
+
AssertEqual [g:testlinter1, g:testlinter2], ale#linter#Get('testft1')
-Execute (Set up aliases in the buffer):
+Execute (Buffer-local overrides for aliases should be used):
call ale#linter#Define('testft1', g:testlinter1)
call ale#linter#Define('testft2', g:testlinter2)
let g:ale_linter_aliases = {'testft1': ['testft2']}
let b:ale_linter_aliases = {'testft1': ['testft1', 'testft2']}
-Then (The buffer-local override should be used):
+
AssertEqual [g:testlinter1, g:testlinter2], ale#linter#Get('testft1')
-Execute (Set up aliases in the buffer for another filetype):
+Execute (The local alias option shouldn't completely replace the global one):
call ale#linter#Define('testft1', g:testlinter1)
call ale#linter#Define('testft2', g:testlinter2)
let g:ale_linter_aliases = {'testft1': ['testft1', 'testft2']}
@@ -87,8 +101,8 @@ Execute (Set up aliases in the buffer for another filetype):
" We should look for a key in this Dictionary first, and then check the
" global Dictionary.
let b:ale_linter_aliases = {'testft3': ['testft1']}
-Then (The global value should be used):
+
AssertEqual [g:testlinter1, g:testlinter2], ale#linter#Get('testft1')
-Execute (Try to load a linter from disk):
- AssertEqual [{'name': 'testlinter', 'output_stream': 'stdout', 'executable': 'testlinter', 'command': 'testlinter', 'callback': 'testCB', 'read_buffer': 1, 'lint_file': 0}], ale#linter#Get('testft')
+Execute (Linters should be loaded from disk appropriately):
+ AssertEqual [{'name': 'testlinter', 'output_stream': 'stdout', 'executable': 'testlinter', 'command': 'testlinter', 'callback': 'testCB', 'read_buffer': 1, 'lint_file': 0, 'aliases': []}], ale#linter#Get('testft')