workflow.vader 46 KB

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