2016-04-28 19:58:24 -07:00
|
|
|
-- Tests for 'packpath' and :packadd
|
2016-04-28 16:23:15 -07:00
|
|
|
|
|
|
|
local helpers = require('test.functional.helpers')(after_each)
|
|
|
|
local clear, source = helpers.clear, helpers.source
|
|
|
|
local call, eq, nvim = helpers.call, helpers.eq, helpers.meths
|
|
|
|
|
|
|
|
local function expected_empty()
|
|
|
|
eq({}, nvim.get_vvar('errors'))
|
|
|
|
end
|
|
|
|
|
2016-04-28 19:58:24 -07:00
|
|
|
describe('packadd', function()
|
|
|
|
before_each(function()
|
2016-04-28 16:23:15 -07:00
|
|
|
clear()
|
|
|
|
|
|
|
|
source([=[
|
2016-04-28 17:47:27 -07:00
|
|
|
func SetUp()
|
|
|
|
let s:topdir = expand('%:p:h') . '/Xdir'
|
|
|
|
exe 'set packpath=' . s:topdir
|
|
|
|
let s:plugdir = s:topdir . '/pack/mine/opt/mytest'
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
func TearDown()
|
|
|
|
call delete(s:topdir, 'rf')
|
|
|
|
endfunc
|
|
|
|
|
2016-04-28 19:58:24 -07:00
|
|
|
func Test_packadd()
|
2016-04-28 17:47:27 -07:00
|
|
|
call mkdir(s:plugdir . '/plugin', 'p')
|
|
|
|
call mkdir(s:plugdir . '/ftdetect', 'p')
|
|
|
|
set rtp&
|
|
|
|
let rtp = &rtp
|
2016-04-28 16:23:15 -07:00
|
|
|
filetype on
|
2016-04-28 17:47:27 -07:00
|
|
|
|
|
|
|
exe 'split ' . s:plugdir . '/plugin/test.vim'
|
|
|
|
call setline(1, 'let g:plugin_works = 42')
|
|
|
|
wq
|
|
|
|
|
|
|
|
exe 'split ' . s:plugdir . '/ftdetect/test.vim'
|
|
|
|
call setline(1, 'let g:ftdetect_works = 17')
|
|
|
|
wq
|
|
|
|
|
2016-04-28 19:58:24 -07:00
|
|
|
packadd mytest
|
2016-04-28 17:47:27 -07:00
|
|
|
|
|
|
|
call assert_true(42, g:plugin_works)
|
|
|
|
call assert_true(17, g:ftdetect_works)
|
|
|
|
call assert_true(len(&rtp) > len(rtp))
|
|
|
|
call assert_true(&rtp =~ (s:plugdir . '\($\|,\)'))
|
|
|
|
endfunc
|
|
|
|
|
2016-04-28 19:58:24 -07:00
|
|
|
func Test_packadd_noload()
|
|
|
|
call mkdir(s:plugdir . '/plugin', 'p')
|
2016-04-28 17:47:27 -07:00
|
|
|
call mkdir(s:plugdir . '/syntax', 'p')
|
|
|
|
set rtp&
|
|
|
|
let rtp = &rtp
|
2016-04-28 19:58:24 -07:00
|
|
|
|
|
|
|
exe 'split ' . s:plugdir . '/plugin/test.vim'
|
|
|
|
call setline(1, 'let g:plugin_works = 42')
|
|
|
|
wq
|
|
|
|
let g:plugin_works = 0
|
|
|
|
|
|
|
|
packadd! mytest
|
|
|
|
|
2016-04-28 17:47:27 -07:00
|
|
|
call assert_true(len(&rtp) > len(rtp))
|
|
|
|
call assert_true(&rtp =~ (s:plugdir . '\($\|,\)'))
|
2016-04-28 19:58:24 -07:00
|
|
|
call assert_equal(0, g:plugin_works)
|
2016-04-28 17:47:27 -07:00
|
|
|
|
|
|
|
" check the path is not added twice
|
|
|
|
let new_rtp = &rtp
|
2016-04-28 19:58:24 -07:00
|
|
|
packadd! mytest
|
2016-04-28 17:47:27 -07:00
|
|
|
call assert_equal(new_rtp, &rtp)
|
2016-04-28 16:23:15 -07:00
|
|
|
endfunc
|
|
|
|
]=])
|
2016-04-28 17:47:27 -07:00
|
|
|
call('SetUp')
|
|
|
|
end)
|
|
|
|
|
2016-04-28 19:58:24 -07:00
|
|
|
after_each(function()
|
2016-04-28 17:47:27 -07:00
|
|
|
call('TearDown')
|
2016-04-28 16:23:15 -07:00
|
|
|
end)
|
|
|
|
|
|
|
|
it('is working', function()
|
2016-04-28 19:58:24 -07:00
|
|
|
call('Test_packadd')
|
2016-04-28 16:23:15 -07:00
|
|
|
expected_empty()
|
|
|
|
end)
|
2016-04-28 17:47:27 -07:00
|
|
|
|
2016-04-28 19:58:24 -07:00
|
|
|
it('works with packadd!', function()
|
|
|
|
call('Test_packadd_noload')
|
2016-04-28 17:47:27 -07:00
|
|
|
expected_empty()
|
|
|
|
end)
|
2016-04-28 16:23:15 -07:00
|
|
|
end)
|