workflow.vader 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. Execute (Initialize test environment):
  2. Save &rtp, g:plug_home, $MYVIMRC
  3. let vader = fnamemodify(globpath(&rtp, 'autoload/vader.vim'), ':h:h')
  4. let plug = fnamemodify(globpath(&rtp, 'autoload/plug.vim'), ':h:h')
  5. set rtp=$HOME/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,$HOME/.vim/after
  6. execute 'set rtp^='.vader
  7. execute 'set rtp^='.plug
  8. let basertp = &rtp
  9. unlet! g:plugs
  10. unlet! g:plug_home
  11. set t_Co=256
  12. colo default
  13. let g:vimrc_reloaded = 0
  14. let vimrc = tempname()
  15. call writefile(['let g:vimrc_reloaded += 1'], vimrc)
  16. let $MYVIMRC = vimrc
  17. Execute (plug#end() before plug#begin() should fail):
  18. try
  19. call plug#end()
  20. Assert 0, 'should not reach here'
  21. catch
  22. Assert stridx(v:exception, 'Call plug#begin() first') >= 0
  23. endtry
  24. Execute (plug#begin() without path argument):
  25. call plug#begin()
  26. AssertEqual split(&rtp, ',')[0].'/plugged', g:plug_home
  27. unlet g:plug_home
  28. Execute (plug#begin() without path argument with empty &rtp):
  29. let save_rtp = &rtp
  30. set rtp=
  31. try
  32. call plug#begin()
  33. Assert 0, 'should not reach here'
  34. catch
  35. Assert stridx(v:exception, 'Unable to determine plug home') >= 0, 'Got: '.v:exception
  36. endtry
  37. let &rtp = save_rtp
  38. Execute (plug#begin(path)):
  39. let temp_plugged = tempname()
  40. call plug#begin(temp_plugged.'/')
  41. Assert g:plug_home !~ '[/\\]$', 'Trailing / should be stripped from g:plug_home'
  42. AssertEqual 0, len(g:plugs)
  43. AssertEqual temp_plugged, g:plug_home
  44. AssertEqual basertp, &rtp
  45. Execute (Subsequent plug#begin() calls will reuse g:plug_home):
  46. call plug#begin()
  47. AssertEqual temp_plugged, g:plug_home
  48. Execute (Test Plug command):
  49. " Git repo with branch
  50. Plug 'junegunn/seoul256.vim', 'no-t_co'
  51. AssertEqual 'https://git:@github.com/junegunn/seoul256.vim.git', g:plugs['seoul256.vim'].uri
  52. AssertEqual join([temp_plugged, 'seoul256.vim/'], '/'), g:plugs['seoul256.vim'].dir
  53. AssertEqual 'no-t_co', g:plugs['seoul256.vim'].branch
  54. " Git URI
  55. Plug 'git@github.com:junegunn/vim-emoji.git'
  56. AssertEqual 'git@github.com:junegunn/vim-emoji.git', g:plugs['vim-emoji'].uri
  57. AssertEqual 'master', g:plugs['vim-emoji'].branch
  58. AssertEqual join([temp_plugged, 'vim-emoji/'], '/'), g:plugs['vim-emoji'].dir
  59. " vim-scripts/
  60. Plug 'beauty256'
  61. AssertEqual 'https://git:@github.com/vim-scripts/beauty256.git', g:plugs.beauty256.uri
  62. AssertEqual 'master', g:plugs.beauty256.branch
  63. AssertEqual 3, len(g:plugs)
  64. Execute (Plug command with dictionary option):
  65. Plug 'junegunn/seoul256.vim', { 'branch': 'no-t_co', 'rtp': '././' }
  66. AssertEqual join([temp_plugged, 'seoul256.vim/'], '/'), g:plugs['seoul256.vim'].dir
  67. AssertEqual '././', g:plugs['seoul256.vim'].rtp
  68. AssertEqual 3, len(g:plugs)
  69. Execute (PlugStatus before installation):
  70. PlugStatus
  71. AssertEqual 3, len(filter(getline(1, line('$')), 'v:val =~ "Not found"'))
  72. q
  73. Execute (PlugClean before installation):
  74. PlugClean
  75. AssertEqual 1, len(filter(getline(1, line('$')), 'v:val =~ "Already clean"'))
  76. q
  77. Execute (plug#end() updates &rtp):
  78. call plug#end()
  79. Assert len(&rtp) > len(basertp)
  80. Execute (Yet, plugins are not available):
  81. Assert empty(globpath(&rtp, 'autoload/emoji.vim'))
  82. Execute (PlugInstall):
  83. PlugInstall
  84. AssertEqual 1, g:vimrc_reloaded
  85. q
  86. Execute (Plugin available after installation):
  87. Assert !empty(globpath(&rtp, 'autoload/emoji.vim'))
  88. Execute (PlugClean after installation):
  89. PlugClean
  90. AssertEqual 1, len(filter(getline(1, line('$')), 'v:val =~ "Already clean"'))
  91. q
  92. Execute (PlugStatus after installation):
  93. PlugStatus
  94. AssertEqual 3, len(filter(getline(1, line('$')), 'v:val =~ "OK"'))
  95. q
  96. Execute (Change branch of seoul256.vim):
  97. call plug#begin()
  98. Plug 'junegunn/seoul256.vim'
  99. Plug 'git@github.com:junegunn/vim-emoji.git'
  100. call plug#end()
  101. Execute (PlugStatus):
  102. PlugStatus
  103. %y
  104. q
  105. normal! P
  106. %sort
  107. g/^$/d
  108. Expect:
  109. Invalid branch: no-t_co. Try PlugUpdate.
  110. - vim-emoji: OK
  111. Finished. 1 error(s).
  112. [==]
  113. x seoul256.vim:
  114. Execute (Change URI of seoul256.vim):
  115. call plug#begin()
  116. Plug 'junegunn.choi/seoul256.vim'
  117. Plug 'git@github.com:junegunn/vim-emoji.git'
  118. call plug#end()
  119. Execute (PlugStatus):
  120. PlugStatus
  121. %y
  122. q
  123. normal! P
  124. %sort
  125. g/^$/d
  126. Expect:
  127. Expected: https://git:@github.com/junegunn.choi/seoul256.vim.git
  128. Invalid URI: https://git:@github.com/junegunn/seoul256.vim.git
  129. PlugClean required.
  130. - vim-emoji: OK
  131. Finished. 1 error(s).
  132. [==]
  133. x seoul256.vim:
  134. # TODO: does not work due to inputsave()
  135. # Do (PlugClean):
  136. # :PlugClean\<Enter>y\<Enter>
  137. # ggyG
  138. # q
  139. # PGdd
  140. Execute (PlugClean! to remove seoul256.vim):
  141. PlugClean!
  142. AssertEqual 1, len(filter(getline(1, line('$')), 'v:val =~ "Removed"'))
  143. Assert empty(globpath(&rtp, 'colors/seoul256.vim'))
  144. Assert !empty(globpath(&rtp, 'autoload/emoji.vim'))
  145. q
  146. Execute (Change GIT URI of vim-emoji):
  147. call plug#begin()
  148. Plug 'junegunn/seoul256.vim'
  149. Plug 'junegunn/vim-emoji'
  150. call plug#end()
  151. Execute (PlugStatus):
  152. PlugStatus
  153. %y
  154. q
  155. normal! P
  156. %sort
  157. g/^$/d
  158. Expect:
  159. Expected: https://git:@github.com/junegunn/vim-emoji.git
  160. Invalid URI: git@github.com:junegunn/vim-emoji.git
  161. Not found. Try PlugInstall.
  162. PlugClean required.
  163. Finished. 2 error(s).
  164. [==]
  165. x seoul256.vim:
  166. x vim-emoji:
  167. Execute (PlugClean! to remove vim-emoji):
  168. PlugClean!
  169. AssertEqual 1, len(filter(getline(1, line('$')), 'v:val =~ "Removed"'))
  170. Assert empty(globpath(&rtp, 'colors/seoul256.vim'))
  171. Assert empty(globpath(&rtp, 'autoload/emoji.vim'))
  172. q
  173. Execute (PlugUpdate to install both again):
  174. PlugUpdate
  175. AssertEqual 2, len(filter(getline(1, line('$')), 'v:val =~ "Cloning into"'))
  176. AssertEqual 2, g:vimrc_reloaded
  177. Assert !empty(globpath(&rtp, 'colors/seoul256.vim')), 'seoul256.vim should be found'
  178. Assert !empty(globpath(&rtp, 'autoload/emoji.vim')), 'vim-emoji should be found'
  179. q
  180. Execute (PlugUpdate only to find out plugins are up-to-date):
  181. PlugUpdate
  182. AssertEqual 2, len(filter(getline(1, line('$')), 'v:val =~ "Already up-to-date"'))
  183. AssertEqual 3, g:vimrc_reloaded
  184. q
  185. Execute (Cleanup):
  186. call system('rm -rf '.temp_plugged)
  187. unlet g:plugs
  188. unlet g:plug_home
  189. unlet g:vimrc_reloaded
  190. unlet temp_plugged vader plug basertp save_rtp
  191. Restore
  192. source $MYVIMRC