]> git.madduck.net Git - etc/vim.git/blob - .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
1 Before:
2   Save g:ale_buffer_info
3   Save g:ale_enabled
4   Save g:ale_set_quickfix
5   Save g:ale_set_loclist
6   Save g:ale_open_list
7
8   let g:ale_buffer_info = {}
9   let g:ale_enabled = 1
10   let g:ale_set_quickfix = 0
11   let g:ale_set_loclist = 0
12   let g:ale_open_list = 1
13
14   let g:expected_loclist = [{
15   \ 'bufnr': bufnr('%'),
16   \ 'lnum': 2,
17   \ 'vcol': 0,
18   \ 'col': 3,
19   \ 'text': 'foo bar',
20   \ 'type': 'E',
21   \ 'nr': -1,
22   \ 'pattern': '',
23   \ 'valid': 1,
24   \}]
25
26   function! ToggleTestCallback(buffer, output)
27     return [{
28     \ 'bufnr': a:buffer,
29     \ 'lnum': 2,
30     \ 'vcol': 0,
31     \ 'col': 3,
32     \ 'text': join(split(a:output[0])),
33     \ 'type': 'E',
34     \ 'nr': -1,
35     \}]
36   endfunction
37
38   call ale#linter#Define('foobar', {
39   \ 'name': 'testlinter',
40   \ 'callback': 'ToggleTestCallback',
41   \ 'executable': has('win32') ? 'cmd' : 'echo',
42   \ 'command': 'echo foo bar',
43   \})
44
45 After:
46   Restore
47
48   unlet! g:expected_loclist
49   unlet! b:i
50
51   call ale#engine#Cleanup(bufnr(''))
52   call ale#linter#Reset()
53
54   " Not sure this is necessary since it was Save/Restore-d
55   let g:ale_buffer_info = {}
56
57   delfunction ToggleTestCallback
58
59 Given foobar (Some imaginary filetype):
60   foo
61   bar
62   baz
63
64 Execute(ALEPopulateQuickfix should have results):
65   AssertEqual 'foobar', &filetype
66
67   " Clear so we can check that they're unmodified.
68   call setqflist([])
69   call setloclist(winnr(), [])
70
71   " Try to run the linter a few times, as it fails randomly in NeoVim.
72   for b:i in range(5)
73     ALELint
74     call ale#test#WaitForJobs(2000)
75
76     if !has('nvim')
77       " Sleep so the delayed list function can run.
78       " This breaks the tests in NeoVim for some reason.
79       sleep 1ms
80     endif
81
82     if ale#test#GetLoclistWithoutNewerKeys() == g:expected_loclist
83       break
84     endif
85   endfor
86
87
88   AssertEqual [], ale#test#GetLoclistWithoutNewerKeys()
89   AssertEqual [], ale#test#GetQflistWithoutNewerKeys()
90
91   ALEPopulateLocList
92   AssertNotEqual 0, get(getloclist(0, {'winid':0}), 'winid', 0)
93   AssertEqual g:expected_loclist, ale#test#GetLoclistWithoutNewerKeys()
94
95   ALEPopulateQuickfix
96   AssertEqual g:expected_loclist, ale#test#GetQflistWithoutNewerKeys()