]> git.madduck.net Git - etc/vim.git/blobdiff - .vim/bundle/ale/test/test_ale_populate_command.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_ale_populate_command.vader
diff --git a/.vim/bundle/ale/test/test_ale_populate_command.vader b/.vim/bundle/ale/test/test_ale_populate_command.vader
new file mode 100644 (file)
index 0000000..14789c7
--- /dev/null
@@ -0,0 +1,96 @@
+Before:
+  Save g:ale_buffer_info
+  Save g:ale_enabled
+  Save g:ale_set_quickfix
+  Save g:ale_set_loclist
+  Save g:ale_open_list
+
+  let g:ale_buffer_info = {}
+  let g:ale_enabled = 1
+  let g:ale_set_quickfix = 0
+  let g:ale_set_loclist = 0
+  let g:ale_open_list = 1
+
+  let g:expected_loclist = [{
+  \ 'bufnr': bufnr('%'),
+  \ 'lnum': 2,
+  \ 'vcol': 0,
+  \ 'col': 3,
+  \ 'text': 'foo bar',
+  \ 'type': 'E',
+  \ 'nr': -1,
+  \ 'pattern': '',
+  \ 'valid': 1,
+  \}]
+
+  function! ToggleTestCallback(buffer, output)
+    return [{
+    \ 'bufnr': a:buffer,
+    \ 'lnum': 2,
+    \ 'vcol': 0,
+    \ 'col': 3,
+    \ 'text': join(split(a:output[0])),
+    \ 'type': 'E',
+    \ 'nr': -1,
+    \}]
+  endfunction
+
+  call ale#linter#Define('foobar', {
+  \ 'name': 'testlinter',
+  \ 'callback': 'ToggleTestCallback',
+  \ 'executable': has('win32') ? 'cmd' : 'echo',
+  \ 'command': 'echo foo bar',
+  \})
+
+After:
+  Restore
+
+  unlet! g:expected_loclist
+  unlet! b:i
+
+  call ale#engine#Cleanup(bufnr(''))
+  call ale#linter#Reset()
+
+  " Not sure this is necessary since it was Save/Restore-d
+  let g:ale_buffer_info = {}
+
+  delfunction ToggleTestCallback
+
+Given foobar (Some imaginary filetype):
+  foo
+  bar
+  baz
+
+Execute(ALEPopulateQuickfix should have results):
+  AssertEqual 'foobar', &filetype
+
+  " Clear so we can check that they're unmodified.
+  call setqflist([])
+  call setloclist(winnr(), [])
+
+  " Try to run the linter a few times, as it fails randomly in NeoVim.
+  for b:i in range(5)
+    ALELint
+    call ale#test#WaitForJobs(2000)
+
+    if !has('nvim')
+      " Sleep so the delayed list function can run.
+      " This breaks the tests in NeoVim for some reason.
+      sleep 1ms
+    endif
+
+    if ale#test#GetLoclistWithoutNewerKeys() == g:expected_loclist
+      break
+    endif
+  endfor
+
+
+  AssertEqual [], ale#test#GetLoclistWithoutNewerKeys()
+  AssertEqual [], ale#test#GetQflistWithoutNewerKeys()
+
+  ALEPopulateLocList
+  AssertNotEqual 0, get(getloclist(0, {'winid':0}), 'winid', 0)
+  AssertEqual g:expected_loclist, ale#test#GetLoclistWithoutNewerKeys()
+
+  ALEPopulateQuickfix
+  AssertEqual g:expected_loclist, ale#test#GetQflistWithoutNewerKeys()