workflow.vader 51 KB

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