workflow.vader 38 KB

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