run 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. mkdir -p "$PLUG_FIXTURES/yyy/rtp/doc"
  70. cat > "$PLUG_FIXTURES/yyy/rtp/doc/yyy.txt" << DOC
  71. hello *yyy*
  72. DOC
  73. gitinit yyy
  74. make_dirs z1/ z1
  75. make_dirs z2/ z2
  76. rm -rf "$PLUG_FIXTURES/ftplugin-msg"
  77. mkdir -p "$PLUG_FIXTURES"/ftplugin-msg/{plugin,ftplugin}
  78. echo "echomsg 'ftplugin-c'" > "$PLUG_FIXTURES/ftplugin-msg/ftplugin/c.vim"
  79. echo "echomsg 'ftplugin-java'" > "$PLUG_FIXTURES/ftplugin-msg/ftplugin/java.vim"
  80. chmod +w "$PLUG_FIXTURES/cant-delete/autoload" || rm -rf "$PLUG_FIXTURES/cant-delete"
  81. mkdir -p "$PLUG_FIXTURES/cant-delete/autoload"
  82. touch "$PLUG_FIXTURES/cant-delete/autoload/cant-delete.vim"
  83. chmod -w "$PLUG_FIXTURES/cant-delete/autoload"
  84. rm -rf $TEMP/new-branch
  85. cd $TEMP
  86. git init new-branch
  87. cd new-branch
  88. mkdir plugin
  89. echo 'let g:foo = 1' > plugin/foo.vim
  90. git add plugin/foo.vim
  91. git commit -m initial
  92. git checkout -b plugin
  93. git checkout master
  94. cd "$BASE"
  95. }
  96. select_vim() {
  97. local vim=/usr/bin/vim
  98. if [ -n "${DEPS:-}" ] && [ -e "${DEPS}/bin/vim" ]; then
  99. vim="${DEPS}/bin/vim"
  100. elif [ -e "/usr/local/bin/vim" ]; then
  101. vim=/usr/local/bin/vim
  102. fi
  103. echo $vim
  104. }
  105. clone_repos
  106. prepare
  107. git --version
  108. vim=$(select_vim)
  109. echo "Selected Vim: $vim"
  110. if [ "${1:-}" = '!' ]; then
  111. FAIL=0
  112. $vim -Nu $TEMP/mini-vimrc -c 'Vader! test.vader' > /dev/null || FAIL=1
  113. prepare
  114. $vim -Nu $TEMP/mini-vimrc -c 'let g:plug_threads = 1 | Vader! test.vader' > /dev/null || FAIL=1
  115. test $FAIL -eq 0
  116. else
  117. $vim -Nu $TEMP/mini-vimrc -c 'Vader test.vader'
  118. fi