workflow.vader 46 KB

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