log: set $NVIM_LOG_FILE; fallback to $XDG_DATA_HOME/nvim/log

This commit is contained in:
Justin M. Keyes
2017-05-31 02:04:03 +02:00
parent 05cdbbc18b
commit bb96b8219d
2 changed files with 60 additions and 28 deletions

View File

@@ -121,6 +121,36 @@ describe('startup defaults', function()
it('v:progpath is set to the absolute path', function()
eq(eval("fnamemodify(v:progpath, ':p')"), eval('v:progpath'))
end)
describe('$NVIM_LOG_FILE', function()
after_each(function()
os.remove('Xtest-logpath')
end)
it('is used if expansion succeeds', function()
clear({env={
NVIM_LOG_FILE='Xtest-logpath',
}})
eq('Xtest-logpath', eval('$NVIM_LOG_FILE'))
end)
it('defaults to stdpath("data")/log', function()
clear({env={
XDG_DATA_HOME='Xtest-startup-logpath',
NVIM_LOG_FILE='', -- Empty value is considered invalid.
}})
-- TODO(jkeyes): use stdpath('data') instead.
local dir = helpers.iswin() and 'nvim-data' or 'nvim'
eq('Xtest-startup-logpath/'..dir..'/log', string.gsub(eval('$NVIM_LOG_FILE'), '\\', '/'))
end)
it('if invalid, falls back to default', function()
clear({env={
XDG_DATA_HOME='Xtest-startup-logpath',
NVIM_LOG_FILE='.', -- Directory is considered invalid.
}})
-- TODO(jkeyes): use stdpath('data') instead.
local dir = helpers.iswin() and 'nvim-data' or 'nvim'
eq('Xtest-startup-logpath/'..dir..'/log', string.gsub(eval('$NVIM_LOG_FILE'), '\\', '/'))
end)
end)
end)
describe('XDG-based defaults', function()