run 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #!/bin/bash
  2. cd $(dirname "${BASH_SOURCE[0]}")
  3. export BASE="$PWD"
  4. export PLUG_SRC="$PWD/../plug.vim"
  5. export PLUG_FIXTURES="$PWD/fixtures"
  6. mkdir -p "$PLUG_FIXTURES"
  7. export TEMP=/tmp/vim-plug-test
  8. rm -rf "$TEMP"
  9. mkdir -p "$TEMP"
  10. cat > $TEMP/mini-vimrc << VIMRC
  11. set rtp+=$TEMP/junegunn/vader.vim
  12. set shell=/bin/bash
  13. VIMRC
  14. clone() {
  15. if [ ! -d $2 ]; then
  16. git clone $1 $2
  17. fi
  18. }
  19. clone_repos() (
  20. cd $TEMP
  21. mkdir -p junegunn vim-scripts jg
  22. for repo in vader.vim goyo.vim rust.vim seoul256.vim vim-easy-align vim-fnr \
  23. vim-oblique vim-pseudocl vim-redis vim-emoji; do
  24. clone https://github.com/junegunn/${repo}.git junegunn/$repo &
  25. done
  26. clone https://github.com/vim-scripts/beauty256.git vim-scripts/beauty256 &
  27. clone https://github.com/junegunn/fzf.git fzf &
  28. clone https://github.com/yous/subsubmodule.git yous/subsubmodule && \
  29. (cd yous/subsubmodule && git submodule update --init --recursive &) &
  30. wait
  31. clone junegunn/vim-emoji jg/vim-emoji
  32. cd junegunn/seoul256.vim && git checkout no-t_co && git checkout master
  33. )
  34. make_dirs() (
  35. rm -rf "$PLUG_FIXTURES/$1"
  36. mkdir -p "$PLUG_FIXTURES/$1"
  37. cd "$PLUG_FIXTURES/$1"
  38. mkdir -p autoload colors ftdetect ftplugin indent plugin syntax
  39. for d in *; do
  40. [ -d $d ] || continue
  41. cat > $d/xxx.vim << EOF
  42. " echom expand('<sfile>')
  43. let g:total_order = get(g:, 'total_order', [])
  44. let g:$2 = get(g:, '$2', [])
  45. let s:name = join(filter(['$2', '${1:4}', '$d'], '!empty(v:val)'), '/')
  46. call add(g:$2, s:name)
  47. call add(g:total_order, s:name)
  48. EOF
  49. done
  50. )
  51. gitinit() (
  52. cd "$PLUG_FIXTURES/$1"
  53. git init
  54. git commit -m 'commit' --allow-empty
  55. )
  56. prepare() {
  57. make_dirs xxx/ xxx
  58. make_dirs xxx/after xxx
  59. mkdir -p "$PLUG_FIXTURES/xxx/doc"
  60. cat > "$PLUG_FIXTURES/xxx/doc/xxx.txt" << DOC
  61. hello *xxx*
  62. DOC
  63. gitinit xxx
  64. make_dirs yyy/ yyy
  65. make_dirs yyy/after yyy
  66. gitinit yyy
  67. make_dirs z1/ z1
  68. make_dirs z2/ z2
  69. rm -rf "$PLUG_FIXTURES/ftplugin-msg"
  70. mkdir -p "$PLUG_FIXTURES/ftplugin-msg/ftplugin"
  71. echo "echomsg 'ftplugin-c'" > "$PLUG_FIXTURES/ftplugin-msg/ftplugin/c.vim"
  72. echo "echomsg 'ftplugin-java'" > "$PLUG_FIXTURES/ftplugin-msg/ftplugin/java.vim"
  73. rm -rf $TEMP/new-branch
  74. cd $TEMP
  75. git init new-branch
  76. cd new-branch
  77. mkdir plugin
  78. echo 'let g:foo = 1' > plugin/foo.vim
  79. git add plugin/foo.vim
  80. git commit -m initial
  81. cd "$BASE"
  82. }
  83. select_vim() {
  84. local vim=/usr/bin/vim
  85. if [ -n "$DEPS" ] && [ -e "${DEPS}/bin/vim" ]; then
  86. vim="${DEPS}/bin/vim"
  87. elif [ -e "/usr/local/bin/vim" ]; then
  88. vim=/usr/local/bin/vim
  89. fi
  90. echo $vim
  91. }
  92. clone_repos
  93. prepare
  94. git --version
  95. VIM=$(select_vim)
  96. echo "Selected Vim: $VIM"
  97. if [ "$1" = '!' ]; then
  98. $VIM -Nu $TEMP/mini-vimrc -c 'Vader! test.vader' > /dev/null &&
  99. prepare &&
  100. $VIM -Nu $TEMP/mini-vimrc -c 'let g:plug_threads = 1 | Vader! test.vader' > /dev/null
  101. else
  102. $VIM -Nu $TEMP/mini-vimrc -c 'Vader test.vader'
  103. fi