You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

143 lines
2.9 KiB

  1. #!/usr/bin/env bash
  2. set -e
  3. set -u
  4. # Author: w0rp <devw0rp@gmail.com>
  5. #
  6. # This script runs tests for the ALE project. The following options are
  7. # accepted:
  8. #
  9. # -v Enable verbose output
  10. # --neovim-only Run tests only for NeoVim
  11. # --vim-only Run tests only for Vim
  12. current_image_id=d5a1b5915b09
  13. image=w0rp/ale
  14. tests='test/*.vader test/*/*.vader test/*/*/*.vader test/*/*/*.vader'
  15. # These flags are forwarded to the script for running Vader tests.
  16. verbose_flag=''
  17. quiet_flag=''
  18. run_neovim_tests=1
  19. run_vim_tests=1
  20. run_vint=1
  21. run_custom_checks=1
  22. while [ $# -ne 0 ]; do
  23. case $1 in
  24. -v)
  25. verbose_flag='-v'
  26. shift
  27. ;;
  28. -q)
  29. quiet_flag='-q'
  30. shift
  31. ;;
  32. --neovim-only)
  33. run_vim_tests=0
  34. run_vint=0
  35. run_custom_checks=0
  36. shift
  37. ;;
  38. --vim-only)
  39. run_neovim_tests=0
  40. run_vint=0
  41. run_custom_checks=0
  42. shift
  43. ;;
  44. --no-vint)
  45. run_vint=0
  46. shift
  47. ;;
  48. --vint-only)
  49. run_vim_tests=0
  50. run_neovim_tests=0
  51. run_custom_checks=0
  52. shift
  53. ;;
  54. --no-custom-checks)
  55. run_custom_checks=0
  56. shift
  57. ;;
  58. --custom-checks-only)
  59. run_vim_tests=0
  60. run_neovim_tests=0
  61. run_vint=0
  62. shift
  63. ;;
  64. --)
  65. shift
  66. break
  67. ;;
  68. -?*)
  69. echo "Invalid argument: $1" 1>&2
  70. exit 1
  71. ;;
  72. *)
  73. break
  74. ;;
  75. esac
  76. done
  77. # Allow tests to be passed as arguments.
  78. if [ $# -ne 0 ]; then
  79. # This doesn't perfectly handle work splitting, but none of our files
  80. # have spaces in the names.
  81. tests="$*"
  82. fi
  83. # Delete .swp files in the test directory, which cause Vim 8 to hang.
  84. find test -name '*.swp' -delete
  85. docker images -q w0rp/ale | grep "^$current_image_id" > /dev/null \
  86. || docker pull "$image"
  87. output_dir=$(mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir')
  88. trap '{ rm -rf "$output_dir"; }' EXIT
  89. file_number=0
  90. pid_list=''
  91. for vim in $(docker run --rm "$image" ls /vim-build/bin | grep '^neovim\|^vim' ); do
  92. if ((run_vim_tests)) || [[ $vim =~ ^neovim ]] && ((run_neovim_tests)); then
  93. echo "Starting Vim: $vim..."
  94. file_number=$((file_number+1))
  95. test/script/run-vader-tests $quiet_flag $verbose_flag "$vim" "$tests" \
  96. > "$output_dir/$file_number" 2>&1 &
  97. pid_list="$pid_list $!"
  98. fi
  99. done
  100. if ((run_vint)); then
  101. echo "Starting Vint..."
  102. file_number=$((file_number+1))
  103. test/script/run-vint > "$output_dir/$file_number" 2>&1 &
  104. pid_list="$pid_list $!"
  105. fi
  106. if ((run_custom_checks)); then
  107. echo "Starting Custom checks..."
  108. file_number=$((file_number+1))
  109. test/script/custom-checks &> "$output_dir/$file_number" 2>&1 &
  110. pid_list="$pid_list $!"
  111. fi
  112. echo
  113. failed=0
  114. index=0
  115. for pid in $pid_list; do
  116. index=$((index+1))
  117. if ! wait "$pid"; then
  118. failed=1
  119. fi
  120. cat "$output_dir/$index"
  121. done
  122. exit $failed