]> Sergey Matveev's repositories - vim-lsp.git/blob - test/run_tests.sh
625ba6f863366a17e57434da2264c2c2105f1049
[vim-lsp.git] / test / run_tests.sh
1 #!/bin/bash
2
3 # Script to run the unit-tests for the LSP Vim plugin
4
5 VIMPRG=${VIMPRG:=$(which vim)}
6 if [ -z "$VIMPRG" ]; then
7   echo "ERROR: vim (\$VIMPRG) is not found in PATH"
8   exit 1
9 fi
10
11 VIM_CMD="$VIMPRG -u NONE -U NONE -i NONE --noplugin -N --not-a-term"
12
13 TESTS="clangd_tests.vim tsserver_tests.vim gopls_tests.vim not_lspserver_related_tests.vim"
14
15 RunTestsInFile() {
16     testfile=$1
17     echo "Running tests in $testfile"
18     $VIM_CMD -c "let g:TestName='$testfile'" -S runner.vim
19
20     if ! [ -f results.txt ]; then
21       echo "ERROR: Test results file 'results.txt' is not found."
22       exit 2
23     fi
24
25     cat results.txt
26
27     if grep -qw FAIL results.txt; then
28       echo "ERROR: Some test(s) in $testfile failed."
29       exit 3
30     fi
31
32     echo "SUCCESS: All the tests in $testfile passed."
33     echo
34 }
35
36 for testfile in $TESTS
37 do
38     RunTestsInFile $testfile
39 done
40
41 for encoding in "utf-8" "utf-16" "utf-32"
42 do
43     export LSP_OFFSET_ENCODING=$encoding
44     echo "LSP offset encoding: $LSP_OFFSET_ENCODING"
45     RunTestsInFile clangd_offsetencoding.vim
46 done
47
48 echo "SUCCESS: All the tests passed."
49 exit 0