workflow.vader 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746
  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. Plug '$PLUG_FIXTURES/cant-delete'
  1245. call plug#end()
  1246. " Remove z1, z2
  1247. PlugClean!
  1248. AssertExpect '^\~ ', 2
  1249. AssertExpect 'Already clean', 0
  1250. PlugClean!
  1251. AssertExpect '^\~ ', 0
  1252. AssertExpect 'Already clean', 1
  1253. q
  1254. **********************************************************************
  1255. Execute (PlugSnapshot / #154 issues with paths containing spaces):
  1256. let $TMPDIR = '/tmp'
  1257. call plug#begin('$TMPDIR/plug with spaces')
  1258. Plug 'junegunn/vim-easy-align'
  1259. Plug 'junegunn/seoul256.vim'
  1260. call plug#end()
  1261. PlugClean!
  1262. PlugInstall
  1263. call plug#load('vim-easy-align') " Should properly handle paths with spaces
  1264. PlugSnapshot
  1265. AssertEqual '" Generated by vim-plug', getline(1)
  1266. AssertEqual 0, stridx(getline(6), "silent! let g:plugs['seoul256.vim'].commit = '")
  1267. AssertEqual 0, stridx(getline(7), "silent! let g:plugs['vim-easy-align'].commit = '")
  1268. AssertEqual 'vim', &filetype
  1269. call delete(g:plug_home.'/snapshot.vim')
  1270. execute 'PlugSnapshot' escape(g:plug_home.'/snapshot.vim', ' ')
  1271. AssertEqual 'vim', &filetype
  1272. AssertEqual 'snapshot.vim', fnamemodify(expand('%'), ':t')
  1273. q
  1274. Execute(PlugSnapshot! to overwrite existing file):
  1275. call writefile(['foobar'], g:plug_home.'/snapshot.vim')
  1276. AssertEqual 'foobar', readfile(g:plug_home.'/snapshot.vim')[0]
  1277. execute 'PlugSnapshot!' escape(g:plug_home.'/snapshot.vim', ' ')
  1278. AssertEqual '" Generated by vim-plug', readfile(g:plug_home.'/snapshot.vim')[0]
  1279. q
  1280. **********************************************************************
  1281. Execute (#221 Shallow-clone and tag option):
  1282. call plug#begin(g:temp_plugged)
  1283. Plug 'junegunn/goyo.vim'
  1284. call plug#end()
  1285. PlugInstall
  1286. execute 'cd' g:plugs['goyo.vim'].dir
  1287. Assert len(split(system('git log --oneline'), '\n')) == 1
  1288. Assert filereadable('.git/shallow')
  1289. Plug 'junegunn/goyo.vim', { 'tag': '1.5.3' }
  1290. PlugUpdate
  1291. q
  1292. Assert len(split(system('git log --oneline'), '\n')) > 1
  1293. Assert system('git describe --tag') =~ '^1.5.3'
  1294. Assert !filereadable('.git/shallow')
  1295. cd -
  1296. Execute (#221 Shallow-clone disabled by g:plug_shallow = 0):
  1297. call plug#begin(g:temp_plugged)
  1298. call plug#end()
  1299. PlugClean!
  1300. let g:plug_shallow = 0
  1301. call plug#begin(g:temp_plugged)
  1302. Plug 'junegunn/goyo.vim'
  1303. call plug#end()
  1304. PlugInstall
  1305. q
  1306. execute 'cd' g:plugs['goyo.vim'].dir
  1307. Assert len(split(system('git log --oneline'), '\n')) > 1, 'not shallow'
  1308. Assert !filereadable('.git/shallow'), 'not shallow'
  1309. cd -
  1310. unlet g:plug_shallow
  1311. Execute (#221 Shallow-clone disabled by tag):
  1312. call plug#begin(g:temp_plugged)
  1313. call plug#end()
  1314. PlugClean!
  1315. call plug#begin(g:temp_plugged)
  1316. Plug 'junegunn/goyo.vim', { 'tag': '1.5.3' }
  1317. call plug#end()
  1318. Assert !isdirectory(g:plugs['goyo.vim'].dir)
  1319. PlugInstall
  1320. Assert isdirectory(g:plugs['goyo.vim'].dir)
  1321. q
  1322. execute 'cd' g:plugs['goyo.vim'].dir
  1323. Assert system('git describe --tag') =~ '^1.5.3'
  1324. Assert len(split(system('git log --oneline'), '\n')) > 1
  1325. Assert !filereadable('.git/shallow')
  1326. cd -
  1327. Execute (Commit hash support):
  1328. " Get goyo back to master
  1329. call plug#begin(g:temp_plugged)
  1330. Plug 'junegunn/goyo.vim'
  1331. call plug#end()
  1332. PlugUpdate
  1333. call plug#begin(g:temp_plugged)
  1334. Plug 'junegunn/goyo.vim', { 'commit': 'ffffffff' }
  1335. Plug 'junegunn/vim-emoji', { 'commit': '9db7fcfee0d90dafdbcb7a32090c0a9085eb054a' }
  1336. call plug#end()
  1337. PlugUpdate
  1338. Log getline(1, '$')
  1339. AssertEqual 'x goyo.vim:', getline(5)
  1340. AssertEqual ' fatal: invalid reference: ffffffff', getline(6)
  1341. AssertEqual 0, stridx(getline(7), '- vim-emoji: HEAD is now at 9db7fcf')
  1342. let hash = system(printf('cd %s && git rev-parse HEAD', g:plugs['vim-emoji'].dir))[:-2]
  1343. AssertEqual '9db7fcfee0d90dafdbcb7a32090c0a9085eb054a', hash
  1344. " Validate error formatting
  1345. PlugStatus
  1346. Log getline(1, '$')
  1347. AssertEqual ['Finished. 1 error(s).',
  1348. \'[==]',
  1349. \'',
  1350. \'x goyo.vim:'], getline(1, 4)
  1351. Assert getline(5) =~ ' Invalid HEAD (expected: fffffff, actual: [0-9a-f]\{7})'
  1352. AssertEqual [' PlugUpdate required.',
  1353. \'- vim-emoji: OK'], getline(6, '$')
  1354. " PlugDiff should show pending updates for vim-emoji
  1355. PlugDiff
  1356. Log getline(1, '$')
  1357. AssertEqual '0 plugin(s) updated. 1 plugin(s) have pending updates.', getline(1)
  1358. Assert !empty(mapcheck('o'))
  1359. Assert empty(mapcheck('X'))
  1360. Assert !empty(mapcheck("\<cr>"))
  1361. " Nor in PlugSnapshot output
  1362. PlugSnapshot
  1363. Log getline(1, '$')
  1364. AssertEqual 8, line('$')
  1365. q
  1366. Execute (Commit hash support - cleared):
  1367. call plug#begin(g:temp_plugged)
  1368. Plug 'junegunn/goyo.vim'
  1369. Plug 'junegunn/vim-emoji'
  1370. call plug#end()
  1371. PlugInstall
  1372. let hash = system(printf('cd %s && git rev-parse HEAD', g:plugs['vim-emoji'].dir))[:-2]
  1373. AssertEqual '9db7fcfee0d90dafdbcb7a32090c0a9085eb054a', hash
  1374. PlugUpdate
  1375. let hash = system(printf('cd %s && git rev-parse HEAD', g:plugs['vim-emoji'].dir))[:-2]
  1376. AssertNotEqual '9db7fcfee0d90dafdbcb7a32090c0a9085eb054a', hash
  1377. q
  1378. Execute (#371 - 'as' option):
  1379. call plug#begin()
  1380. Plug 'jg/goyo.vim'
  1381. Plug 'junegunn/goyo.vim', {'as': 'yogo'}
  1382. call plug#end()
  1383. AssertEqual ['goyo.vim', 'yogo'], sort(keys(g:plugs))
  1384. Log g:plugs
  1385. Assert g:plugs.yogo.dir =~# '/yogo/$'
  1386. call plug#begin()
  1387. Plug 'junegunn/goyo.vim', {'as': 'yogo', 'dir': '/tmp/vim-plug-test/gogo'}
  1388. call plug#end()
  1389. AssertEqual ['yogo'], sort(keys(g:plugs))
  1390. AssertEqual '/tmp/vim-plug-test/gogo/', g:plugs.yogo.dir
  1391. Execute (#427 - Tag option with wildcard (requires git 1.9.2 or above)):
  1392. if str2nr(split(split(system('git --version'))[-1], '\.')[0]) < 2
  1393. Log 'tag with wildcard requires git 1.9.2 or above'
  1394. else
  1395. call plug#begin()
  1396. Plug 'junegunn/vim-easy-align', { 'tag': '2.9.*' }
  1397. call plug#end()
  1398. PlugInstall!
  1399. Log getline(1, '$')
  1400. AssertExpect! '- Latest tag for 2.9.* -> 2.9.7 (vim-easy-align)', 1
  1401. q
  1402. AssertEqual '2.9.7', GitTag('vim-easy-align')
  1403. endif
  1404. Execute (#530 - Comparison of compatible git URIs):
  1405. " .git suffix
  1406. Assert CompareURI('https://github.com/junegunn/vim-plug.git', 'https://github.com/junegunn/vim-plug')
  1407. " user@
  1408. Assert CompareURI('https://github.com/junegunn/vim-plug.git', 'https://user@github.com/junegunn/vim-plug.git')
  1409. " git::@
  1410. Assert CompareURI('https://github.com/junegunn/vim-plug.git', 'https://git::@github.com/junegunn/vim-plug.git')
  1411. " https and ssh
  1412. Assert CompareURI('https://github.com/junegunn/vim-plug.git', 'git@github.com:junegunn/vim-plug.git')
  1413. " file://
  1414. Assert CompareURI('file:///tmp/vim-plug', '/tmp/vim-plug')
  1415. Assert CompareURI('file:///tmp/vim-plug', '/tmp/vim-plug/')
  1416. Execute (#530 - Comparison of incompatible git URIs):
  1417. " Different hostname
  1418. Assert !CompareURI('https://github.com/junegunn/vim-plug.git', 'https://bitbucket.com/junegunn/vim-plug.git')
  1419. " Different repository
  1420. Assert !CompareURI('https://github.com/junegunn/vim-plug.git', 'https://github.com/junegunn/emacs-plug.git')
  1421. " Different port
  1422. Assert !CompareURI('https://github.com/junegunn/vim-plug.git', 'https://github.com:12345/junegunn/vim-plug.git')
  1423. Execute (#532 - Reuse plug window):
  1424. call plug#begin()
  1425. Plug 'junegunn/goyo.vim'
  1426. call plug#end()
  1427. PlugInstall
  1428. call system(printf('cd "%s" && git commit --allow-empty -m "dummy"', g:plugs['goyo.vim'].dir))
  1429. PlugDiff
  1430. AssertEqual 1, winnr(), 'Current window is #1 after PlugDiff (but is '.winnr().')'
  1431. AssertEqual 2, winnr('$'), 'Two windows after PlugDiff (but got '.winnr('$').')'
  1432. " Open preview window
  1433. execute "normal ]]jo"
  1434. AssertEqual 2, winnr(), 'Current window is #2 after opening preview (but is '.winnr().')'
  1435. AssertEqual 3, winnr('$'), 'Three windows with preview (but got '.winnr('$').')'
  1436. " Move plug window to the right
  1437. wincmd L
  1438. AssertEqual 3, winnr(), 'Current window is #3 after moving window (but is '.winnr().')'
  1439. AssertEqual 3, winnr('$'), 'Three windows after moving window (but got '.winnr('$').')'
  1440. " Reuse plug window. Preview window is closed.
  1441. PlugStatus
  1442. AssertEqual 2, winnr(), 'Current window is #2 after PlugStatus (but is '.winnr().')'
  1443. AssertEqual 2, winnr('$'), 'Three windows after PlugStatus (but got '.winnr('$').')'
  1444. q
  1445. Execute (#766 - Allow cloning into an empty directory):
  1446. let d = '/tmp/vim-plug-test/goyo-already'
  1447. call system('rm -rf ' . d)
  1448. call mkdir(d)
  1449. call plug#begin()
  1450. Plug 'junegunn/goyo.vim', { 'dir': d }
  1451. call plug#end()
  1452. PlugInstall
  1453. AssertExpect! '[=]', 1
  1454. q
  1455. unlet d
  1456. Execute (#982 - PlugClean should report when directories cannot be removed):
  1457. call plug#begin('$PLUG_FIXTURES')
  1458. Plug '$PLUG_FIXTURES/ftplugin-msg', { 'for': [] }
  1459. Plug '$PLUG_FIXTURES/fzf'
  1460. Plug '$PLUG_FIXTURES/xxx'
  1461. Plug '$PLUG_FIXTURES/yyy'
  1462. call plug#end()
  1463. " Fail to remove cant-delete
  1464. PlugClean!
  1465. AssertEqual 'Removed 0 directories. Failed to remove 1 directories.', getline(4)
  1466. AssertExpect '^x ', 1
  1467. q
  1468. " Delete tmp but fail to remove cant-delete
  1469. call mkdir(expand('$PLUG_FIXTURES/tmp'))
  1470. PlugClean!
  1471. AssertEqual 'Removed 1 directories. Failed to remove 1 directories.', getline(4)
  1472. AssertExpect '^x ', 1
  1473. AssertExpect '^\~ ', 1
  1474. q