workflow.vader 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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. silent! unlet g:plugs
  10. silent! 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#begin() without path argument):
  18. call plug#begin()
  19. AssertEqual split(&rtp, ',')[0].'/plugged', g:plug_home
  20. unlet g:plug_home
  21. Execute (plug#begin(path)):
  22. let temp_plugged = tempname()
  23. call plug#begin(temp_plugged.'/')
  24. Assert g:plug_home !~ '[/\\]$', 'Trailing / should be stripped from g:plug_home'
  25. AssertEqual 0, len(g:plugs)
  26. AssertEqual temp_plugged, g:plug_home
  27. AssertEqual basertp, &rtp
  28. Execute (Subsequent plug#begin() calls will reuse g:plug_home):
  29. call plug#begin()
  30. AssertEqual temp_plugged, g:plug_home
  31. Execute (Test Plug command):
  32. " Git repo with branch
  33. Plug 'junegunn/seoul256.vim', 'no-t_co'
  34. AssertEqual 'https://git:@github.com/junegunn/seoul256.vim.git', g:plugs['seoul256.vim'].uri
  35. AssertEqual join([temp_plugged, 'seoul256.vim/'], '/'), g:plugs['seoul256.vim'].dir
  36. AssertEqual 'no-t_co', g:plugs['seoul256.vim'].branch
  37. " Git URI
  38. Plug 'git@github.com:junegunn/vim-emoji.git'
  39. AssertEqual 'git@github.com:junegunn/vim-emoji.git', g:plugs['vim-emoji'].uri
  40. AssertEqual 'master', g:plugs['vim-emoji'].branch
  41. AssertEqual join([temp_plugged, 'vim-emoji/'], '/'), g:plugs['vim-emoji'].dir
  42. " vim-scripts/
  43. Plug 'beauty256'
  44. AssertEqual 'https://git:@github.com/vim-scripts/beauty256.git', g:plugs.beauty256.uri
  45. AssertEqual 'master', g:plugs.beauty256.branch
  46. AssertEqual 3, len(g:plugs)
  47. Execute (Plug command with dictionary option):
  48. Plug 'junegunn/seoul256.vim', { 'branch': 'no-t_co', 'rtp': '././' }
  49. AssertEqual join([temp_plugged, 'seoul256.vim/'], '/'), g:plugs['seoul256.vim'].dir
  50. AssertEqual '././', g:plugs['seoul256.vim'].rtp
  51. AssertEqual 3, len(g:plugs)
  52. Execute (PlugStatus before installation):
  53. PlugStatus
  54. AssertEqual 3, len(filter(getline(1, line('$')), 'v:val =~ "Not found"'))
  55. q
  56. Execute (PlugClean before installation):
  57. PlugClean
  58. AssertEqual 1, len(filter(getline(1, line('$')), 'v:val =~ "Already clean"'))
  59. q
  60. Execute (plug#end() updates &rtp):
  61. call plug#end()
  62. Assert len(&rtp) > len(basertp)
  63. Execute (Yet, plugins are not available):
  64. Assert empty(globpath(&rtp, 'autoload/emoji.vim'))
  65. Execute (PlugInstall):
  66. PlugInstall
  67. AssertEqual 1, g:vimrc_reloaded
  68. q
  69. Execute (Plugin available after installation):
  70. Assert !empty(globpath(&rtp, 'autoload/emoji.vim'))
  71. Execute (PlugClean after installation):
  72. PlugClean
  73. AssertEqual 1, len(filter(getline(1, line('$')), 'v:val =~ "Already clean"'))
  74. q
  75. Execute (PlugStatus after installation):
  76. PlugStatus
  77. AssertEqual 3, len(filter(getline(1, line('$')), 'v:val =~ "OK"'))
  78. q
  79. Execute (Change branch of seoul256.vim):
  80. call plug#begin()
  81. Plug 'junegunn/seoul256.vim'
  82. Plug 'git@github.com:junegunn/vim-emoji.git'
  83. call plug#end()
  84. Execute (PlugStatus):
  85. PlugStatus
  86. %y
  87. q
  88. normal! P
  89. %sort
  90. g/^$/d
  91. Expect:
  92. Invalid branch: no-t_co. Try PlugUpdate.
  93. - vim-emoji: OK
  94. Finished. 1 error(s).
  95. x seoul256.vim:
  96. Execute (Change URI of seoul256.vim):
  97. call plug#begin()
  98. Plug 'junegunn.choi/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. Expected: https://git:@github.com/junegunn.choi/seoul256.vim.git
  110. Invalid URI: https://git:@github.com/junegunn/seoul256.vim.git
  111. PlugClean required.
  112. - vim-emoji: OK
  113. Finished. 1 error(s).
  114. x seoul256.vim:
  115. # TODO: does not work due to inputsave()
  116. # Do (PlugClean):
  117. # :PlugClean\<Enter>y\<Enter>
  118. # ggyG
  119. # q
  120. # PGdd
  121. Execute (PlugClean! to remove seoul256.vim):
  122. PlugClean!
  123. AssertEqual 1, len(filter(getline(1, line('$')), 'v:val =~ "Removed"'))
  124. Assert empty(globpath(&rtp, 'colors/seoul256.vim'))
  125. Assert !empty(globpath(&rtp, 'autoload/emoji.vim'))
  126. q
  127. Execute (Change GIT URI of vim-emoji):
  128. call plug#begin()
  129. Plug 'junegunn/seoul256.vim'
  130. Plug 'junegunn/vim-emoji'
  131. call plug#end()
  132. Execute (PlugStatus):
  133. PlugStatus
  134. %y
  135. q
  136. normal! P
  137. %sort
  138. g/^$/d
  139. Expect:
  140. Expected: https://git:@github.com/junegunn/vim-emoji.git
  141. Invalid URI: git@github.com:junegunn/vim-emoji.git
  142. Not found. Try PlugInstall.
  143. PlugClean required.
  144. Finished. 2 error(s).
  145. x seoul256.vim:
  146. x vim-emoji:
  147. Execute (PlugClean! to remove vim-emoji):
  148. PlugClean!
  149. AssertEqual 1, len(filter(getline(1, line('$')), 'v:val =~ "Removed"'))
  150. Assert empty(globpath(&rtp, 'colors/seoul256.vim'))
  151. Assert empty(globpath(&rtp, 'autoload/emoji.vim'))
  152. q
  153. Execute (PlugUpdate to install both again):
  154. PlugUpdate
  155. AssertEqual 2, len(filter(getline(1, line('$')), 'v:val =~ "Cloning into"'))
  156. AssertEqual 2, g:vimrc_reloaded
  157. Assert !empty(globpath(&rtp, 'colors/seoul256.vim')), 'seoul256.vim should be found'
  158. Assert !empty(globpath(&rtp, 'autoload/emoji.vim')), 'vim-emoji should be found'
  159. q
  160. Execute (PlugUpdate only to find out plugins are up-to-date):
  161. PlugUpdate
  162. AssertEqual 2, len(filter(getline(1, line('$')), 'v:val =~ "Already up-to-date"'))
  163. AssertEqual 3, g:vimrc_reloaded
  164. q
  165. Execute (Cleanup):
  166. call system('rm -rf '.temp_plugged)
  167. unlet g:plugs
  168. unlet g:plug_home
  169. unlet g:vimrc_reloaded
  170. unlet temp_plugged vader plug basertp
  171. Restore
  172. source $MYVIMRC