]> git.madduck.net Git - etc/vim.git/blobdiff - .vim/bundle/ale/test/test_other_sources.vader

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge commit '76265755a1add77121c8f9dabb3e9bb70fe9a972' as '.vim/bundle/ale'
[etc/vim.git] / .vim / bundle / ale / test / test_other_sources.vader
diff --git a/.vim/bundle/ale/test/test_other_sources.vader b/.vim/bundle/ale/test/test_other_sources.vader
new file mode 100644 (file)
index 0000000..45a7d30
--- /dev/null
@@ -0,0 +1,153 @@
+Before:
+  Save g:ale_buffer_info
+  Save g:ale_set_signs
+  Save g:ale_set_quickfix
+  Save g:ale_set_loclist
+  Save g:ale_set_highlights
+  Save g:ale_echo_cursor
+
+  let g:ale_buffer_info = {}
+  let g:ale_run_synchronously = 1
+  let g:ale_set_lists_synchronously = 1
+  let g:ale_set_signs = 0
+  let g:ale_set_quickfix = 0
+  let g:ale_set_loclist = 1
+  let g:ale_set_highlights = 0
+  let g:ale_echo_cursor = 0
+
+  function! TestCallback(buffer, output)
+    return []
+  endfunction
+
+  call ale#linter#Define('foobar', {
+  \ 'name': 'testlinter',
+  \ 'callback': 'TestCallback',
+  \ 'executable': has('win32') ? 'cmd' : 'echo',
+  \ 'command': has('win32') ? 'echo foo bar' : '/bin/sh -c ''echo foo bar''',
+  \})
+
+After:
+  Restore
+
+  unlet! b:ale_linters
+  unlet! g:want_results_signaled
+  unlet! g:want_results_buffer_value
+  unlet! g:lint_pre_signaled
+  unlet! g:ale_run_synchronously
+  unlet! g:ale_set_lists_synchronously
+
+  delfunction TestCallback
+
+  augroup VaderTest
+    autocmd!
+  augroup END
+
+  augroup! VaderTest
+
+  call ale#linter#Reset()
+  call setloclist(0, [])
+
+Given foobar (Some imaginary filetype):
+Execute(StartChecking should mark a buffer as being actively checked):
+  Assert !ale#engine#IsCheckingBuffer(bufnr(''))
+
+  call ale#other_source#StartChecking(bufnr(''), 'other-source-linter')
+
+  Assert ale#engine#IsCheckingBuffer(bufnr(''))
+
+Execute(ShowResults should make a buffer inactive):
+  call ale#other_source#StartChecking(bufnr(''), 'other-source-linter')
+  call ale#other_source#StartChecking(bufnr(''), 'second-other-source-linter')
+
+  call ale#other_source#ShowResults(bufnr(''), 'other-source-linter', [])
+
+  Assert ale#engine#IsCheckingBuffer(bufnr(''))
+
+  call ale#other_source#ShowResults(bufnr(''), 'second-other-source-linter', [])
+
+  Assert !ale#engine#IsCheckingBuffer(bufnr(''))
+
+Execute(ShowResults should show results at any time):
+  call ale#other_source#ShowResults(bufnr(''), 'other-source-linter', [
+  \ {'text': 'xyz', 'lnum': 1},
+  \])
+
+  AssertEqual
+  \ [
+  \   {
+  \     'lnum': 1,
+  \     'bufnr': bufnr(''),
+  \     'col': 0,
+  \     'valid': 1,
+  \     'vcol': 0,
+  \     'nr': -1,
+  \     'type': 'E',
+  \     'pattern': '',
+  \     'text': 'xyz',
+  \   },
+  \ ],
+  \ ale#test#GetLoclistWithoutNewerKeys()
+
+  call ale#other_source#ShowResults(bufnr(''), 'other-source-linter', [])
+
+  AssertEqual [], ale#test#GetLoclistWithoutNewerKeys()
+
+Execute(A regular lint cycle shouldn't clear results from other sources):
+  call ale#other_source#ShowResults(bufnr(''), 'other-source-linter', [
+  \ {'text': 'xyz', 'lnum': 1},
+  \])
+  ALELint
+
+  AssertEqual
+  \ [
+  \   {
+  \     'lnum': 1,
+  \     'bufnr': bufnr(''),
+  \     'col': 0,
+  \     'valid': 1,
+  \     'vcol': 0,
+  \     'nr': -1,
+  \     'type': 'E',
+  \     'pattern': '',
+  \     'text': 'xyz',
+  \   },
+  \ ],
+  \ ale#test#GetLoclistWithoutNewerKeys()
+
+Execute(ALEWantResults should be signaled when a buffer is checked):
+  augroup VaderTest
+    autocmd!
+    autocmd User ALEWantResults let g:want_results_signaled = 1
+    autocmd User ALELintPre let g:lint_pre_signaled = 1
+  augroup END
+
+  " Even when all linters are disabled, we should send the signal.
+  let b:ale_linters = []
+  ALELint
+
+  Assert get(g:, 'want_results_signaled')
+  Assert !get(g:, 'lint_pre_signaled')
+
+Execute(ALEWantResults should set a variable indicating which buffer is being checked):
+  augroup VaderTest
+    autocmd!
+    autocmd User ALEWantResults let g:want_results_buffer_value = g:ale_want_results_buffer
+  augroup END
+
+  let b:ale_linters = []
+  ALELint
+
+  AssertEqual bufnr(''), g:want_results_buffer_value
+
+Execute(ALEWantResults should lead to an ALELintPre signal if another source responds):
+  augroup VaderTest
+    autocmd!
+    autocmd User ALEWantResults call ale#other_source#StartChecking(bufnr(''), 'other-source-linter')
+    autocmd User ALELintPre let g:lint_pre_signaled = 1
+  augroup END
+
+  " Even when all linters are disabled, we should send the signal.
+  let b:ale_linters = []
+  ALELint
+
+  Assert get(g:, 'lint_pre_signaled')