run_vim_tests 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #!/usr/bin/env bash
  2. if [ "$1" == "--help" ]; then
  3. echo "$(basename $0) <optional list of tests in form file:func>"
  4. echo "e.g.: "
  5. echo " - run all tests: $0"
  6. echo " - run specific tests script: $0 signature_help.test.vim"
  7. echo " - run specific tests fun: $0 signature_help.test.vim:Test_signatures_TopLine\(\)"
  8. exit 0
  9. elif [ "$1" == "--stdout" ]; then
  10. export YCM_TEST_STDOUT=1
  11. shift
  12. fi
  13. VIM=vim
  14. if [ "$1" == "--vim" ]; then
  15. VIM=$2
  16. shift
  17. shift
  18. fi
  19. RUN_VIM="${VIM} --clean --not-a-term"
  20. RUN_TEST="${RUN_VIM} -S lib/run_test.vim"
  21. pushd $(dirname $0) > /dev/null
  22. echo "Running YouCompleteMe Vim tests"
  23. RESULT=0
  24. TESTS="$@"
  25. if [ -z "$TESTS" ]; then
  26. TESTS=*.test.vim
  27. fi
  28. for t in ${TESTS}; do
  29. echo ""
  30. echo "%RUN: $t"
  31. # split on : into fileName and testName
  32. IFS=: read -s t T <<< "$t"
  33. TESTLOGDIR=$(pwd)/logs/$t
  34. if ${RUN_TEST} --cmd 'au SwapExists * let v:swapchoice = "e"' $t $T \
  35. && [ -f $t.res ]; then
  36. echo "%PASS: $t PASSED"
  37. else
  38. echo "%FAIL: $t FAILED - see $TESTLOGDIR"
  39. RESULT=1
  40. fi
  41. rm -rf $TESTLOGDIR
  42. mkdir -p $TESTLOGDIR
  43. ${RUN_VIM} --version > ${TESTLOGDIR}/vimversion
  44. for l in messages debuglog test.log *.testlog; do
  45. # In CI we can't view the output files, so we just have to cat them
  46. if [ -f $l ]; then
  47. if [ "$YCM_TEST_STDOUT" ]; then
  48. echo ""
  49. echo ""
  50. echo "*** START: $l ***"
  51. cat $l
  52. echo "*** END: $l ***"
  53. fi
  54. mv $l $TESTLOGDIR
  55. fi
  56. done
  57. if [ -n "${COVERAGE}" ]; then
  58. covimerage write_coverage --append \
  59. --source $(pwd)/.. \
  60. --data-file .coverage.vim \
  61. .vim_profile
  62. fi
  63. rm -f $t.res
  64. done
  65. echo "Done running tests"
  66. if [ -n "${COVERAGE}" ]; then
  67. mv .coverage.* ../
  68. fi
  69. popd > /dev/null
  70. echo ""
  71. echo "All done."
  72. exit $RESULT