]> git.madduck.net Git - etc/vim.git/blob - 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:

Squashed '.vim/bundle/ale/' content from commit 22185c4c
[etc/vim.git] / test / test_other_sources.vader
1 Before:
2   Save g:ale_buffer_info
3   Save g:ale_set_signs
4   Save g:ale_set_quickfix
5   Save g:ale_set_loclist
6   Save g:ale_set_highlights
7   Save g:ale_echo_cursor
8
9   let g:ale_buffer_info = {}
10   let g:ale_run_synchronously = 1
11   let g:ale_set_lists_synchronously = 1
12   let g:ale_set_signs = 0
13   let g:ale_set_quickfix = 0
14   let g:ale_set_loclist = 1
15   let g:ale_set_highlights = 0
16   let g:ale_echo_cursor = 0
17
18   function! TestCallback(buffer, output)
19     return []
20   endfunction
21
22   call ale#linter#Define('foobar', {
23   \ 'name': 'testlinter',
24   \ 'callback': 'TestCallback',
25   \ 'executable': has('win32') ? 'cmd' : 'echo',
26   \ 'command': has('win32') ? 'echo foo bar' : '/bin/sh -c ''echo foo bar''',
27   \})
28
29 After:
30   Restore
31
32   unlet! b:ale_linters
33   unlet! g:want_results_signaled
34   unlet! g:want_results_buffer_value
35   unlet! g:lint_pre_signaled
36   unlet! g:ale_run_synchronously
37   unlet! g:ale_set_lists_synchronously
38
39   delfunction TestCallback
40
41   augroup VaderTest
42     autocmd!
43   augroup END
44
45   augroup! VaderTest
46
47   call ale#linter#Reset()
48   call setloclist(0, [])
49
50 Given foobar (Some imaginary filetype):
51 Execute(StartChecking should mark a buffer as being actively checked):
52   Assert !ale#engine#IsCheckingBuffer(bufnr(''))
53
54   call ale#other_source#StartChecking(bufnr(''), 'other-source-linter')
55
56   Assert ale#engine#IsCheckingBuffer(bufnr(''))
57
58 Execute(ShowResults should make a buffer inactive):
59   call ale#other_source#StartChecking(bufnr(''), 'other-source-linter')
60   call ale#other_source#StartChecking(bufnr(''), 'second-other-source-linter')
61
62   call ale#other_source#ShowResults(bufnr(''), 'other-source-linter', [])
63
64   Assert ale#engine#IsCheckingBuffer(bufnr(''))
65
66   call ale#other_source#ShowResults(bufnr(''), 'second-other-source-linter', [])
67
68   Assert !ale#engine#IsCheckingBuffer(bufnr(''))
69
70 Execute(ShowResults should show results at any time):
71   call ale#other_source#ShowResults(bufnr(''), 'other-source-linter', [
72   \ {'text': 'xyz', 'lnum': 1},
73   \])
74
75   AssertEqual
76   \ [
77   \   {
78   \     'lnum': 1,
79   \     'bufnr': bufnr(''),
80   \     'col': 0,
81   \     'valid': 1,
82   \     'vcol': 0,
83   \     'nr': -1,
84   \     'type': 'E',
85   \     'pattern': '',
86   \     'text': 'xyz',
87   \   },
88   \ ],
89   \ ale#test#GetLoclistWithoutNewerKeys()
90
91   call ale#other_source#ShowResults(bufnr(''), 'other-source-linter', [])
92
93   AssertEqual [], ale#test#GetLoclistWithoutNewerKeys()
94
95 Execute(A regular lint cycle shouldn't clear results from other sources):
96   call ale#other_source#ShowResults(bufnr(''), 'other-source-linter', [
97   \ {'text': 'xyz', 'lnum': 1},
98   \])
99   ALELint
100
101   AssertEqual
102   \ [
103   \   {
104   \     'lnum': 1,
105   \     'bufnr': bufnr(''),
106   \     'col': 0,
107   \     'valid': 1,
108   \     'vcol': 0,
109   \     'nr': -1,
110   \     'type': 'E',
111   \     'pattern': '',
112   \     'text': 'xyz',
113   \   },
114   \ ],
115   \ ale#test#GetLoclistWithoutNewerKeys()
116
117 Execute(ALEWantResults should be signaled when a buffer is checked):
118   augroup VaderTest
119     autocmd!
120     autocmd User ALEWantResults let g:want_results_signaled = 1
121     autocmd User ALELintPre let g:lint_pre_signaled = 1
122   augroup END
123
124   " Even when all linters are disabled, we should send the signal.
125   let b:ale_linters = []
126   ALELint
127
128   Assert get(g:, 'want_results_signaled')
129   Assert !get(g:, 'lint_pre_signaled')
130
131 Execute(ALEWantResults should set a variable indicating which buffer is being checked):
132   augroup VaderTest
133     autocmd!
134     autocmd User ALEWantResults let g:want_results_buffer_value = g:ale_want_results_buffer
135   augroup END
136
137   let b:ale_linters = []
138   ALELint
139
140   AssertEqual bufnr(''), g:want_results_buffer_value
141
142 Execute(ALEWantResults should lead to an ALELintPre signal if another source responds):
143   augroup VaderTest
144     autocmd!
145     autocmd User ALEWantResults call ale#other_source#StartChecking(bufnr(''), 'other-source-linter')
146     autocmd User ALELintPre let g:lint_pre_signaled = 1
147   augroup END
148
149   " Even when all linters are disabled, we should send the signal.
150   let b:ale_linters = []
151   ALELint
152
153   Assert get(g:, 'lint_pre_signaled')