workflow.vader 51 KB

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