aboutsummaryrefslogtreecommitdiff
path: root/test/functional/options
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/options')
-rw-r--r--test/functional/options/defaults_spec.lua97
-rw-r--r--test/functional/options/pastetoggle_spec.lua40
-rw-r--r--test/functional/options/shortmess_spec.lua8
-rw-r--r--test/functional/options/tabstop_spec.lua23
4 files changed, 153 insertions, 15 deletions
diff --git a/test/functional/options/defaults_spec.lua b/test/functional/options/defaults_spec.lua
index f57fe5fa23..b83b7b8eee 100644
--- a/test/functional/options/defaults_spec.lua
+++ b/test/functional/options/defaults_spec.lua
@@ -3,11 +3,13 @@ local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local meths = helpers.meths
-local execute = helpers.execute
+local command = helpers.command
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',
@@ -23,13 +25,13 @@ describe('startup defaults', function()
if helpers.pending_win32(pending) then return end
local function expect_filetype(expected)
- local screen = Screen.new(48, 4)
+ local screen = Screen.new(50, 4)
screen:attach()
- execute('filetype')
+ command('filetype')
screen:expect([[
- ^ |
- ~ |
- ~ |
+ ^ |
+ ~ |
+ ~ |
]]..expected
)
end
@@ -37,31 +39,49 @@ describe('startup defaults', function()
it('enabled by `-u NORC`', function()
init_session('-u', 'NORC')
expect_filetype(
- 'filetype detection:ON plugin:ON indent:ON |')
+ 'filetype detection:ON plugin:ON indent:ON |')
end)
it('disabled by `-u NONE`', function()
init_session('-u', 'NONE')
expect_filetype(
- 'filetype detection:OFF plugin:OFF indent:OFF |')
+ 'filetype detection:OFF plugin:OFF indent:OFF |')
end)
it('overridden by early `filetype on`', function()
init_session('-u', 'NORC', '--cmd', 'filetype on')
expect_filetype(
- 'filetype detection:ON plugin:OFF indent:OFF |')
+ 'filetype detection:ON plugin:OFF indent:OFF |')
end)
it('overridden by early `filetype plugin on`', function()
init_session('-u', 'NORC', '--cmd', 'filetype plugin on')
expect_filetype(
- 'filetype detection:ON plugin:ON indent:OFF |')
+ 'filetype detection:ON plugin:ON indent:OFF |')
end)
it('overridden by early `filetype indent on`', function()
init_session('-u', 'NORC', '--cmd', 'filetype indent on')
expect_filetype(
- 'filetype detection:ON plugin:OFF indent:ON |')
+ 'filetype detection:ON plugin:OFF indent:ON |')
+ end)
+
+ it('adjusted by late `filetype off`', function()
+ init_session('-u', 'NORC', '-c', 'filetype off')
+ expect_filetype(
+ 'filetype detection:OFF plugin:(on) indent:(on) |')
+ end)
+
+ it('adjusted by late `filetype plugin off`', function()
+ init_session('-u', 'NORC', '-c', 'filetype plugin off')
+ expect_filetype(
+ 'filetype detection:ON plugin:OFF indent:ON |')
+ end)
+
+ it('adjusted by late `filetype indent off`', function()
+ init_session('-u', 'NORC', '-c', 'filetype indent off')
+ expect_filetype(
+ 'filetype detection:ON plugin:ON indent:OFF |')
end)
end)
@@ -80,6 +100,11 @@ describe('startup defaults', function()
init_session('-u', 'NORC', '--cmd', 'syntax off')
eq(0, eval('exists("g:syntax_on")'))
end)
+
+ it('adjusted by late `syntax off`', function()
+ init_session('-u', 'NORC', '-c', 'syntax off')
+ eq(0, eval('exists("g:syntax_on")'))
+ end)
end)
describe('packpath', function()
@@ -98,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()
diff --git a/test/functional/options/pastetoggle_spec.lua b/test/functional/options/pastetoggle_spec.lua
new file mode 100644
index 0000000000..a1f86f73ff
--- /dev/null
+++ b/test/functional/options/pastetoggle_spec.lua
@@ -0,0 +1,40 @@
+local helpers = require('test.functional.helpers')(after_each)
+
+local clear = helpers.clear
+local feed = helpers.feed
+local command = helpers.command
+local eq = helpers.eq
+local eval = helpers.eval
+local sleep = helpers.sleep
+local expect = helpers.expect
+
+describe("'pastetoggle' option", function()
+ before_each(function()
+ clear()
+ command('set nopaste')
+ end)
+
+ it("toggles 'paste'", function()
+ command('set pastetoggle=a')
+ eq(0, eval('&paste'))
+ feed('a')
+ -- Need another key so that the vgetorpeek() function returns.
+ feed('j')
+ eq(1, eval('&paste'))
+ end)
+
+
+ it('does not wait for timeout', function()
+ command('set pastetoggle=abc')
+ command('set ttimeoutlen=9999999')
+ eq(0, eval('&paste'))
+ -- n.b. need <esc> to return from vgetorpeek()
+ feed('abc<esc>')
+ eq(1, eval('&paste'))
+ feed('ab')
+ sleep(10)
+ feed('c<esc>')
+ expect('bc')
+ eq(1, eval('&paste'))
+ end)
+end)
diff --git a/test/functional/options/shortmess_spec.lua b/test/functional/options/shortmess_spec.lua
index 22e8a39b79..99a574ec46 100644
--- a/test/functional/options/shortmess_spec.lua
+++ b/test/functional/options/shortmess_spec.lua
@@ -1,6 +1,6 @@
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
-local clear, execute = helpers.clear, helpers.execute
+local clear, feed_command = helpers.clear, helpers.feed_command
if helpers.pending_win32(pending) then return end
@@ -19,7 +19,7 @@ describe("'shortmess'", function()
describe('"F" flag', function()
it('hides messages about the files read', function()
- execute('e test')
+ feed_command('e test')
screen:expect([[
^ |
~ |
@@ -27,8 +27,8 @@ describe("'shortmess'", function()
~ |
"test" is a directory |
]])
- execute('set shortmess=F')
- execute('e test')
+ feed_command('set shortmess=F')
+ feed_command('e test')
screen:expect([[
^ |
~ |
diff --git a/test/functional/options/tabstop_spec.lua b/test/functional/options/tabstop_spec.lua
new file mode 100644
index 0000000000..dc3ba38438
--- /dev/null
+++ b/test/functional/options/tabstop_spec.lua
@@ -0,0 +1,23 @@
+local helpers = require('test.functional.helpers')(after_each)
+
+local clear = helpers.clear
+local feed = helpers.feed
+local eq = helpers.eq
+local eval = helpers.eval
+
+describe("'tabstop' option", function()
+ before_each(function()
+ clear()
+ end)
+
+ -- NOTE: Setting 'tabstop' to a big number reproduces crash #2838.
+ -- Disallowing big 'tabstop' would not fix #2838, only hide it.
+ it("tabstop=<big-number> does not crash #2838", function()
+ -- Insert a <Tab> character for 'tabstop' to work with.
+ feed('i<Tab><Esc>')
+ -- Set 'tabstop' to a very high value.
+ -- Use feed(), not command(), to provoke crash.
+ feed(':set tabstop=3000000000<CR>')
+ eq(2, eval("1+1")) -- Still alive?
+ end)
+end)