]> git.madduck.net Git - etc/vim.git/blobdiff - .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 '294584081929424aec883f90c7d6515b3743358d' as '.vim/bundle/vim-lsp-ale'
[etc/vim.git] / .vim / bundle / vim-lsp-ale / test / integ / test.vimspec
diff --git a/.vim/bundle/vim-lsp-ale/test/integ/test.vimspec b/.vim/bundle/vim-lsp-ale/test/integ/test.vimspec
new file mode 100644 (file)
index 0000000..5ae295b
--- /dev/null
@@ -0,0 +1,103 @@
+let s:SEP = has('win32') ? '\' : '/'
+
+function! s:get_debug_info(bufnr) abort
+    let uri = lsp#utils#get_buffer_uri(a:bufnr)
+    let all_diags = lsp#internal#diagnostics#state#_get_all_diagnostics_grouped_by_server_for_uri(uri)
+    return "\nall diags: " . string(all_diags)
+       \ . "\nlocation list: " . string(ale#engine#GetLoclist(a:bufnr))
+       \ . "\nserver_status: " . lsp#get_server_status()
+       \ . "\ncurrent lines: " . string(getline(1, '$'))
+endfunction
+
+Describe rust-analyzer
+    Before all
+        if !executable('rust-analyzer')
+            throw 'rust-analyzer command is not found. It must be installed for running integration tests'
+        endif
+
+        let dir = IntegTestRootDir()
+        execute 'cd' dir
+        let file = join([dir, 'project', 'src', 'lib.rs'], s:SEP)
+
+        " Note: It might be better to write lib.rs here and delete in `After all` hook rather than
+        " modifying a file committed to repository directly.
+        let lib_rs_contents = readfile(file)
+    End
+
+    After all
+        " Restore contents of lib.rs since it was modified by test case
+        call writefile(lib_rs_contents, file)
+
+        redir! > integ_messages.txt
+            if exists(':LspStatus')
+                LspStatus
+            else
+                echom 'No :LspStatus command is defined'
+            endif
+            message
+        redir END
+    End
+
+    Before each
+        execute 'edit!' file
+    End
+
+    After each
+        bwipeout!
+    End
+
+    It shows diagnostics results with ALE through vim-lsp
+        Assert lsp#ale#enabled()
+
+        let bufnr = bufnr('')
+
+        let elapsed = 0 " in seconds
+        let timeout = 120 " in seconds
+        let counts = ale#statusline#Count(bufnr)
+        while elapsed <= timeout
+            if counts.total > 0
+                break
+            endif
+            sleep 1
+            let elapsed += 1
+            let counts = ale#statusline#Count(bufnr)
+        endwhile
+
+        let info = s:get_debug_info(bufnr)
+        Assert True(counts.total > 0, 'No error found after ' . elapsed . ' seconds' . info)
+
+        let loclist = ale#engine#GetLoclist(bufnr)
+        Assert NotEmpty(loclist, 'Location list from ALE is empty after ' . elapsed . ' seconds. ' . info)
+
+        let item = loclist[0]
+        let item_str = string(item)
+        Assert Equals(item.linter_name, 'vim-lsp', item_str . info)
+        Assert True(item.from_other_source, item_str . info)
+        Assert Match(item.filename, 'lib\.rs$', item_str . info)
+        Assert Match(item.text, 'this_variable_is_unused', item_str . info)
+
+        " Fix the problem
+        normal! ggjdd
+        write
+
+        let elapsed = 0 " in seconds
+        let counts = ale#statusline#Count(bufnr)
+        while elapsed <= timeout
+            if counts.total == 0
+                break
+            endif
+            sleep 1
+            let elapsed += 1
+            let counts = ale#statusline#Count(bufnr)
+        endwhile
+
+        let info = s:get_debug_info(bufnr)
+        Assert True(counts.total == 0, 'Error found after ' . elapsed . ' seconds' . info)
+
+        " Check the error was removed from location list since it'd been fixed
+        let loclist = ale#engine#GetLoclist(bufnr)
+        Assert Empty(loclist, 'Location list from ALE is not empty after ' . elapsed . ' seconds. ' . info)
+    End
+End
+
+" vim: set ft=vim: