workflow.vader 50 KB

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