2017-06-06 06:02:48 -05:00
|
|
|
local lfs = require('lfs')
|
|
|
|
local helpers = require('test.functional.helpers')(after_each)
|
|
|
|
|
|
|
|
local clear = helpers.clear
|
|
|
|
local command = helpers.command
|
|
|
|
local get_pathsep = helpers.get_pathsep
|
|
|
|
local eq = helpers.eq
|
|
|
|
local funcs = helpers.funcs
|
2018-01-31 20:12:37 -06:00
|
|
|
local rmdir = helpers.rmdir
|
2017-06-06 06:02:48 -05:00
|
|
|
|
|
|
|
local file_prefix = 'Xtest-functional-ex_cmds-mksession_spec'
|
|
|
|
|
|
|
|
describe(':mksession', function()
|
|
|
|
local session_file = file_prefix .. '.vim'
|
|
|
|
local tab_dir = file_prefix .. '.d'
|
|
|
|
|
|
|
|
before_each(function()
|
|
|
|
clear()
|
|
|
|
lfs.mkdir(tab_dir)
|
|
|
|
end)
|
|
|
|
|
|
|
|
after_each(function()
|
|
|
|
os.remove(session_file)
|
2018-01-31 20:12:37 -06:00
|
|
|
rmdir(tab_dir)
|
2017-06-06 06:02:48 -05:00
|
|
|
end)
|
|
|
|
|
|
|
|
it('restores tab-local working directories', function()
|
|
|
|
local tmpfile_base = file_prefix .. '-tmpfile'
|
|
|
|
local cwd_dir = funcs.getcwd()
|
|
|
|
|
|
|
|
-- :mksession does not save empty tabs, so create some buffers.
|
|
|
|
command('edit ' .. tmpfile_base .. '1')
|
|
|
|
command('tabnew')
|
|
|
|
command('edit ' .. tmpfile_base .. '2')
|
|
|
|
command('tcd ' .. tab_dir)
|
|
|
|
command('tabfirst')
|
|
|
|
command('mksession ' .. session_file)
|
|
|
|
|
|
|
|
-- Create a new test instance of Nvim.
|
|
|
|
clear()
|
|
|
|
|
|
|
|
command('source ' .. session_file)
|
|
|
|
-- First tab should have the original working directory.
|
|
|
|
command('tabnext 1')
|
|
|
|
eq(cwd_dir, funcs.getcwd())
|
|
|
|
-- Second tab should have the tab-local working directory.
|
|
|
|
command('tabnext 2')
|
|
|
|
eq(cwd_dir .. get_pathsep() .. tab_dir, funcs.getcwd())
|
|
|
|
end)
|
|
|
|
end)
|