]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/test/test_disabling_ale.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 'a39f715c13be3352193ffd9c5b7536b8786eff64' as '.vim/bundle/vim-lsp'
[etc/vim.git] / .vim / bundle / ale / test / test_disabling_ale.vader
1 Before:
2   Save g:ale_buffer_info
3   Save g:ale_enabled
4   Save b:ale_enabled
5   Save g:ale_maximum_file_size
6   Save b:ale_maximum_file_size
7
8   function! SetUpCursorData()
9     let g:ale_buffer_info = {
10     \ bufnr('%'): {
11     \   'loclist': [
12     \     {
13     \       'lnum': 2,
14     \       'col': 10,
15     \       'linter_name': 'testlinter',
16     \       'type': 'W',
17     \       'text': 'X'
18     \     },
19     \   ],
20     \ },
21     \}
22
23     call cursor(2, 16)
24   endfunction
25
26   function! TestCallback(buffer, output)
27     return []
28   endfunction
29
30   call ale#linter#Define('foobar', {
31   \ 'name': 'testlinter',
32   \ 'callback': 'TestCallback',
33   \ 'executable': 'echo',
34   \ 'command': 'true',
35   \})
36
37   function GetLastMessage()
38     redir => l:output
39       silent mess
40     redir END
41
42     " Filter out messages that could come from saving this test file.
43     let l:lines = filter(split(l:output, "\n"), 'v:val !~ ''written\|No line''')
44
45     return empty(l:lines) ? '' : l:lines[-1]
46   endfunction
47
48   echomsg ''
49
50 After:
51   Restore
52   call ale#linter#Reset()
53   delfunction TestCallback
54   delfunction GetLastMessage
55   delfunction SetUpCursorData
56
57 Given foobar (Some imaginary filetype):
58   foo
59   bar
60   baz
61
62 Execute(Linting shouldn't happen when ALE is disabled globally):
63   let g:ale_enabled = 0
64   let g:ale_buffer_info = {}
65
66   call ale#Queue(0)
67
68   AssertEqual {}, g:ale_buffer_info
69   call SetUpCursorData()
70   call ale#cursor#EchoCursorWarning()
71   AssertEqual '', GetLastMessage()
72
73 Execute(Linting shouldn't happen when ALE is disabled locally):
74   let b:ale_enabled = 0
75   let g:ale_buffer_info = {}
76
77   call ale#Queue(0)
78
79   AssertEqual {}, g:ale_buffer_info
80   call SetUpCursorData()
81   call ale#cursor#EchoCursorWarning()
82   AssertEqual '', GetLastMessage()
83
84 Execute(Linting shouldn't happen when the file is too large with global options):
85   let g:ale_maximum_file_size = 12
86   let g:ale_buffer_info = {}
87
88   call ale#Queue(0)
89
90   AssertEqual {}, g:ale_buffer_info
91   " We shouldn't show cursor warnings.
92   call SetUpCursorData()
93   call ale#cursor#EchoCursorWarning()
94   AssertEqual '', GetLastMessage()
95
96 Execute(Linting shouldn't happen when the file is too large with local options):
97   let b:ale_maximum_file_size = 12
98   let g:ale_buffer_info = {}
99
100   call ale#Queue(0)
101
102   AssertEqual {}, g:ale_buffer_info
103   call SetUpCursorData()
104   call ale#cursor#EchoCursorWarning()
105   AssertEqual '', GetLastMessage()