]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
fix: correct/refine run test sh script
authorshane.xb.qian <shane.qian@foxmail.com>
Thu, 10 Nov 2022 02:50:58 +0000 (10:50 +0800)
committershane.xb.qian <shane.qian@foxmail.com>
Fri, 11 Nov 2022 16:40:00 +0000 (00:40 +0800)
test/run_tests.sh

index 811604424ff131b04dd1ebf3aa668bb3df846774..67a8182b9f5202b4d63802a169d14d3931c64865 100755 (executable)
@@ -2,7 +2,12 @@
 
 # Script to run the unit-tests for the LSP Vim plugin
 
-VIMPRG=${VIMPRG:=/usr/bin/vim}
+VIMPRG=${VIMPRG:=`which vim`}
+if [ -z "$VIMPRG" ]; then
+  echo "ERROR: Vim is not found or did not indicate."
+  exit 1
+fi
+
 VIM_CMD="$VIMPRG -u NONE -U NONE -i NONE --noplugin -N --not-a-term"
 
 $VIM_CMD -S unit_tests.vim
@@ -10,20 +15,18 @@ $VIM_CMD -S unit_tests.vim
 echo "LSP unit test results:"
 echo
 
-if [ ! -f results.txt ]
-then
-  echo "ERROR: Test results file 'results.txt' is not found"
-  exit 1
+if ! [ -f results.txt ]; then
+  echo "ERROR: Test results file 'results.txt' is not found."
+  exit 2
 fi
 
 cat results.txt
 
 echo
-grep FAIL results.txt > /dev/null 2>&1
-if [ $? -eq 0 ]
-then
+grep -w FAIL results.txt >/dev/null 2>&1
+if [ $? -eq 0 ]; then
   echo "ERROR: Some test(s) failed."
-  exit 1
+  exit 3
 fi
 
 echo "SUCCESS: All the tests passed."