]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/test/test_ale_lint_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_lint_command.vader
1 Before:
2   Save g:ale_buffer_info
3   Save g:ale_enabled
4
5   let g:ale_buffer_info = {}
6   let g:ale_enabled = 1
7
8   let g:expected_loclist = [{
9   \ 'bufnr': bufnr('%'),
10   \ 'lnum': 2,
11   \ 'vcol': 0,
12   \ 'col': 3,
13   \ 'text': 'foo bar',
14   \ 'type': 'E',
15   \ 'nr': -1,
16   \ 'pattern': '',
17   \ 'valid': 1,
18   \}]
19
20   function! ToggleTestCallback(buffer, output)
21     return [{
22     \ 'bufnr': a:buffer,
23     \ 'lnum': 2,
24     \ 'vcol': 0,
25     \ 'col': 3,
26     \ 'text': join(split(a:output[0])),
27     \ 'type': 'E',
28     \ 'nr': -1,
29     \}]
30   endfunction
31
32   call ale#linter#Define('foobar', {
33   \ 'name': 'testlinter',
34   \ 'callback': 'ToggleTestCallback',
35   \ 'executable': has('win32') ? 'cmd' : 'echo',
36   \ 'command': 'echo foo bar',
37   \})
38
39 After:
40   Restore
41
42   unlet! g:expected_loclist
43   unlet! b:i
44
45   call ale#engine#Cleanup(bufnr(''))
46   call ale#linter#Reset()
47
48   let g:ale_buffer_info = {}
49
50   delfunction ToggleTestCallback
51
52 Given foobar (Some imaginary filetype):
53   foo
54   bar
55   baz
56
57 Execute(ALELint should run the linters):
58   AssertEqual 'foobar', &filetype
59
60   " Try to run the linter a few times, as it fails randomly in NeoVim.
61   for b:i in range(5)
62     ALELint
63     call ale#test#WaitForJobs(2000)
64
65     if !has('nvim')
66       " Sleep so the delayed list function can run.
67       " This breaks the tests in NeoVim for some reason.
68       sleep 1ms
69     endif
70
71     if ale#test#GetLoclistWithoutNewerKeys() == g:expected_loclist
72       break
73     endif
74   endfor
75
76   " Check the loclist
77   AssertEqual g:expected_loclist, ale#test#GetLoclistWithoutNewerKeys()