regressions.vader 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. **********************************************************************
  2. Execute (#112 On-demand loading should not suppress messages from ftplugin):
  3. call ResetPlug()
  4. call plug#begin('$PLUG_FIXTURES')
  5. Plug '$PLUG_FIXTURES/ftplugin-msg', { 'for': 'c' }
  6. call plug#end()
  7. redir => out
  8. tabnew a.c
  9. redir END
  10. Assert stridx(out, 'ftplugin-c') >= 0, 'Unexpected output (1): '.out
  11. * The same applies to plug#load())
  12. call ResetPlug()
  13. redir => out
  14. call plug#load('ftplugin-msg')
  15. redir END
  16. Assert stridx(out, 'ftplugin-c') >= 0, 'Unexpected output (2): '.out
  17. q
  18. **********************************************************************
  19. Execute (#114 Should not contain empty path in &rtp):
  20. call plug#begin('/tmp/vim-plug-test/plugged')
  21. call plug#end()
  22. Log &rtp
  23. Assert &rtp !~ ',,', 'Commas'
  24. Assert &rtp !~ '^,', 'Comma prefix'
  25. Assert &rtp !~ ',$', 'Comma suffix'
  26. **********************************************************************
  27. Execute (#130 Proper cleanup of on-demand loading triggers):
  28. augroup PlugLOD
  29. autocmd!
  30. augroup END
  31. " Cleared on command
  32. call ReloadPlug()
  33. call plug#begin('/tmp/vim-plug-test/plugged')
  34. Plug 'junegunn/vim-emoji', { 'on': ['EmojiCommand', 'EmojiCommand2', '<Plug>(EmojiMapping)'] }
  35. call plug#end()
  36. PlugInstall | q
  37. call mkdir(g:plugs['vim-emoji'].dir.'/after/plugin', 'p')
  38. Assert exists(':EmojiCommand'), 'EmojiCommand not defined'
  39. Assert exists(':EmojiCommand2'), 'EmojiCommand2 not defined'
  40. Assert !empty(mapcheck('<Plug>(EmojiMapping)')), '<Plug>(EmojiMapping) not defined'
  41. silent! EmojiCommand
  42. Assert !exists(':EmojiCommand'), 'EmojiCommand defined'
  43. Assert !exists(':EmojiCommand2'), 'EmojiCommand2 defined'
  44. Assert empty(mapcheck('<Plug>(EmojiMapping)')), '<Plug>(EmojiMapping) defined'
  45. " Cleared on FileType
  46. call ReloadPlug()
  47. call plug#begin('/tmp/vim-plug-test/plugged')
  48. Plug 'junegunn/vim-emoji', { 'on': ['EmojiCommandExtra', '<Plug>(EmojiMappingExtra)'], 'for': ['emoji'] }
  49. call plug#end()
  50. Assert exists(':EmojiCommandExtra'), 'EmojiCommandExtra not defined'
  51. Assert !empty(mapcheck('<Plug>(EmojiMappingExtra)')), '<Plug>(EmojiMappingExtra) not defined'
  52. setf emoji
  53. Assert !exists(':EmojiCommandExtra'), 'EmojiCommandExtra defined'
  54. Assert empty(mapcheck('<Plug>(EmojiMappingExtra)')), '<Plug>(EmojiMappingExtra) defined'
  55. **********************************************************************
  56. Execute (#131 Syntax error):
  57. call plug#begin('/proc/no-permission')
  58. Plug 'junegunn/vim-emoji'
  59. call plug#end()
  60. redir => out
  61. silent PlugInstall
  62. redir END
  63. Assert out =~ 'Invalid plug directory: /proc/no-permission', out
  64. **********************************************************************
  65. Execute (#139-1 Using new remote branch):
  66. " Make sure to remove the clone
  67. call plug#begin('/tmp/vim-plug-test/plugged')
  68. call plug#end()
  69. PlugClean!
  70. " Install master branch
  71. call plug#begin('/tmp/vim-plug-test/plugged')
  72. Plug expand('file:////tmp/vim-plug-test/new-branch')
  73. call plug#end()
  74. PlugUpdate
  75. unlet! g:foo g:bar g:baz
  76. call ResetPlug()
  77. call plug#load('new-branch')
  78. Assert exists('g:foo'), 'g:foo should be found (1)'
  79. Assert !exists('g:bar'), 'g:bar should not be found (1)'
  80. Assert !exists('g:baz'), 'g:baz should not be found (1)'
  81. " Create a new branch on origin
  82. call system('cd /tmp/vim-plug-test/new-branch && git checkout -b new &&'
  83. \. 'echo "let g:bar = 1" > plugin/bar.vim && git add plugin/bar.vim &&'
  84. \. 'git commit -m second')
  85. " We're setting up two plugins so that parallel installer is used
  86. call plug#begin('/tmp/vim-plug-test/plugged')
  87. Plug 'junegunn/seoul256.vim'
  88. Plug expand('file:////tmp/vim-plug-test/new-branch'), { 'branch': 'new' }
  89. call plug#end()
  90. PlugUpdate
  91. silent %y
  92. Log @"
  93. Assert @" !~? 'error', 'Should be able to use new remote branch: ' . @"
  94. unlet! g:foo g:bar g:baz
  95. call ResetPlug()
  96. call plug#load('new-branch')
  97. Assert exists('g:foo'), 'g:foo should be found (2)'
  98. Assert exists('g:bar'), 'g:bar should be found (2)'
  99. Assert !exists('g:baz'), 'g:baz should not be found (2)'
  100. call PlugStatusSorted()
  101. Expect:
  102. - new-branch: OK
  103. - seoul256.vim: OK
  104. Finished. 0 error(s).
  105. [==]
  106. Execute (#139-2 Using yet another new remote branch):
  107. " Create another branch on origin
  108. call system('cd /tmp/vim-plug-test/new-branch && git checkout master &&'
  109. \. 'git checkout -b brand-new &&'
  110. \. 'echo "let g:baz = 1" > plugin/baz.vim && git add plugin/baz.vim &&'
  111. \. 'git commit -m third')
  112. " Test Vim installer here
  113. call plug#begin('/tmp/vim-plug-test/plugged')
  114. Plug expand('file:////tmp/vim-plug-test/new-branch'), { 'branch': 'brand-new' }
  115. call plug#end()
  116. PlugUpdate
  117. silent %y
  118. Log @"
  119. Assert @" !~? 'error', 'Should be able to use new remote branch: ' . @"
  120. unlet! g:foo g:bar g:baz
  121. call ResetPlug()
  122. call plug#load('new-branch')
  123. Assert exists('g:foo'), 'g:foo should be found'
  124. Assert !exists('g:bar'), 'g:bar should not be found'
  125. Assert exists('g:baz'), 'g:baz should be found'
  126. call PlugStatusSorted()
  127. Expect:
  128. - new-branch: OK
  129. Finished. 0 error(s).
  130. [=]
  131. Execute (#139-3 Should fail when not possible to fast-forward):
  132. " Commit on cloned repo
  133. call system('cd /tmp/vim-plug-test/plugged/new-branch && git checkout master &&'
  134. \. 'touch foobar && git add foobar && git commit -m foobar')
  135. " Different commit on remote
  136. call system('cd /tmp/vim-plug-test/new-branch && git checkout master &&'
  137. \. 'touch foobaz && git add foobaz && git commit -m foobaz')
  138. for multi in [0, 1]
  139. call plug#begin('/tmp/vim-plug-test/plugged')
  140. if multi
  141. Plug 'junegunn/seoul256.vim'
  142. endif
  143. Plug expand('file:////tmp/vim-plug-test/new-branch')
  144. call plug#end()
  145. PlugUpdate
  146. silent %y
  147. Assert @" =~ 'Not possible to fast-forward', @"
  148. endfor
  149. q
  150. **********************************************************************
  151. Execute (#145: Merging on-demand loading triggers - cmd):
  152. unlet! g:xxx g:yyy
  153. call plug#begin()
  154. Plug '$PLUG_FIXTURES/xxx', { 'on': 'XXX' }
  155. Plug '$PLUG_FIXTURES/yyy', { 'on': ['XXX', 'YYY'] }
  156. call plug#end()
  157. silent! XXX
  158. Assert exists('g:xxx'), 'xxx is not loaded'
  159. Assert exists('g:yyy'), 'yyy is not loaded'
  160. Assert !exists(':YYY')
  161. Execute (#145: Merging on-demand loading triggers - map):
  162. unlet! g:xxx g:yyy
  163. call ReloadPlug()
  164. call plug#begin()
  165. Plug '$PLUG_FIXTURES/xxx', { 'on': '<Plug>(xxx)' }
  166. Plug '$PLUG_FIXTURES/yyy', { 'on': ['<Plug>(xxx)' ,'<Plug>(yyy)' ] }
  167. call plug#end()
  168. Assert !empty(mapcheck("<Plug>(xxx)"))
  169. Assert !empty(mapcheck("<Plug>(yyy)"))
  170. # FIXME feedkeys() cannot be tested with Vader
  171. call plug#load('xxx', 'yyy')
  172. Assert empty(mapcheck("<Plug>(xxx)"))
  173. Assert empty(mapcheck("<Plug>(yyy)"))
  174. **********************************************************************
  175. Execute (#159: shell=/bin/tcsh):
  176. let org = &shell
  177. try
  178. set shell=/bin/tcsh
  179. call plug#begin('/tmp/vim-plug-test/plugged')
  180. Plug 'junegunn/seoul256.vim'
  181. call plug#end()
  182. PlugStatus
  183. Log getline(1, '$')
  184. q
  185. AssertEqual '/bin/tcsh', &shell
  186. finally
  187. let &shell = org
  188. endtry
  189. **********************************************************************
  190. Execute (#154: Spaces in &rtp should not be escaped):
  191. call plug#begin('/tmp/vim-plug-test/plug it')
  192. Plug 'foo/seoul256 vim'
  193. call plug#end()
  194. Log &rtp
  195. Assert stridx(&rtp, 'plug it/seoul256 vim') >= 0
  196. **********************************************************************
  197. Execute (#184: Duplicate entries in &rtp):
  198. call plug#begin('/tmp/vim-plug-test/plugged')
  199. Plug 'foo/plugin1'
  200. \| Plug 'foo/plugin0'
  201. Plug 'foo/plugin2'
  202. \| Plug 'foo/plugin0'
  203. \| Plug 'foo/plugin1'
  204. call plug#end()
  205. Log &rtp
  206. AssertEqual 3, len(filter(split(&rtp, ','), 'stridx(v:val, "plugged") >= 0'))
  207. **********************************************************************
  208. Execute (#236: Plugin removed from &rtp when .vimrc is reloaded):
  209. unlet! g:loaded_easy_align_plugin
  210. silent! delc EasyAlign
  211. call ReloadPlug()
  212. call plug#begin('/tmp/vim-plug-test/plugged')
  213. Plug 'junegunn/vim-easy-align', { 'on': 'EasyAlign' }
  214. call plug#end()
  215. PlugInstall | q
  216. Assert &rtp !~ '/vim-easy-align', 'Plugin should not be in &rtp'
  217. %EasyAlign=
  218. Assert &rtp =~ '/vim-easy-align', 'Plugin should be in &rtp'
  219. call plug#begin('/tmp/vim-plug-test/plugged')
  220. Plug 'junegunn/vim-easy-align', { 'on': 'EasyAlign' }
  221. call plug#end()
  222. Assert &rtp =~ '/vim-easy-align', 'Plugin should still be in &rtp'
  223. **********************************************************************
  224. Execute (#350: Ruby installer failed to unshallow tagged plugin on update):
  225. call plug#begin('/tmp/vim-plug-test/plugged')
  226. call plug#end()
  227. PlugClean!
  228. " Shallow clone. We should have at least 2 plugins to enable parallel installer.
  229. call plug#begin('/tmp/vim-plug-test/plugged')
  230. Plug 'junegunn/vim-easy-align'
  231. Plug 'junegunn/seoul256.vim'
  232. call plug#end()
  233. PlugUpdate
  234. Assert filereadable(g:plugs['vim-easy-align'].dir.'/.git/shallow')
  235. " Now unshallowed
  236. call plug#begin('/tmp/vim-plug-test/plugged')
  237. Plug 'junegunn/vim-easy-align', { 'tag': '2.9.0' }
  238. Plug 'junegunn/seoul256.vim'
  239. call plug#end()
  240. PlugUpdate
  241. Assert !filereadable(g:plugs['vim-easy-align'].dir.'/.git/shallow')
  242. q
  243. **********************************************************************
  244. Execute (#474: Load ftdetect files in filetypedetect augroup):
  245. call plug#begin('/tmp/vim-plug-test/plugged')
  246. Plug 'junegunn/rust.vim', { 'for': 'rust', 'commit': '115d321d383eb96d438466c56cc871fcc1bd0faa' }
  247. call plug#end()
  248. PlugInstall!
  249. q
  250. tabnew /tmp/vim-plug-test/any.rs
  251. AssertEqual 'rust', &filetype
  252. Log &filetype
  253. filetype detect
  254. AssertEqual 'rust', &filetype
  255. Log &filetype
  256. bd
  257. **********************************************************************
  258. Execute (#489/#587 On-demand loading with 'on' option should trigger BufRead autocmd w/o nomodeline):
  259. call plug#begin('$PLUG_FIXTURES')
  260. Plug 'foo/ftplugin-msg', { 'on': 'XXX' }
  261. call plug#end()
  262. tabnew a.java
  263. call setline(1, '// vim: set filetype=lava:')
  264. redir => out
  265. silent! XXX
  266. redir END
  267. Assert stridx(out, 'ftplugin-java') >= 0
  268. AssertEqual 'lava', &filetype
  269. q!
  270. **********************************************************************
  271. Execute (Cursor moved to another window during post-update hook):
  272. function! DoSplit(...)
  273. new
  274. call setline(1, 'empty')
  275. endfunction
  276. call plug#begin('/tmp/vim-plug-test/plugged')
  277. Plug 'junegunn/rust.vim', { 'do': function('DoSplit') }
  278. call plug#end()
  279. PlugInstall!
  280. AssertEqual 1, line('$')
  281. AssertEqual 'empty', getline(1)
  282. q!
  283. q
  284. **********************************************************************
  285. Execute (#593 Add plugin to &rtp before running post-update hook with : prefix):
  286. call ReloadPlug()
  287. call plug#begin()
  288. Plug 'junegunn/vim-pseudocl', { 'on': 'XXX', 'do': ':let g:bar = pseudocl#complete#extract_words(''a b'')' }
  289. call plug#end()
  290. PlugInstall!
  291. AssertEqual ['a', 'b'], g:bar
  292. **********************************************************************
  293. Execute (#602 Confusion with branch name and path name):
  294. call plug#begin()
  295. Plug expand('file:////tmp/vim-plug-test/new-branch'), { 'branch': 'plugin' }
  296. call plug#end()
  297. PlugUpdate
  298. call PlugStatusSorted()
  299. Expect:
  300. - new-branch: OK
  301. Finished. 0 error(s).
  302. [=]
  303. **********************************************************************
  304. Execute (PlugStatus showed error with wildcard tag):
  305. call plug#begin()
  306. Plug 'junegunn/vim-easy-align', { 'tag': '*' }
  307. call plug#end()
  308. PlugUpdate
  309. call PlugStatusSorted()
  310. Expect:
  311. - vim-easy-align: OK
  312. Finished. 0 error(s).
  313. [=]