summaryrefslogtreecommitdiff
path: root/vim/pack/downloads/opt/lsp/test/runner.vim
diff options
context:
space:
mode:
authorMarc Coquand <marc@mccd.space>2024-06-30 17:20:44 -0500
committerMarc Coquand <marc@mccd.space>2024-06-30 17:20:44 -0500
commitaeabdffa8870c2b90a32f53c1d0e5b63367a6e27 (patch)
treed3b8e3395cbfc5c9ba4f1dd28ff807f18d582b26 /vim/pack/downloads/opt/lsp/test/runner.vim
parent97ce8456231b997135be6c5f1afaee08eff2cbb1 (diff)
downloadrcm-aeabdffa8870c2b90a32f53c1d0e5b63367a6e27.tar.gz
rcm-aeabdffa8870c2b90a32f53c1d0e5b63367a6e27.tar.bz2
rcm-aeabdffa8870c2b90a32f53c1d0e5b63367a6e27.zip
Vim
Diffstat (limited to 'vim/pack/downloads/opt/lsp/test/runner.vim')
-rw-r--r--vim/pack/downloads/opt/lsp/test/runner.vim55
1 files changed, 55 insertions, 0 deletions
diff --git a/vim/pack/downloads/opt/lsp/test/runner.vim b/vim/pack/downloads/opt/lsp/test/runner.vim
new file mode 100644
index 0000000..14c849a
--- /dev/null
+++ b/vim/pack/downloads/opt/lsp/test/runner.vim
@@ -0,0 +1,55 @@
+vim9script
+# Script to run a language server unit tests
+# The global variable TestName should be set to the name of the file
+# containing the tests.
+
+source common.vim
+
+def LspRunTests()
+ :set nomore
+ :set debug=beep
+ delete('results.txt')
+
+ # Get the list of test functions in this file and call them
+ var fns: list<string> = execute('function /^Test_')
+ ->split("\n")
+ ->map("v:val->substitute('^def ', '', '')")
+ ->sort()
+ if fns->empty()
+ # No tests are found
+ writefile(['No tests are found'], 'results.txt')
+ return
+ endif
+ for f in fns
+ v:errors = []
+ v:errmsg = ''
+ try
+ :%bw!
+ exe $'g:{f}'
+ catch
+ call add(v:errors, $'Error: Test {f} failed with exception {v:exception} at {v:throwpoint}')
+ endtry
+ if v:errmsg != ''
+ call add(v:errors, $'Error: Test {f} generated error {v:errmsg}')
+ endif
+ 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
+enddef
+
+try
+ g:LoadLspPlugin()
+ exe $'source {g:TestName}'
+ g:StartLangServer()
+ LspRunTests()
+catch
+ writefile(['FAIL: Tests in ' .. g:TestName .. ' failed with exception ' .. v:exception .. ' at ' .. v:throwpoint], 'results.txt', 'a')
+endtry
+
+qall!
+
+# vim: shiftwidth=2 softtabstop=2 noexpandtab