workflow.vader 51 KB

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