workflow.vader 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403
  1. Execute (plug#end() before plug#begin() should fail):
  2. redir => out
  3. silent! AssertEqual 0, plug#end()
  4. redir END
  5. Assert stridx(out, 'Call plug#begin() first') >= 0
  6. Execute (plug#begin() without path argument):
  7. call plug#begin()
  8. AssertEqual split(&rtp, ',')[0].'/plugged', g:plug_home
  9. unlet g:plug_home
  10. Execute (plug#begin() without path argument with empty &rtp):
  11. let save_rtp = &rtp
  12. set rtp=
  13. redir => out
  14. AssertEqual 0, plug#begin()
  15. redir END
  16. Assert stridx(out, 'Unable to determine plug home') >= 0
  17. let &rtp = save_rtp
  18. unlet save_rtp
  19. Execute (plug#begin(path)):
  20. call plug#begin(g:temp_plugged.'/')
  21. Assert g:plug_home !~ '[/\\]$', 'Trailing / should be stripped from g:plug_home'
  22. AssertEqual 0, len(g:plugs)
  23. AssertEqual g:temp_plugged, g:plug_home
  24. AssertEqual g:base_rtp, &rtp
  25. Execute (Subsequent plug#begin() calls will reuse g:plug_home):
  26. call plug#begin()
  27. AssertEqual g:temp_plugged, g:plug_home
  28. Execute (Test Plug command):
  29. ^ Git repo with branch (DEPRECATED. USE BRANCH OPTION)
  30. Plug 'junegunn/seoul256.vim', { 'branch': 'yes-t_co' }
  31. AssertEqual 'file:///tmp/junegunn/seoul256.vim', g:plugs['seoul256.vim'].uri
  32. AssertEqual join([g:temp_plugged, 'seoul256.vim/'], '/'), g:plugs['seoul256.vim'].dir
  33. AssertEqual 'yes-t_co', g:plugs['seoul256.vim'].branch
  34. Plug 'junegunn/seoul256.vim', { 'branch': 'no-t_co' } " Using branch option
  35. AssertEqual 'no-t_co', g:plugs['seoul256.vim'].branch
  36. ^ Git repo with tag (DEPRECATED. USE TAG OPTION)
  37. Plug 'junegunn/goyo.vim', '1.5.2'
  38. AssertEqual 'file:///tmp/junegunn/goyo.vim', g:plugs['goyo.vim'].uri
  39. AssertEqual join([g:temp_plugged, 'goyo.vim/'], '/'), g:plugs['goyo.vim'].dir
  40. AssertEqual '1.5.2', g:plugs['goyo.vim'].tag
  41. Plug 'junegunn/goyo.vim', { 'tag': '1.5.3' } " Using tag option
  42. AssertEqual '1.5.3', g:plugs['goyo.vim'].tag
  43. " Git URI
  44. Plug 'file:///tmp/jg/vim-emoji'
  45. AssertEqual 'file:///tmp/jg/vim-emoji', g:plugs['vim-emoji'].uri
  46. AssertEqual 'master', g:plugs['vim-emoji'].branch
  47. AssertEqual join([g:temp_plugged, 'vim-emoji/'], '/'), g:plugs['vim-emoji'].dir
  48. " vim-scripts/
  49. Plug 'beauty256'
  50. AssertEqual 'file:///tmp/vim-scripts/beauty256', g:plugs.beauty256.uri
  51. AssertEqual 'master', g:plugs.beauty256.branch
  52. AssertEqual 4, len(g:plugs)
  53. Execute (Plug command with dictionary option):
  54. Log string(g:plugs)
  55. Plug 'junegunn/seoul256.vim', { 'branch': 'no-t_co', 'rtp': '././' }
  56. AssertEqual join([g:temp_plugged, 'seoul256.vim/'], '/'), g:plugs['seoul256.vim'].dir
  57. AssertEqual '././', g:plugs['seoul256.vim'].rtp
  58. Log string(g:plugs)
  59. AssertEqual 4, len(g:plugs)
  60. Execute (PlugStatus before installation):
  61. PlugStatus
  62. AssertExpect 'Not found', 4
  63. q
  64. Execute (PlugClean before installation):
  65. PlugClean
  66. AssertExpect 'Already clean', 1
  67. q
  68. Execute (plug#end() updates &rtp):
  69. call plug#end()
  70. Assert len(&rtp) > len(g:base_rtp)
  71. AssertEqual g:first_rtp, split(&rtp, ',')[0]
  72. AssertEqual g:last_rtp, split(&rtp, ',')[-1]
  73. Execute (Yet, plugins are not available):
  74. Assert empty(globpath(&rtp, 'autoload/emoji.vim'))
  75. Execute (PlugInstall):
  76. PlugInstall
  77. q
  78. Execute (Plugin available after installation):
  79. Assert !empty(globpath(&rtp, 'autoload/emoji.vim'))
  80. Execute (PlugClean after installation):
  81. PlugClean
  82. AssertExpect 'Already clean', 1
  83. q
  84. Execute (PlugStatus after installation):
  85. PlugStatus
  86. Log getline(1, '$')
  87. AssertExpect 'OK', 4
  88. q
  89. Execute (PlugUpdate - tagged plugin should not fail (#174)):
  90. PlugUpdate goyo.vim
  91. Log getline(1, '$')
  92. AssertExpect '^- goyo.vim', 1
  93. q
  94. Execute (Change tag of goyo.vim):
  95. call plug#begin()
  96. Plug 'junegunn/goyo.vim', { 'tag': '9.9.9' }
  97. call plug#end()
  98. Execute (PlugStatus):
  99. call PlugStatusSorted()
  100. Expect:
  101. Invalid tag: 1.5.3 (expected: 9.9.9). Try PlugUpdate.
  102. Finished. 1 error(s).
  103. [=]
  104. x goyo.vim:
  105. Execute (Remove tag of goyo.vim):
  106. call plug#begin()
  107. Plug 'junegunn/goyo.vim'
  108. call plug#end()
  109. Execute (PlugStatus):
  110. call PlugStatusSorted()
  111. Expect:
  112. Invalid branch: HEAD (expected: master). Try PlugUpdate.
  113. Finished. 1 error(s).
  114. [=]
  115. x goyo.vim:
  116. Execute (PlugUpdate to set the right branch):
  117. PlugUpdate
  118. call PlugStatusSorted()
  119. Expect:
  120. - goyo.vim: OK
  121. Finished. 0 error(s).
  122. [=]
  123. Execute (Change branch of seoul256.vim):
  124. call plug#begin()
  125. Plug 'junegunn/seoul256.vim'
  126. Plug 'file:///tmp/jg/vim-emoji'
  127. call plug#end()
  128. Execute (PlugStatus):
  129. call PlugStatusSorted()
  130. Expect:
  131. Invalid branch: no-t_co (expected: master). Try PlugUpdate.
  132. - vim-emoji: OK
  133. Finished. 1 error(s).
  134. [==]
  135. x seoul256.vim:
  136. Execute (PlugUpdate to switch branch, then PlugStatus):
  137. PlugUpdate
  138. call PlugStatusSorted()
  139. Expect:
  140. - seoul256.vim: OK
  141. - vim-emoji: OK
  142. Finished. 0 error(s).
  143. [==]
  144. Execute (Change tag of seoul256.vim):
  145. call plug#begin()
  146. Plug 'junegunn/seoul256.vim', { 'tag': 'no-such-tag' }
  147. call plug#end()
  148. call PlugStatusSorted()
  149. Expect:
  150. Invalid tag: N/A (expected: no-such-tag). Try PlugUpdate.
  151. Finished. 1 error(s).
  152. [=]
  153. x seoul256.vim:
  154. Execute (Change URI of seoul256.vim):
  155. call plug#begin()
  156. Plug 'junegunn.choi/seoul256.vim'
  157. Plug 'file:///tmp/jg/vim-emoji'
  158. call plug#end()
  159. Execute (PlugStatus):
  160. call PlugStatusSorted()
  161. Expect:
  162. Expected: file:///tmp/junegunn.choi/seoul256.vim
  163. Invalid URI: file:///tmp/junegunn/seoul256.vim
  164. PlugClean required.
  165. - vim-emoji: OK
  166. Finished. 1 error(s).
  167. [==]
  168. x seoul256.vim:
  169. # TODO: does not work due to inputsave()
  170. # Do (PlugClean):
  171. # :PlugClean\<Enter>y\<Enter>
  172. # ggyG
  173. # q
  174. # PGdd
  175. Execute (PlugClean! to remove seoul256.vim):
  176. PlugClean!
  177. " Three removed, emoji left
  178. AssertExpect '^- ', 3
  179. AssertExpect 'Removed', 1
  180. Assert empty(globpath(&rtp, 'colors/seoul256.vim'))
  181. Assert !empty(globpath(&rtp, 'autoload/emoji.vim'))
  182. q
  183. Execute (Change GIT URI of vim-emoji):
  184. call plug#begin()
  185. Plug 'junegunn/seoul256.vim'
  186. Plug 'junegunn/vim-emoji'
  187. call plug#end()
  188. Execute (PlugStatus):
  189. call PlugStatusSorted()
  190. Expect:
  191. Expected: file:///tmp/junegunn/vim-emoji
  192. Invalid URI: file:///tmp/jg/vim-emoji
  193. Not found. Try PlugInstall.
  194. PlugClean required.
  195. Finished. 2 error(s).
  196. [==]
  197. x seoul256.vim:
  198. x vim-emoji:
  199. Execute (PlugClean! to remove vim-emoji):
  200. PlugClean!
  201. AssertExpect '^- ', 1
  202. AssertExpect 'Removed', 1
  203. Assert empty(globpath(&rtp, 'colors/seoul256.vim'))
  204. Assert empty(globpath(&rtp, 'autoload/emoji.vim'))
  205. q
  206. Execute (PlugUpdate to install both again):
  207. PlugUpdate
  208. AssertExpect '^- [^:]*:', 2
  209. Assert !empty(globpath(&rtp, 'colors/seoul256.vim')), 'seoul256.vim should be found'
  210. Assert !empty(globpath(&rtp, 'autoload/emoji.vim')), 'vim-emoji should be found'
  211. q
  212. Execute (PlugUpdate only to find out plugins are up-to-date, D key to check):
  213. PlugUpdate
  214. AssertExpect 'Already up-to-date', 2
  215. normal D
  216. AssertEqual '0 plugin(s) updated.', getline(1)
  217. q
  218. Execute (PlugDiff - 'No updates.'):
  219. PlugDiff
  220. Log getline(1, '$')
  221. AssertEqual '0 plugin(s) updated.', getline(1)
  222. Assert empty(mapcheck('o'))
  223. Assert empty(mapcheck('X'))
  224. Assert empty(mapcheck("\<cr>"))
  225. q
  226. Execute (New commits on remote, PlugUpdate, then PlugDiff):
  227. for repo in ['seoul256.vim', 'vim-emoji']
  228. for _ in range(2)
  229. call system(printf('cd /tmp/junegunn/%s && git commit --allow-empty -m "update"', repo))
  230. endfor
  231. endfor
  232. unlet repo
  233. PlugUpdate
  234. " Now we have updates
  235. normal D
  236. AssertEqual '2 plugin(s) updated.', getline(1)
  237. " Preview commit
  238. silent! wincmd P
  239. AssertEqual 0, &previewwindow
  240. " ]] motion
  241. execute 'normal ]]'
  242. let lnum = line('.')
  243. AssertEqual 3, col('.')
  244. " Open commit preview
  245. execute "normal j\<cr>"
  246. wincmd P
  247. AssertEqual 1, &previewwindow
  248. AssertEqual 'git', &filetype
  249. " Back to plug window
  250. wincmd p
  251. " ]] motion
  252. execute 'normal $]]'
  253. Assert line('.') >= 4
  254. " 5+ for merge commit
  255. AssertEqual 3, col('.')
  256. " [[ motion
  257. execute 'normal 0[['
  258. AssertEqual lnum, line('.')
  259. unlet lnum
  260. AssertEqual 3, col('.')
  261. " X key to revert the update
  262. AssertExpect '^- ', 2
  263. execute "normal Xn\<cr>"
  264. AssertExpect '^- ', 2
  265. execute "normal Xy\<cr>"
  266. AssertExpect '^- ', 1
  267. " q will close preview window as well
  268. normal q
  269. " We no longer have preview window
  270. silent! wincmd P
  271. AssertEqual 0, &previewwindow
  272. " q should not close preview window if it's already open
  273. pedit
  274. PlugDiff
  275. AssertExpect '^- ', 1
  276. execute "normal ]]j\<cr>"
  277. normal q
  278. silent! wincmd P
  279. AssertEqual 1, &previewwindow
  280. pclose
  281. Execute (Reuse Plug window in another tab):
  282. let tabnr = tabpagenr()
  283. PlugDiff
  284. tab new new-tab
  285. set buftype=nofile
  286. PlugUpdate
  287. normal D
  288. AssertExpect '^- ', 1
  289. normal q
  290. AssertEqual tabnr, tabpagenr()
  291. normal! gt
  292. q
  293. unlet tabnr
  294. Execute (contd. PlugDiff should not show inverted history):
  295. " Additional PlugUpdate to clear diff
  296. PlugUpdate
  297. PlugDiff
  298. Log getline(1, '$')
  299. " Checking out older revisions
  300. for repo in values(g:plugs)
  301. call system(printf('cd %s && git reset HEAD^ --hard', shellescape(repo.dir)))
  302. endfor
  303. unlet repo
  304. " PlugDiff should not report the changes i.e. git log --left-only
  305. PlugDiff
  306. Log getline(1, '$')
  307. AssertEqual '0 plugin(s) updated.', getline(1)
  308. q
  309. **********************************************************************
  310. ~ PlugDiff to see the pending changes
  311. **********************************************************************
  312. Execute (PlugDiff):
  313. call plug#begin()
  314. call plug#end()
  315. PlugClean!
  316. call plug#begin()
  317. Plug 'file://'.expand('$PLUG_FIXTURES').'/xxx'
  318. Plug 'file://'.expand('$PLUG_FIXTURES').'/yyy'
  319. call plug#end()
  320. PlugInstall
  321. Log getline(1, '$')
  322. call system('cd "$PLUG_FIXTURES/xxx" && git commit --allow-empty -m update-xxx && git tag -f xxx')
  323. call system('cd "$PLUG_FIXTURES/yyy" && git tag -f yyy && git commit --allow-empty -m update-yyy && git tag -f zzz')
  324. let g:plugs.yyy.tag = 'yyy'
  325. PlugUpdate
  326. Log getline(1, '$')
  327. PlugDiff
  328. " 1 plugin(s) updated. 1 plugin(s) have pending updates.
  329. " [==]
  330. "
  331. " Last update:
  332. " ------------
  333. "
  334. " - xxx:
  335. " 166cfff (tag: xxx) update-xxx (1 second ago)
  336. "
  337. " Pending updates:
  338. " ----------------
  339. "
  340. " - yyy: (tag: yyy)
  341. " c0a064b (tag: zzz) update-yyy (1 second ago)
  342. "
  343. Log getline(1, '$')
  344. AssertEqual 15, line('$')
  345. AssertEqual '1 plugin(s) updated. 1 plugin(s) have pending updates.', getline(1)
  346. AssertEqual '[==]', getline(2)
  347. AssertEqual '- yyy: (tag: yyy)', getline(13)
  348. Assert getline(8) =~ '(tag: xxx)'
  349. Assert getline(14) =~ '(tag: zzz)'
  350. Assert !empty(mapcheck('o'))
  351. Assert !empty(mapcheck('X'))
  352. Assert !empty(mapcheck("\<cr>"))
  353. q
  354. **********************************************************************
  355. ~ On-demand loading / Partial installation/update ~
  356. **********************************************************************
  357. Execute (Trying to execute on-demand commands when plugin is not installed):
  358. call ReloadPlug()
  359. call plug#begin()
  360. Plug 'junegunn/vim-easy-align', { 'on': ['EasyAlign', 'LiveEasyAlign'] }
  361. call plug#end()
  362. Assert exists(':EasyAlign')
  363. Assert exists(':LiveEasyAlign')
  364. AssertThrows EasyAlign
  365. AssertThrows LiveEasyAlign
  366. Assert !exists(':EasyAlign')
  367. Assert !exists(':LiveEasyAlign')
  368. Execute (New set of plugins):
  369. call ReloadPlug()
  370. call plug#begin()
  371. Plug 'junegunn/vim-fnr'
  372. Plug 'junegunn/vim-pseudocl'
  373. Plug 'junegunn/vim-easy-align', { 'on': 'EasyAlign' }
  374. Plug 'junegunn/vim-redis', { 'for': 'redis' }
  375. let user_autocmd = {}
  376. autocmd! User vim-fnr let user_autocmd.fnr = 1
  377. autocmd! User vim-easy-align let user_autocmd.easy_align = 1
  378. autocmd! User vim-redis let user_autocmd.redis = 1
  379. call plug#end()
  380. Execute (Check commands):
  381. Assert !exists(':FNR'), 'FNR command should not be found'
  382. Assert !exists(':RedisExecute'), 'RedisExecute command should not be found'
  383. Assert empty(user_autocmd)
  384. Execute (Partial PlugInstall):
  385. PlugInstall vim-fnr vim-easy-align
  386. AssertExpect 'vim-fnr', 1
  387. q
  388. PlugInstall vim-fnr vim-easy-align 1
  389. AssertExpect 'vim-fnr', 1
  390. AssertExpect 'vim-easy-align', 1
  391. AssertEqual g:first_rtp, split(&rtp, ',')[0]
  392. AssertEqual g:last_rtp, split(&rtp, ',')[-1]
  393. q
  394. Given (Unaligned code):
  395. a=1
  396. aa=2
  397. Execute (Check installed plugins):
  398. call EnsureLoaded()
  399. Assert exists(':FNR'), 'FNR command should be found'
  400. Assert !exists(':RedisExecute'), 'RedisExecute command still should not be found'
  401. Assert exists(':EasyAlign'), 'EasyAlign command should be found'
  402. %EasyAlign=
  403. Expect (Aligned code):
  404. a = 1
  405. aa = 2
  406. Then (autocmd executed):
  407. Assert user_autocmd.easy_align
  408. AssertEqual 1, len(user_autocmd)
  409. Given:
  410. Execute (Partial PlugUpdate):
  411. PlugUpdate vim-redis
  412. q
  413. Execute (On-demand loading based on filetypes):
  414. Assert !exists(':RedisExecute'), 'RedisExecute command still should not be found'
  415. set ft=redis
  416. Assert exists(':RedisExecute'), 'RedisExecute command is now found'
  417. Assert user_autocmd.redis
  418. AssertEqual 2, len(user_autocmd)
  419. autocmd! User
  420. unlet user_autocmd
  421. **********************************************************************
  422. ~ Local (unmanaged) plugins
  423. **********************************************************************
  424. Execute (Add unmanaged plugin):
  425. let fzf = expand('$PLUG_FIXTURES/fzf')
  426. call RmRf(fzf)
  427. Log fzf
  428. call plug#begin()
  429. Plug fzf, { 'on': 'SomeCommand' }
  430. call plug#end()
  431. " Check uri field
  432. Assert !has_key(g:plugs.fzf, 'uri'), 'Should not have uri field'
  433. " Check dir field
  434. AssertEqual fzf.'/', g:plugs.fzf.dir
  435. " Trailing slashes and backslashes should be stripped
  436. for suffix in ['///', '/\/\/']
  437. call plug#begin()
  438. Plug fzf.suffix, { 'on': 'SomeCommand' }
  439. call plug#end()
  440. " Check dir field
  441. AssertEqual fzf.'/', g:plugs.fzf.dir
  442. endfor
  443. Execute (Plug block for following tests):
  444. call plug#begin()
  445. Plug 'junegunn/vim-easy-align'
  446. Plug fzf, { 'on': 'SomeCommand' }
  447. call plug#end()
  448. " Remove plugins from previous tests
  449. PlugClean!
  450. q
  451. Execute (PlugInstall will only install vim-easy-align):
  452. PlugInstall
  453. Log getline(1, '$')
  454. AssertExpect 'fzf', 0
  455. q
  456. Execute (PlugUpdate will only update vim-easy-align):
  457. PlugUpdate
  458. Log getline(1, '$')
  459. AssertExpect 'fzf', 0
  460. q
  461. Execute (PlugClean should not care about unmanaged plugins):
  462. PlugClean
  463. Log getline(1, '$')
  464. AssertExpect 'fzf', 0
  465. q
  466. Execute (PlugStatus should point out that the plugin is missing):
  467. PlugStatus
  468. Log getline(1, '$')
  469. AssertExpect 'x fzf', 1
  470. AssertExpect 'Not found', 1
  471. q
  472. Execute (Deploy unmanaged plugin):
  473. Assert !exists(':FZF'), ':FZF command should not exist'
  474. call RmRf(fzf)
  475. Log system(printf('cp -r "/tmp/fzf" "%s"', fzf))
  476. Execute (PlugUpdate still should not care):
  477. PlugUpdate
  478. Log getline(1, '$')
  479. AssertExpect 'fzf', 0
  480. q
  481. Execute (PlugStatus with no error):
  482. PlugStatus
  483. Log getline(1, '$')
  484. AssertExpect 'x fzf', 0
  485. AssertExpect 'Not found', 0
  486. q
  487. Execute (Check &rtp after SomeCommand):
  488. Log &rtp
  489. Assert &rtp !~ 'fzf'
  490. silent! SomeCommand
  491. Assert &rtp =~ 'fzf'
  492. AssertEqual g:first_rtp, split(&rtp, ',')[0]
  493. AssertEqual g:last_rtp, split(&rtp, ',')[-1]
  494. Execute (Common parent):
  495. call plug#begin()
  496. Plug 'junegunn/vim-pseudocl'
  497. Plug 'junegunn/vim-fnr'
  498. Plug 'junegunn/vim-oblique'
  499. call plug#end()
  500. PlugInstall
  501. Log getline(1, '$')
  502. AssertExpect! '[===]', 1
  503. q
  504. unlet fzf
  505. **********************************************************************
  506. ~ Frozen plugins
  507. **********************************************************************
  508. - We've decided to install plugins that are frozen: see #113
  509. Execute (Frozen plugin are not ~~installed nor~~ updated):
  510. " Remove plugins
  511. call plug#begin()
  512. call plug#end()
  513. PlugClean!
  514. q
  515. " vim-easy-align is not found, so it will be installed even though it's frozen
  516. call plug#begin()
  517. Plug 'junegunn/vim-easy-align', { 'frozen': 1 }
  518. call plug#end()
  519. PlugInstall
  520. AssertEqual 1, len(filter(getline(1, '$'), 'v:val =~ "vim-easy-align"'))
  521. q
  522. " Remove plugins again
  523. call plug#begin()
  524. call plug#end()
  525. PlugClean!
  526. q
  527. " PlugUpdate will do the same
  528. call plug#begin()
  529. Plug 'junegunn/vim-easy-align', { 'frozen': 1 }
  530. call plug#end()
  531. PlugInstall
  532. AssertEqual 1, len(filter(getline(1, '$'), 'v:val =~ "vim-easy-align"'))
  533. q
  534. " Since vim-easy-align already exists, PlugInstall or PlugUpdate will skip it
  535. redir => out
  536. silent PlugInstall
  537. redir END
  538. Assert out =~ 'No plugin to install'
  539. redir => out
  540. silent PlugUpdate
  541. redir END
  542. Assert out =~ 'No plugin to update'
  543. Execute (But you can still install it if the name is given as the argument):
  544. PlugInstall vim-easy-align
  545. Log getline(1, '$')
  546. AssertEqual 1, len(filter(getline(1, '$'), 'v:val =~ "vim-easy-align"'))
  547. q
  548. PlugUpdate vim-easy-align
  549. Log getline(1, '$')
  550. AssertEqual 1, len(filter(getline(1, '$'), 'v:val =~ "vim-easy-align"'))
  551. q
  552. **********************************************************************
  553. ~ Retry
  554. **********************************************************************
  555. Execute (Retry failed tasks):
  556. call plug#begin()
  557. Plug 'junegunn/vim-easy-align'
  558. Plug 'junegunn/aaaaaaaaaaaaaa'
  559. call plug#end()
  560. PlugInstall
  561. Log getline(1, '$')
  562. AssertExpect 'x aaa', 1
  563. AssertExpect '- vim-easy-align', 1
  564. normal R
  565. Log getline(1, '$')
  566. AssertExpect 'x aaa', 1
  567. AssertExpect '- vim-easy-align', 0
  568. AssertExpect! '[x]', 1
  569. q
  570. call plug#begin()
  571. Plug 'junegunn/vim-easy-align'
  572. Plug 'junegunn/aaaaaaaaaaaaaa'
  573. Plug 'junegunn/bbbbbbbbbbbbbb'
  574. Plug 'junegunn/cccccccccccccc'
  575. call plug#end()
  576. " Ruby installer
  577. PlugUpdate
  578. normal R
  579. AssertExpect '- vim-easy-align', 0
  580. AssertExpect! '[xxx]', 1
  581. q
  582. " Vim installer
  583. PlugUpdate 1
  584. normal R
  585. AssertExpect '- vim-easy-align', 0
  586. AssertExpect! '[xxx]', 1
  587. q
  588. **********************************************************************
  589. ~ Post-update hook (`do` option)
  590. **********************************************************************
  591. Execute (Cleanup):
  592. call plug#begin()
  593. call plug#end()
  594. PlugClean!
  595. q
  596. Execute (On install):
  597. call plug#begin()
  598. Plug 'junegunn/vim-easy-align', { 'do': 'touch installed' }
  599. Plug 'junegunn/vim-pseudocl'
  600. Plug 'junegunn/seoul256.vim'
  601. Plug 'junegunn/goyo.vim'
  602. Plug 'yous/subsubmodule'
  603. call plug#end()
  604. silent PlugInstall
  605. q
  606. Assert filereadable(g:plugs['vim-easy-align'].dir.'/installed'),
  607. \ 'vim-easy-align/installed should exist'
  608. Assert !filereadable(g:plugs['vim-pseudocl'].dir.'/installed'),
  609. \ 'vim-pseudocl/installed should not exist'
  610. AssertEqual ' ', system('cd '.g:plugs['subsubmodule'].dir.' && git submodule status')[0],
  611. \ 'subsubmodule/subsubmodule should be initialized'
  612. Execute (On update):
  613. call plug#begin()
  614. Plug 'junegunn/vim-easy-align', { 'do': 'touch updated' }
  615. Plug 'junegunn/vim-pseudocl', { 'do': 'touch updated' }
  616. Plug 'junegunn/seoul256.vim'
  617. Plug 'junegunn/goyo.vim'
  618. Plug 'yous/subsubmodule'
  619. call plug#end()
  620. " New commits on remote
  621. call system('cd /tmp/junegunn/vim-pseudocl && git commit --allow-empty -m "update"')
  622. silent PlugUpdate
  623. Log getline(1, '$')
  624. q
  625. Assert !filereadable(g:plugs['vim-easy-align'].dir.'/updated'),
  626. \ 'vim-easy-align/updated should not exist'
  627. Assert filereadable(g:plugs['vim-pseudocl'].dir.'/updated'),
  628. \ 'vim-pseudocl/updated should exist'
  629. Execute (When already installed):
  630. call plug#begin()
  631. Plug 'junegunn/vim-easy-align', { 'do': 'touch installed2' }
  632. Plug 'junegunn/vim-pseudocl', { 'commit': '7f8cd78' }
  633. Plug 'junegunn/seoul256.vim', { 'branch': 'no-t_co' }
  634. Plug 'junegunn/goyo.vim', { 'tag': '1.5.3' }
  635. Plug 'yous/subsubmodule'
  636. call plug#end()
  637. PlugInstall
  638. q
  639. Assert !filereadable(g:plugs['vim-easy-align'].dir.'/installed2'),
  640. \ 'vim-easy-align/installed2 should not exist'
  641. AssertNotEqual '7f8cd78cb1fe52185b98b16a3749811f0cc508af', GitCommit('vim-pseudocl')
  642. AssertNotEqual 'no-t_co', GitBranch('seoul256.vim')
  643. AssertNotEqual '1.5.3', GitTag('goyo.vim')
  644. Execute (PlugInstall!):
  645. silent PlugInstall!
  646. q
  647. Assert filereadable(g:plugs['vim-easy-align'].dir.'/installed2'),
  648. \ 'vim-easy-align/installed2 should exist'
  649. AssertEqual '7f8cd78cb1fe52185b98b16a3749811f0cc508af', GitCommit('vim-pseudocl')
  650. AssertEqual 'no-t_co', GitBranch('seoul256.vim')
  651. AssertEqual '1.5.3', GitTag('goyo.vim')
  652. Execute (When submodules are not initialized):
  653. call system(printf('cd %s && git submodule deinit subsubmodule', g:plugs['subsubmodule'].dir))
  654. silent PlugInstall!
  655. q
  656. AssertEqual ' ', system(printf('cd %s && git submodule status', g:plugs['subsubmodule'].dir))[0],
  657. \ 'subsubmodule/subsubmodule should be initialized'
  658. Execute (When already updated):
  659. call plug#begin()
  660. Plug 'junegunn/vim-easy-align', { 'do': 'touch updated2' }
  661. Plug 'junegunn/vim-pseudocl', { 'commit': 'dd507ca' }
  662. Plug 'junegunn/seoul256.vim', { 'branch': 'master' }
  663. Plug 'junegunn/goyo.vim', { 'tag': '1.6.0' }
  664. Plug 'yous/subsubmodule'
  665. call plug#end()
  666. PlugUpdate
  667. q
  668. Assert !filereadable(g:plugs['vim-easy-align'].dir.'/updated2'),
  669. \ 'vim-easy-align/updated2 should not exist'
  670. AssertEqual 'dd507ca0d5f3fdf0d522558cc5ecffdabf824469', GitCommit('vim-pseudocl')
  671. AssertEqual 'master', GitBranch('seoul256.vim')
  672. AssertEqual '1.6.0', GitTag('goyo.vim')
  673. Execute (PlugUpdate!):
  674. silent PlugUpdate!
  675. q
  676. Assert filereadable(g:plugs['vim-easy-align'].dir.'/updated2'),
  677. \ 'vim-easy-align/updated2 should exist'
  678. Execute (When submodules are not initialized):
  679. call system(printf('cd %s && git submodule deinit subsubmodule', g:plugs['subsubmodule'].dir))
  680. silent PlugUpdate!
  681. q
  682. AssertEqual ' ', system(printf('cd %s && git submodule status', g:plugs['subsubmodule'].dir))[0],
  683. \ 'subsubmodule/subsubmodule should be initialized'
  684. Execute (Using Funcref):
  685. function! PlugUpdated(info)
  686. call system('touch '. a:info.name . a:info.status . a:info.force . len(a:info))
  687. endfunction
  688. call plug#begin()
  689. Plug 'junegunn/vim-easy-align', { 'do': function('PlugUpdated') }
  690. Plug 'junegunn/vim-pseudocl', { 'do': function('PlugUpdated') }
  691. call plug#end()
  692. call system('cd /tmp/junegunn/vim-easy-align && git commit --allow-empty -m "update"')
  693. call system('cd '.g:plugs['vim-easy-align'].dir.' && git reset --hard HEAD^')
  694. call RmRf(g:plugs['vim-pseudocl'].dir)
  695. PlugUpdate
  696. Log getline(1, '$')
  697. q
  698. Assert filereadable(g:plugs['vim-easy-align'].dir.'/vim-easy-alignupdated03'),
  699. \ 'vim-easy-align/vim-easy-alignupdated03 should exist'
  700. Assert filereadable(g:plugs['vim-pseudocl'].dir.'/vim-pseudoclinstalled03'),
  701. \ 'vim-pseudocl/vim-pseudoclinstalled03 should exist'
  702. call RmRf(g:plugs['vim-pseudocl'].dir)
  703. PlugInstall!
  704. q
  705. Assert filereadable(g:plugs['vim-easy-align'].dir.'/vim-easy-alignunchanged13'),
  706. \ 'vim-easy-align/vim-easy-alignunchanged13 should exist'
  707. Assert filereadable(g:plugs['vim-pseudocl'].dir.'/vim-pseudoclinstalled13'),
  708. \ 'vim-pseudocl/vim-pseudoclinstalled13 should exist'
  709. call system('cd '.g:plugs['vim-easy-align'].dir.' && git reset --hard HEAD^')
  710. PlugUpdate!
  711. q
  712. Assert filereadable(g:plugs['vim-easy-align'].dir.'/vim-easy-alignupdated13'),
  713. \ 'vim-easy-align/vim-easy-alignupdated13 should exist'
  714. Assert filereadable(g:plugs['vim-pseudocl'].dir.'/vim-pseudoclunchanged13'),
  715. \ 'vim-pseudocl/vim-pseudoclunchanged13 should exist'
  716. Execute (Post-update hook output; success and failure):
  717. call plug#begin()
  718. Plug 'junegunn/vim-easy-align', { 'do': 'xxx-non-existent-command-xxx' }
  719. Plug 'junegunn/vim-pseudocl', { 'do': 'true' }
  720. call plug#end()
  721. silent PlugInstall! 1
  722. AssertEqual '- Post-update hook for vim-pseudocl ... OK', getline(5)
  723. AssertEqual 'x Post-update hook for vim-easy-align ... Exit status: 127', getline(6)
  724. q
  725. Execute (Post-update hook output; invalid type or funcref):
  726. call plug#begin()
  727. Plug 'junegunn/vim-easy-align', { 'do': 1 }
  728. Plug 'junegunn/vim-pseudocl', { 'do': function('call') }
  729. call plug#end()
  730. silent PlugInstall! 1
  731. AssertEqual 'x Post-update hook for vim-pseudocl ... Vim(call):E119: Not enough arguments for function: call', getline(5)
  732. AssertEqual 'x Post-update hook for vim-easy-align ... Invalid hook type', getline(6)
  733. q
  734. Execute (Should not run when failed to update):
  735. call plug#begin()
  736. Plug 'junegunn/vim-easy-align', { 'do': 'touch failed' }
  737. Plug 'junegunn/vim-pseudocl', { 'do': 'touch not-failed' }
  738. call plug#end()
  739. " Invalid remote URL
  740. call system(printf('cd %s && git remote set-url origin xxx', g:plugs['vim-easy-align'].dir))
  741. " New commits on remote
  742. call system('cd /tmp/junegunn/vim-easy-align && git commit --allow-empty -m "update"')
  743. call system('cd /tmp/junegunn/vim-pseudocl && git commit --allow-empty -m "update"')
  744. silent PlugUpdate
  745. Log getline(1, '$')
  746. q
  747. Assert !filereadable(g:plugs['vim-easy-align'].dir.'/failed'),
  748. \ 'vim-easy-align/failed should not exist'
  749. Assert filereadable(g:plugs['vim-pseudocl'].dir.'/not-failed'),
  750. \ 'vim-pseudocl/not-failed should exist'
  751. **********************************************************************
  752. ~ Overriding `dir`
  753. **********************************************************************
  754. Execute (Using custom dir):
  755. Assert isdirectory(g:plugs['vim-easy-align'].dir)
  756. call RmRf('/tmp/easy-align')
  757. call plug#begin()
  758. Plug 'junegunn/vim-easy-align', { 'dir': '/tmp/easy-align' }
  759. call plug#end()
  760. AssertEqual '/tmp/easy-align/', g:plugs['vim-easy-align'].dir
  761. PlugClean!
  762. Assert !isdirectory(g:plugs['vim-easy-align'].dir)
  763. q
  764. PlugInstall
  765. q
  766. Assert isdirectory(g:plugs['vim-easy-align'].dir)
  767. **********************************************************************
  768. ~ On-demand loading load order
  769. **********************************************************************
  770. Before (Clear global vars):
  771. let g:xxx = []
  772. set rtp-=$PLUG_FIXTURES/xxx/
  773. set rtp-=$PLUG_FIXTURES/xxx/after
  774. Execute (Immediate loading):
  775. call ReloadPlug()
  776. call plug#begin()
  777. Plug '$PLUG_FIXTURES/xxx'
  778. call plug#end()
  779. " FIXME:
  780. " Different result when Vader is run from commandline with `-c` option
  781. Log g:xxx
  782. if has('vim_starting')
  783. AssertEqual ['xxx/ftdetect', 'xxx/after/ftdetect'], g:xxx
  784. else
  785. AssertEqual ['xxx/plugin', 'xxx/after/plugin', 'xxx/ftdetect', 'xxx/after/ftdetect'], g:xxx
  786. endif
  787. Execute (Command-based on-demand loading):
  788. call ReloadPlug()
  789. call plug#begin()
  790. Plug '$PLUG_FIXTURES/xxx', { 'on': 'XXX' }
  791. call plug#end()
  792. AssertEqual [], g:xxx
  793. silent! XXX
  794. AssertEqual ['xxx/ftdetect', 'xxx/after/ftdetect', 'xxx/plugin', 'xxx/after/plugin'], g:xxx
  795. setf xxx
  796. AssertEqual ['xxx/ftdetect', 'xxx/after/ftdetect', 'xxx/plugin', 'xxx/after/plugin', 'xxx/ftplugin', 'xxx/after/ftplugin', 'xxx/indent', 'xxx/after/indent', 'xxx/syntax', 'xxx/after/syntax'], g:xxx
  797. Execute (Filetype-based on-demand loading):
  798. call ReloadPlug()
  799. call plug#begin()
  800. Plug '$PLUG_FIXTURES/xxx', { 'for': 'xxx' }
  801. Plug '$PLUG_FIXTURES/yyy', { 'for': 'yyy' }
  802. call plug#end()
  803. AssertEqual ['xxx/ftdetect', 'xxx/after/ftdetect'], g:xxx
  804. setf xxx
  805. AssertEqual ['xxx/ftdetect', 'xxx/after/ftdetect', 'xxx/plugin', 'xxx/after/plugin', 'xxx/syntax', 'xxx/after/syntax', 'xxx/ftplugin', 'xxx/after/ftplugin', 'xxx/indent', 'xxx/after/indent'], g:xxx
  806. " syntax/xxx.vim and after/syntax/xxx.vim should not be loaded (#410)
  807. setf yyy
  808. AssertEqual ['yyy/ftdetect', 'yyy/after/ftdetect', 'yyy/plugin', 'yyy/after/plugin'], g:yyy
  809. Before:
  810. **********************************************************************
  811. ~ plug#helptags()
  812. **********************************************************************
  813. Execute (plug#helptags):
  814. silent! call delete(expand('$PLUG_FIXTURES/xxx/doc/tags'))
  815. Assert !filereadable(expand('$PLUG_FIXTURES/xxx/doc/tags'))
  816. AssertEqual 1, plug#helptags()
  817. Assert filereadable(expand('$PLUG_FIXTURES/xxx/doc/tags'))
  818. **********************************************************************
  819. ~ Manual loading
  820. **********************************************************************
  821. Execute (plug#load - invalid arguments):
  822. AssertEqual 0, plug#load()
  823. AssertEqual 0, plug#load('non-existent-plugin')
  824. AssertEqual 0, plug#load('non-existent-plugin', 'another-non-existent-plugin')
  825. AssertEqual 1, plug#load('xxx')
  826. AssertEqual 0, plug#load('xxx', 'non-existent-plugin')
  827. AssertEqual 0, plug#load('non-existent-plugin', 'xxx')
  828. Execute (on: []):
  829. call plug#begin()
  830. Plug 'junegunn/rust.vim', { 'on': [] }
  831. call plug#end()
  832. PlugInstall
  833. q
  834. Execute (PlugStatus reports (not loaded)):
  835. PlugStatus
  836. AssertExpect 'not loaded', 1
  837. q
  838. Execute (plug#load to load it):
  839. tabnew test.rs
  840. " Vader will switch tab to [Vader-workbench] after Log
  841. " Log &filetype
  842. AssertEqual 1, plug#load('rust.vim')
  843. AssertEqual 'rust', &filetype
  844. q
  845. Execute (PlugStatus should not contain (not loaded)):
  846. PlugStatus
  847. AssertExpect 'not loaded', 0
  848. q
  849. Execute (Load plugin from PlugStatus screen with L key in normal mode):
  850. call ResetPlug()
  851. unlet! g:yyy
  852. call plug#begin()
  853. Plug '$PLUG_FIXTURES/yyy', { 'on': [] }
  854. call plug#end()
  855. PlugStatus
  856. AssertExpect 'not loaded', 1
  857. Assert !exists('g:yyy'), 'yyy not loaded'
  858. /not loaded
  859. normal L
  860. AssertExpect 'not loaded', 0
  861. Assert exists('g:yyy'), 'yyy loaded'
  862. q
  863. Execute (Load plugin from PlugStatus screen with L key in visual mode):
  864. call plug#begin()
  865. Plug '$PLUG_FIXTURES/z1', { 'on': [] }
  866. Plug '$PLUG_FIXTURES/z2', { 'for': [] }
  867. call plug#end()
  868. PlugStatus
  869. AssertExpect 'not loaded', 2
  870. Assert !exists('g:z1'), 'z1 not loaded'
  871. Assert !exists('g:z2'), 'z2 not loaded'
  872. normal ggVGL
  873. AssertExpect 'not loaded', 0
  874. Assert exists('g:z1'), 'z1 loaded'
  875. Assert exists('g:z2'), 'z2 loaded'
  876. q
  877. **********************************************************************
  878. ~ g:plug_window
  879. **********************************************************************
  880. Execute (Open plug window in a new tab):
  881. " Without g:plug_window, plug window is open on the left split
  882. let tabnr = tabpagenr()
  883. PlugStatus
  884. AssertEqual tabnr, tabpagenr()
  885. AssertEqual 1, winnr()
  886. " PlugStatus again inside the window should not change the view
  887. normal S
  888. AssertEqual tabnr, tabpagenr()
  889. AssertEqual 1, winnr()
  890. q
  891. " Define g:plug_window so that plug window is open in a new tab
  892. let g:plug_window = 'tabnew'
  893. PlugStatus
  894. AssertNotEqual tabnr, tabpagenr()
  895. " PlugStatus again inside the window should not change the view
  896. let tabnr = tabpagenr()
  897. normal S
  898. AssertEqual tabnr, tabpagenr()
  899. q
  900. unlet g:plug_window tabnr
  901. **********************************************************************
  902. ~ g:plug_url_format
  903. **********************************************************************
  904. Execute (Using g:plug_url_format):
  905. let prev_plug_url_format = g:plug_url_format
  906. call plug#begin()
  907. let g:plug_url_format = 'git@bitbucket.org:%s.git'
  908. Plug 'junegunn/seoul256.vim'
  909. let g:plug_url_format = 'git@bitsocket.org:%s.git'
  910. Plug 'beauty256'
  911. AssertEqual 'git@bitbucket.org:junegunn/seoul256.vim.git', g:plugs['seoul256.vim'].uri
  912. AssertEqual 'git@bitsocket.org:vim-scripts/beauty256.git', g:plugs['beauty256'].uri
  913. let g:plug_url_format = prev_plug_url_format
  914. **********************************************************************
  915. ~ U
  916. **********************************************************************
  917. Execute (Plug block):
  918. call plug#begin()
  919. Plug 'junegunn/vim-easy-align'
  920. Plug 'junegunn/vim-emoji'
  921. call plug#end()
  922. Execute (Update plugin with U key in normal mode):
  923. PlugStatus
  924. /emoji
  925. normal U
  926. Log getline(1, '$')
  927. AssertExpect 'Updated', 1
  928. AssertExpect 'vim-emoji', 1
  929. AssertExpect 'vim-easy-align', 0
  930. AssertExpect! '[=]', 1
  931. " From PlugInstall screen
  932. PlugInstall
  933. /easy-align
  934. normal U
  935. AssertExpect 'Updated', 1
  936. AssertExpect 'vim-emoji', 0
  937. AssertExpect 'vim-easy-align', 1
  938. AssertExpect! '[=]', 1
  939. q
  940. Execute (Update plugins with U key in visual mode):
  941. silent! call RmRf(g:plugs['vim-easy-align'].dir)
  942. PlugStatus
  943. normal VGU
  944. Log getline(1, '$')
  945. AssertExpect 'Updated', 1
  946. AssertExpect 'vim-emoji', 1
  947. AssertExpect 'vim-easy-align', 1
  948. AssertExpect! '[==]', 1
  949. " From PlugUpdate screen
  950. normal VGU
  951. Log getline(1, '$')
  952. AssertExpect 'Updated', 1
  953. AssertExpect 'vim-emoji', 1
  954. AssertExpect 'vim-easy-align', 1
  955. AssertExpect! '[==]', 1
  956. q
  957. **********************************************************************
  958. Execute (plug#begin should expand env vars):
  959. AssertNotEqual '$HOME/.emacs/plugged', expand('$HOME/.emacs/plugged')
  960. call plug#begin('$HOME/.emacs/plugged')
  961. AssertEqual expand('$HOME/.emacs/plugged'), g:plug_home
  962. **********************************************************************
  963. Execute (Plug directory with comma):
  964. call plug#begin(g:temp_plugged . '/p,l,u,g,g,e,d')
  965. Plug 'junegunn/vim-emoji'
  966. call plug#end()
  967. Log &rtp
  968. PlugInstall
  969. q
  970. let found = filter(split(globpath(&rtp, 'README.md'), '\n'), 'v:val =~ ","')
  971. Log found
  972. AssertEqual 1, len(found)
  973. unlet found
  974. **********************************************************************
  975. Execute (Strict load order):
  976. let g:total_order = []
  977. call ReloadPlug()
  978. call plug#begin()
  979. Plug '$PLUG_FIXTURES/xxx'
  980. Plug '$PLUG_FIXTURES/yyy', { 'for': ['xxx'] }
  981. call plug#end()
  982. call EnsureLoaded()
  983. setf xxx
  984. Log 'Case 1: ' . &rtp
  985. AssertEqual ['yyy/ftdetect', 'yyy/after/ftdetect', 'xxx/ftdetect', 'xxx/after/ftdetect'], g:total_order[0:3]
  986. Assert index(g:total_order, 'xxx/plugin') < index(g:total_order, 'yyy/plugin')
  987. Assert index(g:total_order, 'xxx/after/plugin') < index(g:total_order, 'yyy/after/plugin')
  988. let len = len(split(&rtp, ','))
  989. let g:total_order = []
  990. call ReloadPlug()
  991. call plug#begin()
  992. Plug '$PLUG_FIXTURES/xxx', { 'for': ['xxx'] }
  993. Plug '$PLUG_FIXTURES/yyy'
  994. call plug#end()
  995. call EnsureLoaded()
  996. set rtp^=manually-prepended
  997. set rtp+=manually-appended
  998. setf xxx
  999. Log 'Case 2: ' . &rtp
  1000. AssertEqual 'manually-prepended', split(&rtp, ',')[3]
  1001. AssertEqual 'manually-appended', split(&rtp, ',')[-4]
  1002. AssertEqual ['xxx/ftdetect', 'xxx/after/ftdetect', 'yyy/ftdetect', 'yyy/after/ftdetect'], g:total_order[0:3]
  1003. Assert index(g:total_order, 'yyy/plugin') < index(g:total_order, 'xxx/plugin')
  1004. Assert index(g:total_order, 'yyy/after/plugin') < index(g:total_order, 'xxx/after/plugin')
  1005. AssertEqual len + 2, len(split(&rtp, ','))
  1006. let g:total_order = []
  1007. call ReloadPlug()
  1008. set rtp^=manually-prepended
  1009. set rtp+=manually-appended
  1010. call plug#begin()
  1011. Plug '$PLUG_FIXTURES/xxx', { 'for': ['xxx'] }
  1012. Plug '$PLUG_FIXTURES/yyy', { 'for': ['xxx'] }
  1013. call plug#end()
  1014. call EnsureLoaded()
  1015. setf xxx
  1016. Log 'Case 3: ' . &rtp
  1017. AssertEqual ['xxx/ftdetect', 'xxx/after/ftdetect', 'yyy/ftdetect', 'yyy/after/ftdetect'], g:total_order[0:3]
  1018. Assert index(g:total_order, 'xxx/plugin') < index(g:total_order, 'yyy/plugin')
  1019. Assert index(g:total_order, 'xxx/after/plugin') < index(g:total_order, 'yyy/after/plugin')
  1020. AssertEqual len + 2, len(split(&rtp, ','))
  1021. **********************************************************************
  1022. Execute (PlugClean should not try to remove unmanaged plugins inside g:plug_home):
  1023. call plug#begin('$PLUG_FIXTURES')
  1024. Plug '$PLUG_FIXTURES/ftplugin-msg', { 'for': [] }
  1025. Plug '$PLUG_FIXTURES/fzf'
  1026. Plug '$PLUG_FIXTURES/xxx'
  1027. Plug '$PLUG_FIXTURES/yyy'
  1028. call plug#end()
  1029. " Remove z1, z2
  1030. PlugClean!
  1031. AssertExpect '^- ', 2
  1032. AssertExpect 'Already clean', 0
  1033. PlugClean!
  1034. AssertExpect '^- ', 0
  1035. AssertExpect 'Already clean', 1
  1036. q
  1037. **********************************************************************
  1038. Execute (PlugSnapshot / #154 issues with paths containing spaces):
  1039. let $TMPDIR = '/tmp'
  1040. call plug#begin('$TMPDIR/plug with spaces')
  1041. Plug 'junegunn/vim-easy-align'
  1042. Plug 'junegunn/seoul256.vim'
  1043. call plug#end()
  1044. PlugClean!
  1045. PlugInstall
  1046. call plug#load('vim-easy-align') " Should properly handle paths with spaces
  1047. PlugSnapshot
  1048. AssertEqual '" Generated by vim-plug', getline(1)
  1049. AssertEqual 0, stridx(getline(6), "silent! let g:plugs['seoul256.vim'].commit = '")
  1050. AssertEqual 0, stridx(getline(7), "silent! let g:plugs['vim-easy-align'].commit = '")
  1051. AssertEqual 'vim', &filetype
  1052. call delete(g:plug_home.'/snapshot.vim')
  1053. execute 'PlugSnapshot' escape(g:plug_home.'/snapshot.vim', ' ')
  1054. AssertEqual 'vim', &filetype
  1055. AssertEqual 'snapshot.vim', fnamemodify(expand('%'), ':t')
  1056. q
  1057. Execute(PlugSnapshot! to overwrite existing file):
  1058. call writefile(['foobar'], g:plug_home.'/snapshot.vim')
  1059. AssertEqual 'foobar', readfile(g:plug_home.'/snapshot.vim')[0]
  1060. execute 'PlugSnapshot!' escape(g:plug_home.'/snapshot.vim', ' ')
  1061. AssertEqual '" Generated by vim-plug', readfile(g:plug_home.'/snapshot.vim')[0]
  1062. q
  1063. **********************************************************************
  1064. Execute (#221 Shallow-clone and tag option):
  1065. call plug#begin(g:temp_plugged)
  1066. Plug 'junegunn/goyo.vim'
  1067. call plug#end()
  1068. PlugInstall
  1069. execute 'cd' g:plugs['goyo.vim'].dir
  1070. Assert len(split(system('git log --oneline'), '\n')) == 1
  1071. Assert filereadable('.git/shallow')
  1072. Plug 'junegunn/goyo.vim', { 'tag': '1.5.3' }
  1073. PlugUpdate
  1074. q
  1075. Assert len(split(system('git log --oneline'), '\n')) > 1
  1076. Assert system('git describe --tag') =~ '^1.5.3'
  1077. Assert !filereadable('.git/shallow')
  1078. cd -
  1079. Execute (#221 Shallow-clone disabled by g:plug_shallow = 0):
  1080. call plug#begin(g:temp_plugged)
  1081. call plug#end()
  1082. PlugClean!
  1083. let g:plug_shallow = 0
  1084. call plug#begin(g:temp_plugged)
  1085. Plug 'junegunn/goyo.vim'
  1086. call plug#end()
  1087. PlugInstall
  1088. q
  1089. execute 'cd' g:plugs['goyo.vim'].dir
  1090. Assert len(split(system('git log --oneline'), '\n')) > 1, 'not shallow'
  1091. Assert !filereadable('.git/shallow'), 'not shallow'
  1092. cd -
  1093. unlet g:plug_shallow
  1094. Execute (#221 Shallow-clone disabled by tag):
  1095. call plug#begin(g:temp_plugged)
  1096. call plug#end()
  1097. PlugClean!
  1098. call plug#begin(g:temp_plugged)
  1099. Plug 'junegunn/goyo.vim', { 'tag': '1.5.3' }
  1100. call plug#end()
  1101. Assert !isdirectory(g:plugs['goyo.vim'].dir)
  1102. PlugInstall
  1103. Assert isdirectory(g:plugs['goyo.vim'].dir)
  1104. q
  1105. execute 'cd' g:plugs['goyo.vim'].dir
  1106. Assert system('git describe --tag') =~ '^1.5.3'
  1107. Assert len(split(system('git log --oneline'), '\n')) > 1
  1108. Assert !filereadable('.git/shallow')
  1109. cd -
  1110. Execute (Commit hash support):
  1111. " Get goyo back to master
  1112. call plug#begin(g:temp_plugged)
  1113. Plug 'junegunn/goyo.vim'
  1114. call plug#end()
  1115. PlugUpdate
  1116. call plug#begin(g:temp_plugged)
  1117. Plug 'junegunn/goyo.vim', { 'commit': 'ffffffff' }
  1118. Plug 'junegunn/vim-emoji', { 'commit': '9db7fcfee0d90dafdbcb7a32090c0a9085eb054a' }
  1119. call plug#end()
  1120. PlugUpdate
  1121. Log getline(1, '$')
  1122. AssertEqual 'x goyo.vim: error: pathspec ''ffffffff'' did not match any file(s) known to git.', getline(5)
  1123. AssertEqual 0, stridx(getline(6), '- vim-emoji: HEAD is now at 9db7fcf...')
  1124. let hash = system(printf('cd %s && git rev-parse HEAD', g:plugs['vim-emoji'].dir))[:-2]
  1125. AssertEqual '9db7fcfee0d90dafdbcb7a32090c0a9085eb054a', hash
  1126. " Validate error formatting
  1127. PlugStatus
  1128. Log getline(1, '$')
  1129. AssertEqual ['Finished. 1 error(s).',
  1130. \'[==]',
  1131. \'',
  1132. \'x goyo.vim:'], getline(1, 4)
  1133. Assert getline(5) =~ ' Invalid HEAD (expected: fffffff, actual: [0-9a-f]\{7})'
  1134. AssertEqual [' PlugUpdate required.',
  1135. \'- vim-emoji: OK'], getline(6, '$')
  1136. " PlugDiff should show pending updates for vim-emoji
  1137. PlugDiff
  1138. Log getline(1, '$')
  1139. AssertEqual '0 plugin(s) updated. 1 plugin(s) have pending updates.', getline(1)
  1140. Assert !empty(mapcheck('o'))
  1141. Assert empty(mapcheck('X'))
  1142. Assert !empty(mapcheck("\<cr>"))
  1143. " Nor in PlugSnapshot output
  1144. PlugSnapshot
  1145. Log getline(1, '$')
  1146. AssertEqual 8, line('$')
  1147. q
  1148. Execute (Commit hash support - cleared):
  1149. call plug#begin(g:temp_plugged)
  1150. Plug 'junegunn/goyo.vim'
  1151. Plug 'junegunn/vim-emoji'
  1152. call plug#end()
  1153. PlugInstall
  1154. let hash = system(printf('cd %s && git rev-parse HEAD', g:plugs['vim-emoji'].dir))[:-2]
  1155. AssertEqual '9db7fcfee0d90dafdbcb7a32090c0a9085eb054a', hash
  1156. PlugUpdate
  1157. let hash = system(printf('cd %s && git rev-parse HEAD', g:plugs['vim-emoji'].dir))[:-2]
  1158. AssertNotEqual '9db7fcfee0d90dafdbcb7a32090c0a9085eb054a', hash
  1159. q
  1160. Execute (#371 - 'as' option):
  1161. call plug#begin()
  1162. Plug 'jg/goyo.vim'
  1163. Plug 'junegunn/goyo.vim', {'as': 'yogo'}
  1164. call plug#end()
  1165. AssertEqual ['goyo.vim', 'yogo'], sort(keys(g:plugs))
  1166. Log g:plugs
  1167. Assert g:plugs.yogo.dir =~# '/yogo/$'
  1168. call plug#begin()
  1169. Plug 'junegunn/goyo.vim', {'as': 'yogo', 'dir': '/tmp/gogo'}
  1170. call plug#end()
  1171. AssertEqual ['yogo'], sort(keys(g:plugs))
  1172. AssertEqual '/tmp/gogo/', g:plugs.yogo.dir