run 3.0 KB

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