]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/test/sign/test_linting_sets_signs.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 / sign / test_linting_sets_signs.vader
1 Given foobar (Some imaginary filetype):
2   var y = 3+3;
3   var y = 3
4
5 Before:
6   Save g:ale_buffer_info
7   Save g:ale_echo_cursor
8   Save g:ale_run_synchronously
9   Save g:ale_set_highlights
10   Save g:ale_set_loclist
11   Save g:ale_set_quickfix
12   Save g:ale_set_signs
13   Save g:ale_command_wrapper
14   Save g:ale_use_neovim_diagnostics_api
15
16   let g:ale_command_wrapper = ''
17   let g:ale_buffer_info = {}
18   let g:ale_run_synchronously = 1
19   unlet! g:ale_run_synchronously_callbacks
20   let g:ale_set_signs = 1
21   " Disable features we don't need for these tests.
22   let g:ale_set_quickfix = 0
23   let g:ale_set_loclist = 0
24   let g:ale_set_highlights = 0
25   let g:ale_echo_cursor = 0
26   let g:ale_use_neovim_diagnostics_api = 0
27
28   call ale#sign#Clear()
29
30   function! TestCallback(buffer, output)
31     return [
32     \ {'lnum': 1, 'text': 'foo', 'type': 'W'},
33     \ {'lnum': 2, 'text': 'foo', 'type': 'E'},
34     \]
35   endfunction
36
37   function! CollectSigns()
38     redir => l:output
39       if has('nvim-0.4.2') || has('patch-8.1.614')
40         silent exec 'sign place group=ale_signs'
41       else
42         silent exec 'sign place'
43       endif
44     redir END
45
46     let l:actual_sign_list = []
47
48     for l:line in split(l:output, "\n")
49       let l:match = matchlist(l:line, ale#sign#ParsePattern())
50
51       if len(l:match) > 0
52         call add(l:actual_sign_list, [l:match[1], l:match[3]])
53       endif
54     endfor
55
56     return l:actual_sign_list
57   endfunction
58
59   call ale#linter#Define('foobar', {
60   \ 'name': 'testlinter',
61   \ 'callback': 'TestCallback',
62   \ 'executable': has('win32') ? 'cmd' : 'echo',
63   \ 'command': has('win32') ? 'echo foo bar' : '/bin/sh -c ''echo foo bar''',
64   \})
65
66 After:
67   delfunction TestCallback
68   delfunction CollectSigns
69
70   unlet! g:ale_run_synchronously_callbacks
71   call ale#sign#Clear()
72   call ale#linter#Reset()
73
74 Execute(The signs should be updated after linting is done):
75   ALELint
76   call ale#test#FlushJobs()
77
78   AssertEqual [['1', 'ALEWarningSign'], ['2', 'ALEErrorSign']], CollectSigns()
79
80 Execute(Signs should not be set when diagnostics API integration is enabled):
81   let g:ale_use_neovim_diagnostics_api = 1
82   ALELint
83   call ale#test#FlushJobs()
84
85   AssertEqual [], CollectSigns()