workflow.vader 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343
  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. call plug#end()
  601. silent PlugInstall
  602. q
  603. Assert filereadable(g:plugs['vim-easy-align'].dir.'/installed'),
  604. \ 'vim-easy-align/installed should exist'
  605. Assert !filereadable(g:plugs['vim-pseudocl'].dir.'/installed'),
  606. \ 'vim-pseudocl/installed should not exist'
  607. Execute (On update):
  608. call plug#begin()
  609. Plug 'junegunn/vim-easy-align', { 'do': 'touch updated' }
  610. Plug 'junegunn/vim-pseudocl', { 'do': 'touch updated' }
  611. call plug#end()
  612. " New commits on remote
  613. call system('cd /tmp/junegunn/vim-pseudocl && git commit --allow-empty -m "update"')
  614. silent PlugUpdate
  615. Log getline(1, '$')
  616. q
  617. Assert !filereadable(g:plugs['vim-easy-align'].dir.'/updated'),
  618. \ 'vim-easy-align/updated should not exist'
  619. Assert filereadable(g:plugs['vim-pseudocl'].dir.'/updated'),
  620. \ 'vim-pseudocl/updated should exist'
  621. Execute (When already installed):
  622. call plug#begin()
  623. Plug 'junegunn/vim-easy-align', { 'do': 'touch installed2' }
  624. Plug 'junegunn/vim-pseudocl', { 'do': 'touch installed2' }
  625. call plug#end()
  626. PlugInstall
  627. q
  628. Assert !filereadable(g:plugs['vim-easy-align'].dir.'/installed2'),
  629. \ 'vim-easy-align/installed2 should not exist'
  630. Assert !filereadable(g:plugs['vim-pseudocl'].dir.'/installed2'),
  631. \ 'vim-pseudocl/installed2 should not exist'
  632. Execute (PlugInstall!):
  633. silent PlugInstall!
  634. q
  635. Assert filereadable(g:plugs['vim-easy-align'].dir.'/installed2'),
  636. \ 'vim-easy-align/installed2 should exist'
  637. Assert filereadable(g:plugs['vim-pseudocl'].dir.'/installed2'),
  638. \ 'vim-pseudocl/installed2 should exist'
  639. Execute (When already updated):
  640. call plug#begin()
  641. Plug 'junegunn/vim-easy-align', { 'do': 'touch updated2' }
  642. Plug 'junegunn/vim-pseudocl', { 'do': 'touch updated2' }
  643. call plug#end()
  644. PlugUpdate
  645. q
  646. Assert !filereadable(g:plugs['vim-easy-align'].dir.'/updated2'),
  647. \ 'vim-easy-align/updated2 should not exist'
  648. Assert !filereadable(g:plugs['vim-pseudocl'].dir.'/updated2'),
  649. \ 'vim-pseudocl/updated2 should not exist'
  650. Execute (PlugUpdate!):
  651. silent PlugUpdate!
  652. q
  653. Assert filereadable(g:plugs['vim-easy-align'].dir.'/updated2'),
  654. \ 'vim-easy-align/updated2 should exist'
  655. Assert filereadable(g:plugs['vim-pseudocl'].dir.'/updated2'),
  656. \ 'vim-pseudocl/updated2 should exist'
  657. Execute (Using Funcref):
  658. function! PlugUpdated(info)
  659. call system('touch '. a:info.name . a:info.status . a:info.force . len(a:info))
  660. endfunction
  661. call plug#begin()
  662. Plug 'junegunn/vim-easy-align', { 'do': function('PlugUpdated') }
  663. Plug 'junegunn/vim-pseudocl', { 'do': function('PlugUpdated') }
  664. call plug#end()
  665. call system('cd /tmp/junegunn/vim-easy-align && git commit --allow-empty -m "update"')
  666. call system('cd '.g:plugs['vim-easy-align'].dir.' && git reset --hard HEAD^')
  667. call RmRf(g:plugs['vim-pseudocl'].dir)
  668. PlugUpdate
  669. Log getline(1, '$')
  670. q
  671. Assert filereadable(g:plugs['vim-easy-align'].dir.'/vim-easy-alignupdated03'),
  672. \ 'vim-easy-align/vim-easy-alignupdated03 should exist'
  673. Assert filereadable(g:plugs['vim-pseudocl'].dir.'/vim-pseudoclinstalled03'),
  674. \ 'vim-pseudocl/vim-pseudoclinstalled03 should exist'
  675. call RmRf(g:plugs['vim-pseudocl'].dir)
  676. PlugInstall!
  677. q
  678. Assert filereadable(g:plugs['vim-easy-align'].dir.'/vim-easy-alignunchanged13'),
  679. \ 'vim-easy-align/vim-easy-alignunchanged13 should exist'
  680. Assert filereadable(g:plugs['vim-pseudocl'].dir.'/vim-pseudoclinstalled13'),
  681. \ 'vim-pseudocl/vim-pseudoclinstalled13 should exist'
  682. call system('cd '.g:plugs['vim-easy-align'].dir.' && git reset --hard HEAD^')
  683. PlugUpdate!
  684. q
  685. Assert filereadable(g:plugs['vim-easy-align'].dir.'/vim-easy-alignupdated13'),
  686. \ 'vim-easy-align/vim-easy-alignupdated13 should exist'
  687. Assert filereadable(g:plugs['vim-pseudocl'].dir.'/vim-pseudoclunchanged13'),
  688. \ 'vim-pseudocl/vim-pseudoclunchanged13 should exist'
  689. Execute (Post-update hook output; success and failure):
  690. call plug#begin()
  691. Plug 'junegunn/vim-easy-align', { 'do': 'xxx-non-existent-command-xxx' }
  692. Plug 'junegunn/vim-pseudocl', { 'do': 'true' }
  693. call plug#end()
  694. silent PlugInstall! 1
  695. AssertEqual '- Post-update hook for vim-pseudocl ... OK', getline(5)
  696. AssertEqual 'x Post-update hook for vim-easy-align ... Exit status: 127', getline(6)
  697. q
  698. Execute (Post-update hook output; invalid type or funcref):
  699. call plug#begin()
  700. Plug 'junegunn/vim-easy-align', { 'do': 1 }
  701. Plug 'junegunn/vim-pseudocl', { 'do': function('call') }
  702. call plug#end()
  703. silent PlugInstall! 1
  704. AssertEqual 'x Post-update hook for vim-pseudocl ... Vim(call):E119: Not enough arguments for function: call', getline(5)
  705. AssertEqual 'x Post-update hook for vim-easy-align ... Invalid hook type', getline(6)
  706. q
  707. Execute (Should not run when failed to update):
  708. call plug#begin()
  709. Plug 'junegunn/vim-easy-align', { 'do': 'touch failed' }
  710. Plug 'junegunn/vim-pseudocl', { 'do': 'touch not-failed' }
  711. call plug#end()
  712. " Invalid remote URL
  713. call system(printf('cd %s && git remote set-url origin xxx', g:plugs['vim-easy-align'].dir))
  714. " New commits on remote
  715. call system('cd /tmp/junegunn/vim-easy-align && git commit --allow-empty -m "update"')
  716. call system('cd /tmp/junegunn/vim-pseudocl && git commit --allow-empty -m "update"')
  717. silent PlugUpdate
  718. Log getline(1, '$')
  719. q
  720. Assert !filereadable(g:plugs['vim-easy-align'].dir.'/failed'),
  721. \ 'vim-easy-align/failed should not exist'
  722. Assert filereadable(g:plugs['vim-pseudocl'].dir.'/not-failed'),
  723. \ 'vim-pseudocl/not-failed should exist'
  724. **********************************************************************
  725. ~ Overriding `dir`
  726. **********************************************************************
  727. Execute (Using custom dir):
  728. Assert isdirectory(g:plugs['vim-easy-align'].dir)
  729. call RmRf('/tmp/easy-align')
  730. call plug#begin()
  731. Plug 'junegunn/vim-easy-align', { 'dir': '/tmp/easy-align' }
  732. call plug#end()
  733. AssertEqual '/tmp/easy-align/', g:plugs['vim-easy-align'].dir
  734. PlugClean!
  735. Assert !isdirectory(g:plugs['vim-easy-align'].dir)
  736. q
  737. PlugInstall
  738. q
  739. Assert isdirectory(g:plugs['vim-easy-align'].dir)
  740. **********************************************************************
  741. ~ On-demand loading load order
  742. **********************************************************************
  743. Before (Clear global vars):
  744. let g:xxx = []
  745. set rtp-=$PLUG_FIXTURES/xxx/
  746. set rtp-=$PLUG_FIXTURES/xxx/after
  747. Execute (Immediate loading):
  748. call ReloadPlug()
  749. call plug#begin()
  750. Plug '$PLUG_FIXTURES/xxx'
  751. call plug#end()
  752. " FIXME:
  753. " Different result when Vader is run from commandline with `-c` option
  754. Log g:xxx
  755. if has('vim_starting')
  756. AssertEqual ['xxx/ftdetect', 'xxx/after/ftdetect'], g:xxx
  757. else
  758. AssertEqual ['xxx/plugin', 'xxx/after/plugin', 'xxx/ftdetect', 'xxx/after/ftdetect'], g:xxx
  759. endif
  760. Execute (Command-based on-demand loading):
  761. call ReloadPlug()
  762. call plug#begin()
  763. Plug '$PLUG_FIXTURES/xxx', { 'on': 'XXX' }
  764. call plug#end()
  765. AssertEqual [], g:xxx
  766. silent! XXX
  767. AssertEqual ['xxx/ftdetect', 'xxx/after/ftdetect', 'xxx/plugin', 'xxx/after/plugin'], g:xxx
  768. setf xxx
  769. 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
  770. Execute (Filetype-based on-demand loading):
  771. call ReloadPlug()
  772. call plug#begin()
  773. Plug '$PLUG_FIXTURES/xxx', { 'for': 'xxx' }
  774. call plug#end()
  775. AssertEqual ['xxx/ftdetect', 'xxx/after/ftdetect'], g:xxx
  776. setf xxx
  777. 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', 'xxx/syntax', 'xxx/after/syntax'], g:xxx
  778. Before:
  779. **********************************************************************
  780. ~ plug#helptags()
  781. **********************************************************************
  782. Execute (plug#helptags):
  783. silent! call delete(expand('$PLUG_FIXTURES/xxx/doc/tags'))
  784. Assert !filereadable(expand('$PLUG_FIXTURES/xxx/doc/tags'))
  785. AssertEqual 1, plug#helptags()
  786. Assert filereadable(expand('$PLUG_FIXTURES/xxx/doc/tags'))
  787. **********************************************************************
  788. ~ Manual loading
  789. **********************************************************************
  790. Execute (plug#load - invalid arguments):
  791. AssertEqual 0, plug#load()
  792. AssertEqual 0, plug#load('non-existent-plugin')
  793. AssertEqual 0, plug#load('non-existent-plugin', 'another-non-existent-plugin')
  794. AssertEqual 1, plug#load('xxx')
  795. AssertEqual 0, plug#load('xxx', 'non-existent-plugin')
  796. AssertEqual 0, plug#load('non-existent-plugin', 'xxx')
  797. Execute (on: []):
  798. call plug#begin()
  799. Plug 'junegunn/rust.vim', { 'on': [] }
  800. call plug#end()
  801. PlugInstall
  802. q
  803. Execute (PlugStatus reports (not loaded)):
  804. PlugStatus
  805. AssertExpect 'not loaded', 1
  806. q
  807. Execute (plug#load to load it):
  808. tabnew test.rs
  809. " Vader will switch tab to [Vader-workbench] after Log
  810. " Log &filetype
  811. AssertEqual 1, plug#load('rust.vim')
  812. AssertEqual 'rust', &filetype
  813. q
  814. Execute (PlugStatus should not contain (not loaded)):
  815. PlugStatus
  816. AssertExpect 'not loaded', 0
  817. q
  818. Execute (Load plugin from PlugStatus screen with L key in normal mode):
  819. call plug#begin()
  820. Plug '$PLUG_FIXTURES/yyy', { 'on': [] }
  821. call plug#end()
  822. PlugStatus
  823. AssertExpect 'not loaded', 1
  824. Assert !exists('g:yyy'), 'yyy not loaded'
  825. /not loaded
  826. normal L
  827. AssertExpect 'not loaded', 0
  828. Assert exists('g:yyy'), 'yyy loaded'
  829. q
  830. Execute (Load plugin from PlugStatus screen with L key in visual mode):
  831. call plug#begin()
  832. Plug '$PLUG_FIXTURES/z1', { 'on': [] }
  833. Plug '$PLUG_FIXTURES/z2', { 'for': [] }
  834. call plug#end()
  835. PlugStatus
  836. AssertExpect 'not loaded', 2
  837. Assert !exists('g:z1'), 'z1 not loaded'
  838. Assert !exists('g:z2'), 'z2 not loaded'
  839. normal ggVGL
  840. AssertExpect 'not loaded', 0
  841. Assert exists('g:z1'), 'z1 loaded'
  842. Assert exists('g:z2'), 'z2 loaded'
  843. q
  844. **********************************************************************
  845. ~ g:plug_window
  846. **********************************************************************
  847. Execute (Open plug window in a new tab):
  848. " Without g:plug_window, plug window is open on the left split
  849. let tabnr = tabpagenr()
  850. PlugStatus
  851. AssertEqual tabnr, tabpagenr()
  852. AssertEqual 1, winnr()
  853. " PlugStatus again inside the window should not change the view
  854. normal S
  855. AssertEqual tabnr, tabpagenr()
  856. AssertEqual 1, winnr()
  857. q
  858. " Define g:plug_window so that plug window is open in a new tab
  859. let g:plug_window = 'tabnew'
  860. PlugStatus
  861. AssertNotEqual tabnr, tabpagenr()
  862. " PlugStatus again inside the window should not change the view
  863. let tabnr = tabpagenr()
  864. normal S
  865. AssertEqual tabnr, tabpagenr()
  866. q
  867. unlet g:plug_window tabnr
  868. **********************************************************************
  869. ~ g:plug_url_format
  870. **********************************************************************
  871. Execute (Using g:plug_url_format):
  872. let prev_plug_url_format = g:plug_url_format
  873. call plug#begin()
  874. let g:plug_url_format = 'git@bitbucket.org:%s.git'
  875. Plug 'junegunn/seoul256.vim'
  876. let g:plug_url_format = 'git@bitsocket.org:%s.git'
  877. Plug 'beauty256'
  878. AssertEqual 'git@bitbucket.org:junegunn/seoul256.vim.git', g:plugs['seoul256.vim'].uri
  879. AssertEqual 'git@bitsocket.org:vim-scripts/beauty256.git', g:plugs['beauty256'].uri
  880. let g:plug_url_format = prev_plug_url_format
  881. **********************************************************************
  882. ~ U
  883. **********************************************************************
  884. Execute (Plug block):
  885. call plug#begin()
  886. Plug 'junegunn/vim-easy-align'
  887. Plug 'junegunn/vim-emoji'
  888. call plug#end()
  889. Execute (Update plugin with U key in normal mode):
  890. PlugStatus
  891. /emoji
  892. normal U
  893. Log getline(1, '$')
  894. AssertExpect 'Updated', 1
  895. AssertExpect 'vim-emoji', 1
  896. AssertExpect 'vim-easy-align', 0
  897. AssertExpect! '[=]', 1
  898. " From PlugInstall screen
  899. PlugInstall
  900. /easy-align
  901. normal U
  902. AssertExpect 'Updated', 1
  903. AssertExpect 'vim-emoji', 0
  904. AssertExpect 'vim-easy-align', 1
  905. AssertExpect! '[=]', 1
  906. q
  907. Execute (Update plugins with U key in visual mode):
  908. silent! call RmRf(g:plugs['vim-easy-align'].dir)
  909. PlugStatus
  910. normal VGU
  911. Log getline(1, '$')
  912. AssertExpect 'Updated', 1
  913. AssertExpect 'vim-emoji', 1
  914. AssertExpect 'vim-easy-align', 1
  915. AssertExpect! '[==]', 1
  916. " From PlugUpdate screen
  917. normal VGU
  918. Log getline(1, '$')
  919. AssertExpect 'Updated', 1
  920. AssertExpect 'vim-emoji', 1
  921. AssertExpect 'vim-easy-align', 1
  922. AssertExpect! '[==]', 1
  923. q
  924. **********************************************************************
  925. Execute (plug#begin should expand env vars):
  926. AssertNotEqual '$HOME/.emacs/plugged', expand('$HOME/.emacs/plugged')
  927. call plug#begin('$HOME/.emacs/plugged')
  928. AssertEqual expand('$HOME/.emacs/plugged'), g:plug_home
  929. **********************************************************************
  930. Execute (Plug directory with comma):
  931. call plug#begin(g:temp_plugged . '/p,l,u,g,g,e,d')
  932. Plug 'junegunn/vim-emoji'
  933. call plug#end()
  934. Log &rtp
  935. PlugInstall
  936. q
  937. let found = filter(split(globpath(&rtp, 'README.md'), '\n'), 'v:val =~ ","')
  938. Log found
  939. AssertEqual 1, len(found)
  940. unlet found
  941. **********************************************************************
  942. Execute (Strict load order):
  943. let g:total_order = []
  944. call ReloadPlug()
  945. call plug#begin()
  946. Plug '$PLUG_FIXTURES/xxx'
  947. Plug '$PLUG_FIXTURES/yyy', { 'for': ['xxx'] }
  948. call plug#end()
  949. call EnsureLoaded()
  950. setf xxx
  951. Log 'Case 1: ' . &rtp
  952. AssertEqual ['yyy/ftdetect', 'yyy/after/ftdetect', 'xxx/ftdetect', 'xxx/after/ftdetect'], g:total_order[0:3]
  953. Assert index(g:total_order, 'xxx/plugin') < index(g:total_order, 'yyy/plugin')
  954. Assert index(g:total_order, 'xxx/after/plugin') < index(g:total_order, 'yyy/after/plugin')
  955. let len = len(split(&rtp, ','))
  956. let g:total_order = []
  957. call ReloadPlug()
  958. call plug#begin()
  959. Plug '$PLUG_FIXTURES/xxx', { 'for': ['xxx'] }
  960. Plug '$PLUG_FIXTURES/yyy'
  961. call plug#end()
  962. call EnsureLoaded()
  963. set rtp^=manually-prepended
  964. set rtp+=manually-appended
  965. setf xxx
  966. Log 'Case 2: ' . &rtp
  967. AssertEqual 'manually-prepended', split(&rtp, ',')[3]
  968. AssertEqual 'manually-appended', split(&rtp, ',')[-4]
  969. AssertEqual ['xxx/ftdetect', 'xxx/after/ftdetect', 'yyy/ftdetect', 'yyy/after/ftdetect'], g:total_order[0:3]
  970. Assert index(g:total_order, 'yyy/plugin') < index(g:total_order, 'xxx/plugin')
  971. Assert index(g:total_order, 'yyy/after/plugin') < index(g:total_order, 'xxx/after/plugin')
  972. AssertEqual len + 2, len(split(&rtp, ','))
  973. let g:total_order = []
  974. call ReloadPlug()
  975. set rtp^=manually-prepended
  976. set rtp+=manually-appended
  977. call plug#begin()
  978. Plug '$PLUG_FIXTURES/xxx', { 'for': ['xxx'] }
  979. Plug '$PLUG_FIXTURES/yyy', { 'for': ['xxx'] }
  980. call plug#end()
  981. call EnsureLoaded()
  982. setf xxx
  983. Log 'Case 3: ' . &rtp
  984. AssertEqual ['xxx/ftdetect', 'xxx/after/ftdetect', 'yyy/ftdetect', 'yyy/after/ftdetect'], g:total_order[0:3]
  985. Assert index(g:total_order, 'xxx/plugin') < index(g:total_order, 'yyy/plugin')
  986. Assert index(g:total_order, 'xxx/after/plugin') < index(g:total_order, 'yyy/after/plugin')
  987. AssertEqual len + 2, len(split(&rtp, ','))
  988. **********************************************************************
  989. Execute (PlugClean should not try to remove unmanaged plugins inside g:plug_home):
  990. call plug#begin('$PLUG_FIXTURES')
  991. Plug '$PLUG_FIXTURES/ftplugin-msg', { 'for': [] }
  992. Plug '$PLUG_FIXTURES/fzf'
  993. Plug '$PLUG_FIXTURES/xxx'
  994. Plug '$PLUG_FIXTURES/yyy'
  995. call plug#end()
  996. " Remove z1, z2
  997. PlugClean!
  998. AssertExpect '^- ', 2
  999. AssertExpect 'Already clean', 0
  1000. PlugClean!
  1001. AssertExpect '^- ', 0
  1002. AssertExpect 'Already clean', 1
  1003. q
  1004. **********************************************************************
  1005. Execute (PlugSnapshot / #154 issues with paths containing spaces):
  1006. let $TMPDIR = '/tmp'
  1007. call plug#begin('$TMPDIR/plug with spaces')
  1008. Plug 'junegunn/vim-easy-align'
  1009. Plug 'junegunn/seoul256.vim'
  1010. call plug#end()
  1011. PlugClean!
  1012. PlugInstall
  1013. call plug#load('vim-easy-align') " Should properly handle paths with spaces
  1014. PlugSnapshot
  1015. AssertEqual '" Generated by vim-plug', getline(1)
  1016. AssertEqual 0, stridx(getline(6), "silent! let g:plugs['seoul256.vim'].commit = '")
  1017. AssertEqual 0, stridx(getline(7), "silent! let g:plugs['vim-easy-align'].commit = '")
  1018. AssertEqual 'vim', &filetype
  1019. call delete(g:plug_home.'/snapshot.vim')
  1020. execute 'PlugSnapshot' escape(g:plug_home.'/snapshot.vim', ' ')
  1021. AssertEqual 'vim', &filetype
  1022. AssertEqual 'snapshot.vim', fnamemodify(expand('%'), ':t')
  1023. q
  1024. Execute(PlugSnapshot! to overwrite existing file):
  1025. call writefile(['foobar'], g:plug_home.'/snapshot.vim')
  1026. AssertEqual 'foobar', readfile(g:plug_home.'/snapshot.vim')[0]
  1027. execute 'PlugSnapshot!' escape(g:plug_home.'/snapshot.vim', ' ')
  1028. AssertEqual '" Generated by vim-plug', readfile(g:plug_home.'/snapshot.vim')[0]
  1029. q
  1030. **********************************************************************
  1031. Execute (#221 Shallow-clone and tag option):
  1032. call plug#begin(g:temp_plugged)
  1033. Plug 'junegunn/goyo.vim'
  1034. call plug#end()
  1035. PlugInstall
  1036. execute 'cd' g:plugs['goyo.vim'].dir
  1037. Assert len(split(system('git log --oneline'), '\n')) == 1
  1038. Assert filereadable('.git/shallow')
  1039. Plug 'junegunn/goyo.vim', { 'tag': '1.5.3' }
  1040. PlugUpdate
  1041. q
  1042. Assert len(split(system('git log --oneline'), '\n')) > 1
  1043. Assert system('git describe --tag') =~ '^1.5.3'
  1044. Assert !filereadable('.git/shallow')
  1045. cd -
  1046. Execute (#221 Shallow-clone disabled by g:plug_shallow = 0):
  1047. call plug#begin(g:temp_plugged)
  1048. call plug#end()
  1049. PlugClean!
  1050. let g:plug_shallow = 0
  1051. call plug#begin(g:temp_plugged)
  1052. Plug 'junegunn/goyo.vim'
  1053. call plug#end()
  1054. PlugInstall
  1055. q
  1056. execute 'cd' g:plugs['goyo.vim'].dir
  1057. Assert len(split(system('git log --oneline'), '\n')) > 1, 'not shallow'
  1058. Assert !filereadable('.git/shallow'), 'not shallow'
  1059. cd -
  1060. unlet g:plug_shallow
  1061. Execute (#221 Shallow-clone disabled by tag):
  1062. call plug#begin(g:temp_plugged)
  1063. call plug#end()
  1064. PlugClean!
  1065. call plug#begin(g:temp_plugged)
  1066. Plug 'junegunn/goyo.vim', { 'tag': '1.5.3' }
  1067. call plug#end()
  1068. Assert !isdirectory(g:plugs['goyo.vim'].dir)
  1069. PlugInstall
  1070. Assert isdirectory(g:plugs['goyo.vim'].dir)
  1071. q
  1072. execute 'cd' g:plugs['goyo.vim'].dir
  1073. Assert system('git describe --tag') =~ '^1.5.3'
  1074. Assert len(split(system('git log --oneline'), '\n')) > 1
  1075. Assert !filereadable('.git/shallow')
  1076. cd -
  1077. Execute (Commit hash support):
  1078. call plug#begin(g:temp_plugged)
  1079. Plug 'junegunn/goyo.vim', { 'commit': 'ffffffff' }
  1080. Plug 'junegunn/vim-emoji', { 'commit': '9db7fcfee0d90dafdbcb7a32090c0a9085eb054a' }
  1081. call plug#end()
  1082. PlugUpdate
  1083. Log getline(1, '$')
  1084. AssertEqual ['x Checking out fffffff of goyo.vim ... Error',
  1085. \' error: pathspec ''ffffffff'' did not match any file(s) known to git.',
  1086. \'- Checking out 9db7fcf of vim-emoji ... OK'], getline(5, 7)
  1087. let hash = system(printf('cd %s && git rev-parse HEAD', g:plugs['vim-emoji'].dir))[:-2]
  1088. AssertEqual '9db7fcfee0d90dafdbcb7a32090c0a9085eb054a', hash
  1089. " Validate error formatting
  1090. PlugStatus
  1091. Log getline(1, '$')
  1092. AssertEqual ['Finished. 1 error(s).',
  1093. \'[==]',
  1094. \'',
  1095. \'x goyo.vim:'], getline(1, 4)
  1096. Assert getline(5) =~ ' Invalid HEAD (expected: fffffff, actual: [0-9a-f]\{7})'
  1097. AssertEqual [' PlugUpdate required.',
  1098. \'- vim-emoji: OK'], getline(6, '$')
  1099. " PlugDiff should show pending updates for vim-emoji
  1100. PlugDiff
  1101. Log getline(1, '$')
  1102. AssertEqual '0 plugin(s) updated. 1 plugin(s) have pending updates.', getline(1)
  1103. Assert !empty(mapcheck('o'))
  1104. Assert empty(mapcheck('X'))
  1105. Assert !empty(mapcheck("\<cr>"))
  1106. " Nor in PlugSnapshot output
  1107. PlugSnapshot
  1108. Log getline(1, '$')
  1109. AssertEqual 8, line('$')
  1110. q
  1111. Execute (Commit hash support - cleared):
  1112. call plug#begin(g:temp_plugged)
  1113. Plug 'junegunn/goyo.vim'
  1114. Plug 'junegunn/vim-emoji'
  1115. call plug#end()
  1116. PlugInstall
  1117. let hash = system(printf('cd %s && git rev-parse HEAD', g:plugs['vim-emoji'].dir))[:-2]
  1118. AssertEqual '9db7fcfee0d90dafdbcb7a32090c0a9085eb054a', hash
  1119. PlugUpdate
  1120. let hash = system(printf('cd %s && git rev-parse HEAD', g:plugs['vim-emoji'].dir))[:-2]
  1121. AssertNotEqual '9db7fcfee0d90dafdbcb7a32090c0a9085eb054a', hash
  1122. q