diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2017-05-31 18:12:26 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2017-06-07 00:27:26 +0200 |
commit | d07661b9a38225e1a29465bbbe54c99ca4038392 (patch) | |
tree | fde61ef55c2723123e640c447d33e1a8cb5cbc71 /test/functional | |
parent | a49c92fc5b12cd9645b8638b409442ad3ca652bc (diff) | |
download | rneovim-d07661b9a38225e1a29465bbbe54c99ca4038392.tar.gz rneovim-d07661b9a38225e1a29465bbbe54c99ca4038392.tar.bz2 rneovim-d07661b9a38225e1a29465bbbe54c99ca4038392.zip |
log: Fall back to CWD-relative .nvimlog
If if the resolved $NVIM_LOG_FILE *and* stdpath("data")/log cannot be
created (e.g. because the XDG data directory does not exist), fall back
to .nvimlog in the current direcrtory.
Diffstat (limited to 'test/functional')
-rw-r--r-- | test/functional/options/defaults_spec.lua | 46 |
1 files changed, 34 insertions, 12 deletions
diff --git a/test/functional/options/defaults_spec.lua b/test/functional/options/defaults_spec.lua index 34921df6d4..b83b7b8eee 100644 --- a/test/functional/options/defaults_spec.lua +++ b/test/functional/options/defaults_spec.lua @@ -8,6 +8,8 @@ local clear = helpers.clear local eval = helpers.eval local eq = helpers.eq local neq = helpers.neq +local mkdir = helpers.mkdir +local rmdir = helpers.rmdir local function init_session(...) local args = { helpers.nvim_prog, '-i', 'NONE', '--embed', @@ -123,32 +125,52 @@ describe('startup defaults', function() end) describe('$NVIM_LOG_FILE', function() + -- TODO(jkeyes): use stdpath('data') instead. + local datasubdir = helpers.iswin() and 'nvim-data' or 'nvim' + local xdgdir = 'Xtest-startup-xdg-logpath' + local xdgdatadir = xdgdir..'/'..datasubdir after_each(function() os.remove('Xtest-logpath') + rmdir(xdgdir) 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() + it('defaults to stdpath("data")/log if empty', function() + eq(true, mkdir(xdgdir) and mkdir(xdgdatadir)) clear({env={ - XDG_DATA_HOME='Xtest-startup-logpath', - NVIM_LOG_FILE='', -- Empty value is considered invalid. + XDG_DATA_HOME=xdgdir, + NVIM_LOG_FILE='', -- Empty is 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'), '\\', '/')) + -- server_start() calls ELOG, which tickles log_path_init(). + pcall(command, 'call serverstart(serverlist()[0])') + + eq(xdgdir..'/'..datasubdir..'/log', string.gsub(eval('$NVIM_LOG_FILE'), '\\', '/')) end) - it('if invalid, falls back to default', function() + it('defaults to stdpath("data")/log if invalid', function() + eq(true, mkdir(xdgdir) and mkdir(xdgdatadir)) clear({env={ - XDG_DATA_HOME='Xtest-startup-logpath', - NVIM_LOG_FILE='.', -- Directory is considered invalid. + XDG_DATA_HOME=xdgdir, + NVIM_LOG_FILE='.', -- Any directory is 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'), '\\', '/')) + -- server_start() calls ELOG, which tickles log_path_init(). + pcall(command, 'call serverstart(serverlist()[0])') + + eq(xdgdir..'/'..datasubdir..'/log', string.gsub(eval('$NVIM_LOG_FILE'), '\\', '/')) + end) + it('defaults to .nvimlog if stdpath("data") is invalid', function() + clear({env={ + XDG_DATA_HOME='Xtest-missing-xdg-dir', + NVIM_LOG_FILE='.', -- Any directory is invalid. + }}) + -- server_start() calls ELOG, which tickles log_path_init(). + pcall(command, 'call serverstart(serverlist()[0])') + + eq('.nvimlog', eval('$NVIM_LOG_FILE')) end) end) end) |