--- /dev/null
+@echo off
+
+REM Script to run the unit-tests for the LSP Vim plugin on MS-Windows
+
+SETLOCAL
+SET VIMPRG="vim.exe"
+SET VIM_CMD=%VIMPRG% -u NONE -U NONE -i NONE --noplugin -N
+
+%VIM_CMD% -S unit_tests.vim
+
+echo LSP unit test results
+type results.txt
+
+findstr /I FAIL results.txt > nul 2>&1
+if %ERRORLEVEL% EQU 0 echo ERROR: Some test failed.
+if %ERRORLEVEL% NEQ 0 echo SUCCESS: All the tests passed.
+
--- /dev/null
+#!/bin/bash
+
+# Script to run the unit-tests for the LSP Vim plugin
+
+VIMPRG=${VIMPRG:=/usr/bin/vim}
+VIM_CMD="$VIMPRG -u NONE -U NONE -i NONE --noplugin -N"
+
+$VIM_CMD -S unit_tests.vim
+
+echo "LSP unit test results:"
+echo
+cat results.txt
+
+echo
+grep FAIL results.txt > /dev/null 2>&1
+if [ $? -eq 0 ]
+then
+ echo "ERROR: Some test(s) failed."
+ exit 1
+fi
+
+echo "SUCCESS: All the tests passed."
+exit 0
vim9script
-# Tests for Vim Language Server Protocol (LSP) client
-# To run the tests, just source this file
+# Unit tests for Vim Language Server Protocol (LSP) client
+
+syntax on
+filetype on
+filetype plugin on
+filetype indent on
+
+set rtp+=../
+source ../plugin/lsp.vim
+var lspServers = [{
+ filetype: ['c', 'cpp'],
+ path: '/usr/bin/clangd',
+ args: ['--background-index', '--clang-tidy']
+ }]
+lsp#addServer(lspServers)
g:LSPTest = true
enddef
def LspRunTests()
+ :set nomore
+ :set debug=beep
+ delete('results.txt')
+
# Edit a dummy C file to start the LSP server
:edit Xtest.c
:sleep 500m
if v:errmsg != ''
call add(v:errors, "Error: Test " .. f .. " generated error " .. v:errmsg)
endif
- if v:errors->len() != 0
- new Lsp-Test-Results
- setline(1, ["Error: Test " .. f .. " failed"]->extend(v:errors))
- setbufvar('', '&modified', 0)
- return
+ if !v:errors->empty()
+ writefile(v:errors, 'results.txt', 'a')
+ writefile([f .. ': FAIL'], 'results.txt', 'a')
+ else
+ writefile([f .. ': pass'], 'results.txt', 'a')
endif
endfor
-
- echomsg "Success: All the LSP tests have passed"
enddef
LspRunTests()
+qall!
# vim: shiftwidth=2 softtabstop=2 noexpandtab