workflow.vader 51 KB

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