]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/vim-lsp-ale/test/integ/test.vimspec

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 'd49e95aa7ba744f0a7f544aca43afdb6aab41f24' as '.vim/bundle/asyncomplete...
[etc/vim.git] / .vim / bundle / vim-lsp-ale / test / integ / test.vimspec
1 let s:SEP = has('win32') ? '\' : '/'
2
3 function! s:get_debug_info(bufnr) abort
4     let uri = lsp#utils#get_buffer_uri(a:bufnr)
5     let all_diags = lsp#internal#diagnostics#state#_get_all_diagnostics_grouped_by_server_for_uri(uri)
6     return "\nall diags: " . string(all_diags)
7        \ . "\nlocation list: " . string(ale#engine#GetLoclist(a:bufnr))
8        \ . "\nserver_status: " . lsp#get_server_status()
9        \ . "\ncurrent lines: " . string(getline(1, '$'))
10 endfunction
11
12 Describe rust-analyzer
13     Before all
14         if !executable('rust-analyzer')
15             throw 'rust-analyzer command is not found. It must be installed for running integration tests'
16         endif
17
18         let dir = IntegTestRootDir()
19         execute 'cd' dir
20         let file = join([dir, 'project', 'src', 'lib.rs'], s:SEP)
21
22         " Note: It might be better to write lib.rs here and delete in `After all` hook rather than
23         " modifying a file committed to repository directly.
24         let lib_rs_contents = readfile(file)
25     End
26
27     After all
28         " Restore contents of lib.rs since it was modified by test case
29         call writefile(lib_rs_contents, file)
30
31         redir! > integ_messages.txt
32             if exists(':LspStatus')
33                 LspStatus
34             else
35                 echom 'No :LspStatus command is defined'
36             endif
37             message
38         redir END
39     End
40
41     Before each
42         execute 'edit!' file
43     End
44
45     After each
46         bwipeout!
47     End
48
49     It shows diagnostics results with ALE through vim-lsp
50         Assert lsp#ale#enabled()
51
52         let bufnr = bufnr('')
53
54         let elapsed = 0 " in seconds
55         let timeout = 120 " in seconds
56         let counts = ale#statusline#Count(bufnr)
57         while elapsed <= timeout
58             if counts.total > 0
59                 break
60             endif
61             sleep 1
62             let elapsed += 1
63             let counts = ale#statusline#Count(bufnr)
64         endwhile
65
66         let info = s:get_debug_info(bufnr)
67         Assert True(counts.total > 0, 'No error found after ' . elapsed . ' seconds' . info)
68
69         let loclist = ale#engine#GetLoclist(bufnr)
70         Assert NotEmpty(loclist, 'Location list from ALE is empty after ' . elapsed . ' seconds. ' . info)
71
72         let item = loclist[0]
73         let item_str = string(item)
74         Assert Equals(item.linter_name, 'vim-lsp', item_str . info)
75         Assert True(item.from_other_source, item_str . info)
76         Assert Match(item.filename, 'lib\.rs$', item_str . info)
77         Assert Match(item.text, 'this_variable_is_unused', item_str . info)
78
79         " Fix the problem
80         normal! ggjdd
81         write
82
83         let elapsed = 0 " in seconds
84         let counts = ale#statusline#Count(bufnr)
85         while elapsed <= timeout
86             if counts.total == 0
87                 break
88             endif
89             sleep 1
90             let elapsed += 1
91             let counts = ale#statusline#Count(bufnr)
92         endwhile
93
94         let info = s:get_debug_info(bufnr)
95         Assert True(counts.total == 0, 'Error found after ' . elapsed . ' seconds' . info)
96
97         " Check the error was removed from location list since it'd been fixed
98         let loclist = ale#engine#GetLoclist(bufnr)
99         Assert Empty(loclist, 'Location list from ALE is not empty after ' . elapsed . ' seconds. ' . info)
100     End
101 End
102
103 " vim: set ft=vim: