aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/core/startup_spec.lua4
-rw-r--r--test/functional/helpers.lua13
-rw-r--r--test/functional/lua/help_spec.lua31
-rw-r--r--test/functional/options/defaults_spec.lua58
4 files changed, 60 insertions, 46 deletions
diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua
index 4f9df4010e..a32c801c97 100644
--- a/test/functional/core/startup_spec.lua
+++ b/test/functional/core/startup_spec.lua
@@ -354,7 +354,9 @@ describe('startup', function()
local function pack_clear(cmd)
-- add packages after config dir in rtp but before config/after
- clear{args={'--cmd', 'set packpath=test/functional/fixtures', '--cmd', 'let paths=split(&rtp, ",")', '--cmd', 'let &rtp = paths[0]..",test/functional/fixtures,test/functional/fixtures/middle,"..join(paths[1:],",")', '--cmd', cmd}, env={XDG_CONFIG_HOME='test/functional/fixtures/'}}
+ clear{args={'--cmd', 'set packpath=test/functional/fixtures', '--cmd', 'let paths=split(&rtp, ",")', '--cmd', 'let &rtp = paths[0]..",test/functional/fixtures,test/functional/fixtures/middle,"..join(paths[1:],",")', '--cmd', cmd}, env={XDG_CONFIG_HOME='test/functional/fixtures/'},
+ args_rm={'runtimepath'},
+ }
end
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua
index eff54b6d4a..3aec834bea 100644
--- a/test/functional/helpers.lua
+++ b/test/functional/helpers.lua
@@ -29,6 +29,7 @@ local module = {
}
local start_dir = lfs.currentdir()
+local runtime_set = 'set runtimepath^=./build/lib/nvim/'
module.nvim_prog = (
os.getenv('NVIM_PRG')
or global_helpers.test_build_dir .. '/bin/nvim'
@@ -40,6 +41,8 @@ module.nvim_set = (
..' belloff= wildoptions-=pum joinspaces noshowcmd noruler nomore redrawdebug=invalid')
module.nvim_argv = {
module.nvim_prog, '-u', 'NONE', '-i', 'NONE',
+ -- XXX: find treesitter parsers.
+ '--cmd', runtime_set,
'--cmd', module.nvim_set,
'--cmd', 'mapclear',
'--cmd', 'mapclear!',
@@ -345,14 +348,17 @@ end
-- Removes Nvim startup args from `args` matching items in `args_rm`.
--
--- "-u", "-i", "--cmd" are treated specially: their "values" are also removed.
+-- - Special case: "-u", "-i", "--cmd" are treated specially: their "values" are also removed.
+-- - Special case: "runtimepath" will remove only { '--cmd', 'set runtimepath^=…', }
+--
-- Example:
-- args={'--headless', '-u', 'NONE'}
-- args_rm={'--cmd', '-u'}
-- Result:
-- {'--headless'}
--
--- All cases are removed.
+-- All matching cases are removed.
+--
-- Example:
-- args={'--cmd', 'foo', '-N', '--cmd', 'bar'}
-- args_rm={'--cmd', '-u'}
@@ -373,6 +379,9 @@ local function remove_args(args, args_rm)
last = ''
elseif tbl_contains(args_rm, arg) then
last = arg
+ elseif arg == runtime_set and tbl_contains(args_rm, 'runtimepath') then
+ table.remove(new_args) -- Remove the preceding "--cmd".
+ last = ''
else
table.insert(new_args, arg)
end
diff --git a/test/functional/lua/help_spec.lua b/test/functional/lua/help_spec.lua
index 266f261ab9..2ddabc15ae 100644
--- a/test/functional/lua/help_spec.lua
+++ b/test/functional/lua/help_spec.lua
@@ -12,29 +12,26 @@ describe(':help docs', function()
before_each(clear)
it('validate', function()
-- If this test fails, try these steps (in order):
- -- 1. Try to fix/cleanup the :help docs, especially Nvim-owned :help docs.
- -- 2. Try to fix the parser: https://github.com/vigoux/tree-sitter-vimdoc
+ -- 1. Fix/cleanup the :help docs.
+ -- 2. Fix the parser: https://github.com/neovim/tree-sitter-vimdoc
-- 3. File a parser bug, and adjust the tolerance of this test in the meantime.
local rv = exec_lua([[return require('scripts.gen_help_html').validate('./build/runtime/doc')]])
+ -- Check that we actually found helpfiles.
+ ok(rv.helpfiles > 100, '>100 :help files', rv.helpfiles)
-- Check that parse errors did not increase wildly.
- -- TODO: yes, there are currently 24k+ parser errors.
- -- WIP: https://github.com/vigoux/tree-sitter-vimdoc/pull/16
- ok(rv.err_count < 24000, '<24000', rv.err_count)
- -- TODO: should be eq(0, …)
- ok(exec_lua('return vim.tbl_count(...)', rv.invalid_tags) < 538, '<538',
- exec_lua('return vim.inspect(...)', rv.invalid_tags))
+ -- TODO: Fix all parse errors in :help files.
+ ok(rv.err_count < 1300, '<1300 parse errors', rv.err_count)
+ eq({}, rv.invalid_links, exec_lua([[return 'found invalid :help tag links:\n'..vim.inspect(...)]], rv.invalid_links))
end)
it('gen_help_html.lua generates HTML', function()
- -- Test:
- -- 1. Check that parse errors did not increase wildly. Because we explicitly test only a few
- -- :help files, we can be more precise about the tolerances here.
- -- 2. exercise gen_help_html.lua, check that it actually works.
- -- 3. check that its tree-sitter-vimdoc dependency is working.
+ -- 1. Test that gen_help_html.lua actually works.
+ -- 2. Test that parse errors did not increase wildly. Because we explicitly test only a few
+ -- :help files, we can be precise about the tolerances here.
local tmpdir = exec_lua('return vim.fs.dirname(vim.fn.tempname())')
- -- Because gen() is slow (1 min), this test is limited to a few files.
+ -- Because gen() is slow (~30s), this test is limited to a few files.
local rv = exec_lua([[
local to_dir = ...
return require('scripts.gen_help_html').gen(
@@ -46,9 +43,7 @@ describe(':help docs', function()
tmpdir
)
eq(4, #rv.helpfiles)
- ok(rv.err_count < 700, '<700', rv.err_count)
- -- TODO: should be eq(0, …)
- ok(exec_lua('return vim.tbl_count(...)', rv.invalid_tags) <= 32, '<=32',
- exec_lua('return vim.inspect(...)', rv.invalid_tags))
+ ok(rv.err_count < 16, '<16 parse errors', rv.err_count)
+ eq({}, rv.invalid_links, exec_lua([[return 'found invalid :help tag links:\n'..vim.inspect(...)]], rv.invalid_links))
end)
end)
diff --git a/test/functional/options/defaults_spec.lua b/test/functional/options/defaults_spec.lua
index 4e2f2ab63e..130ed73c34 100644
--- a/test/functional/options/defaults_spec.lua
+++ b/test/functional/options/defaults_spec.lua
@@ -220,7 +220,9 @@ describe('startup defaults', function()
end)
it("'packpath'", function()
- clear()
+ clear{
+ args_rm={'runtimepath'},
+ }
-- Defaults to &runtimepath.
eq(meths.get_option('runtimepath'), meths.get_option('packpath'))
@@ -332,17 +334,19 @@ describe('XDG defaults', function()
describe('with too long XDG variables', function()
before_each(function()
- clear({env={
- XDG_CONFIG_HOME=(root_path .. ('/x'):rep(4096)),
- XDG_CONFIG_DIRS=(root_path .. ('/a'):rep(2048)
- .. env_sep.. root_path .. ('/b'):rep(2048)
- .. (env_sep .. root_path .. '/c'):rep(512)),
- XDG_DATA_HOME=(root_path .. ('/X'):rep(4096)),
- XDG_RUNTIME_DIR=(root_path .. ('/X'):rep(4096)),
- XDG_STATE_HOME=(root_path .. ('/X'):rep(4096)),
- XDG_DATA_DIRS=(root_path .. ('/A'):rep(2048)
- .. env_sep .. root_path .. ('/B'):rep(2048)
- .. (env_sep .. root_path .. '/C'):rep(512)),
+ clear({
+ args_rm={'runtimepath'},
+ env={
+ XDG_CONFIG_HOME=(root_path .. ('/x'):rep(4096)),
+ XDG_CONFIG_DIRS=(root_path .. ('/a'):rep(2048)
+ .. env_sep.. root_path .. ('/b'):rep(2048)
+ .. (env_sep .. root_path .. '/c'):rep(512)),
+ XDG_DATA_HOME=(root_path .. ('/X'):rep(4096)),
+ XDG_RUNTIME_DIR=(root_path .. ('/X'):rep(4096)),
+ XDG_STATE_HOME=(root_path .. ('/X'):rep(4096)),
+ XDG_DATA_DIRS=(root_path .. ('/A'):rep(2048)
+ .. env_sep .. root_path .. ('/B'):rep(2048)
+ .. (env_sep .. root_path .. '/C'):rep(512)),
}})
end)
@@ -405,13 +409,15 @@ describe('XDG defaults', function()
describe('with XDG variables that can be expanded', function()
before_each(function()
- clear({env={
- XDG_CONFIG_HOME='$XDG_DATA_HOME',
- XDG_CONFIG_DIRS='$XDG_DATA_DIRS',
- XDG_DATA_HOME='$XDG_CONFIG_HOME',
- XDG_RUNTIME_DIR='$XDG_RUNTIME_DIR',
- XDG_STATE_HOME='$XDG_CONFIG_HOME',
- XDG_DATA_DIRS='$XDG_CONFIG_DIRS',
+ clear({
+ args_rm={'runtimepath'},
+ env={
+ XDG_CONFIG_HOME='$XDG_DATA_HOME',
+ XDG_CONFIG_DIRS='$XDG_DATA_DIRS',
+ XDG_DATA_HOME='$XDG_CONFIG_HOME',
+ XDG_RUNTIME_DIR='$XDG_RUNTIME_DIR',
+ XDG_STATE_HOME='$XDG_CONFIG_HOME',
+ XDG_DATA_DIRS='$XDG_CONFIG_DIRS',
}})
end)
@@ -478,12 +484,14 @@ describe('XDG defaults', function()
describe('with commas', function()
before_each(function()
- clear({env={
- XDG_CONFIG_HOME=', , ,',
- XDG_CONFIG_DIRS=',-,-,' .. env_sep .. '-,-,-',
- XDG_DATA_HOME=',=,=,',
- XDG_STATE_HOME=',=,=,',
- XDG_DATA_DIRS=',≡,≡,' .. env_sep .. '≡,≡,≡',
+ clear({
+ args_rm={'runtimepath'},
+ env={
+ XDG_CONFIG_HOME=', , ,',
+ XDG_CONFIG_DIRS=',-,-,' .. env_sep .. '-,-,-',
+ XDG_DATA_HOME=',=,=,',
+ XDG_STATE_HOME=',=,=,',
+ XDG_DATA_DIRS=',≡,≡,' .. env_sep .. '≡,≡,≡',
}})
end)