summaryrefslogtreecommitdiff
path: root/test/test_linter_defintion_processing.vader
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-02-04 18:30:30 +0000
committerw0rp <devw0rp@gmail.com>2017-02-04 18:30:30 +0000
commit829f87bc6a63cd442c7e2bf55870faa8804668a4 (patch)
tree5886ed67def110fb58b1515f03545e8f1c9e15bd /test/test_linter_defintion_processing.vader
parent97131262abf31de883bcb65835ed6842f66bbd3b (diff)
downloadale-829f87bc6a63cd442c7e2bf55870faa8804668a4.zip
Fix #124 Finish implementing command chaining, and make it work for DMD
Diffstat (limited to 'test/test_linter_defintion_processing.vader')
-rw-r--r--test/test_linter_defintion_processing.vader88
1 files changed, 88 insertions, 0 deletions
diff --git a/test/test_linter_defintion_processing.vader b/test/test_linter_defintion_processing.vader
index 52d40530..4b5c6a76 100644
--- a/test/test_linter_defintion_processing.vader
+++ b/test/test_linter_defintion_processing.vader
@@ -1,3 +1,9 @@
+Before:
+ let g:linter = {}
+
+After:
+ unlet g:linter
+
Execute (PreProcess should throw when the linter object is not a Dictionary):
AssertThrows call ale#linter#PreProcess('')
AssertEqual 'The linter object must be a Dictionary', g:vader_exception
@@ -123,3 +129,85 @@ Execute (PreProcess should accept a 'both' output_stream):
\ 'command': 'echo',
\ 'output_stream': 'both',
\})
+
+Execute(PreProcess should complain if the command_chain is not a List):
+ let g:linter = {
+ \ 'name': 'x',
+ \ 'callback': 'x',
+ \ 'executable': 'x',
+ \ 'command_chain': 'x',
+ \}
+ AssertThrows call ale#linter#PreProcess(g:linter)
+ AssertEqual '`command_chain` must be a List', g:vader_exception
+
+Execute(PreProcess should complain if the command_chain is empty):
+ let g:linter = {
+ \ 'name': 'x',
+ \ 'callback': 'x',
+ \ 'executable': 'x',
+ \ 'command_chain': [],
+ \}
+ AssertThrows call ale#linter#PreProcess(g:linter)
+ AssertEqual '`command_chain` must contain at least one item', g:vader_exception
+
+Execute(PreProcess should complain if the command_chain has no callback):
+ let g:linter = {
+ \ 'name': 'x',
+ \ 'callback': 'x',
+ \ 'executable': 'x',
+ \ 'command_chain': [{}],
+ \}
+ AssertThrows call ale#linter#PreProcess(g:linter)
+ AssertEqual 'The `command_chain` item 0 must define a `callback` function', g:vader_exception
+
+Execute(PreProcess should complain if the command_chain callback is not a function):
+ let g:linter = {
+ \ 'name': 'x',
+ \ 'callback': 'x',
+ \ 'executable': 'x',
+ \ 'command_chain': [{'callback': 2}],
+ \}
+ AssertThrows call ale#linter#PreProcess(g:linter)
+ AssertEqual 'The `command_chain` item 0 must define a `callback` function', g:vader_exception
+
+Execute(PreProcess should accept a chain with one callback):
+ let g:linter = {
+ \ 'name': 'x',
+ \ 'callback': 'x',
+ \ 'executable': 'x',
+ \ 'command_chain': [{'callback': 'foo'}],
+ \}
+ call ale#linter#PreProcess(g:linter)
+
+Execute(PreProcess should complain about invalid output_stream values in the chain):
+ let g:linter = {
+ \ 'name': 'x',
+ \ 'callback': 'x',
+ \ 'executable': 'x',
+ \ 'command_chain': [{'callback': 'foo', 'output_stream': ''}],
+ \}
+ AssertThrows call ale#linter#PreProcess(g:linter)
+ AssertEqual "The `command_chain` item 0 `output_stream` flag must be 'stdout', 'stderr', or 'both'", g:vader_exception
+
+Execute(PreProcess should complain about valid output_stream values in the chain):
+ let g:linter = {
+ \ 'name': 'x',
+ \ 'callback': 'x',
+ \ 'executable': 'x',
+ \ 'command_chain': [{'callback': 'foo', 'output_stream': 'stdout'}],
+ \}
+ call ale#linter#PreProcess(g:linter)
+ let g:linter.command_chain[0].output_stream = 'stderr'
+ call ale#linter#PreProcess(g:linter)
+ let g:linter.command_chain[0].output_stream = 'both'
+ call ale#linter#PreProcess(g:linter)
+
+Execute(PreProcess should complain about invalid chain items at higher indices):
+ let g:linter = {
+ \ 'name': 'x',
+ \ 'callback': 'x',
+ \ 'executable': 'x',
+ \ 'command_chain': [{'callback': 'foo'}, {'callback': 123}],
+ \}
+ AssertThrows call ale#linter#PreProcess(g:linter)
+ AssertEqual 'The `command_chain` item 1 must define a `callback` function', g:vader_exception