aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2017-06-07 23:19:02 +0200
committerGitHub <noreply@github.com>2017-06-07 23:19:02 +0200
commit16cce1ac17456e3758f95af6ce7289bade3bb285 (patch)
tree1e5bc9c076e6a49dcc750cb686c45a0e371b3a31 /test
parentd3d0c9a7b11cad3f277f732dee6c782d1d911b48 (diff)
parentbc025ab117c92418f890085dc13f26cb7c976772 (diff)
downloadrneovim-16cce1ac17456e3758f95af6ce7289bade3bb285.tar.gz
rneovim-16cce1ac17456e3758f95af6ce7289bade3bb285.tar.bz2
rneovim-16cce1ac17456e3758f95af6ce7289bade3bb285.zip
Merge #6827 'Always enable logging'
Diffstat (limited to 'test')
-rw-r--r--test/README.md2
-rw-r--r--test/functional/helpers.lua2
-rw-r--r--test/functional/options/defaults_spec.lua52
3 files changed, 55 insertions, 1 deletions
diff --git a/test/README.md b/test/README.md
index 2857cc0ecf..01db5960cd 100644
--- a/test/README.md
+++ b/test/README.md
@@ -2,6 +2,8 @@
Tests are run by `/cmake/RunTests.cmake` file, using busted.
+For some failures, `.nvimlog` (or `$NVIM_LOG_FILE`) may provide insight.
+
## Directory structure
Directories with tests: `/test/benchmark` for benchmarks, `/test/functional` for
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua
index 62b0ce1200..b8512c0ad6 100644
--- a/test/functional/helpers.lua
+++ b/test/functional/helpers.lua
@@ -174,7 +174,7 @@ local os_name = (function()
end)()
local function iswin()
- return os_name() == 'windows'
+ return package.config:sub(1,1) == '\\'
end
-- Executes a VimL function.
diff --git a/test/functional/options/defaults_spec.lua b/test/functional/options/defaults_spec.lua
index dc73679bb4..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',
@@ -121,6 +123,56 @@ 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()
+ -- 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 if empty', function()
+ eq(true, mkdir(xdgdir) and mkdir(xdgdatadir))
+ clear({env={
+ XDG_DATA_HOME=xdgdir,
+ NVIM_LOG_FILE='', -- Empty is invalid.
+ }})
+ -- 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 stdpath("data")/log if invalid', function()
+ eq(true, mkdir(xdgdir) and mkdir(xdgdatadir))
+ clear({env={
+ XDG_DATA_HOME=xdgdir,
+ NVIM_LOG_FILE='.', -- Any directory is invalid.
+ }})
+ -- 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)
describe('XDG-based defaults', function()