aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua/help_spec.lua
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2023-01-25 18:31:31 +0000
committerJosh Rahm <joshuarahm@gmail.com>2023-01-25 18:31:31 +0000
commit9243becbedbb6a1592208051f8fa2b090dcc5e7d (patch)
tree607c2a862ec3f4399b8766383f6f8e04c4aa43b4 /test/functional/lua/help_spec.lua
parent9e40b6e9e1bc67f2d856adb837ee64dd0e25b717 (diff)
parent3c48d3c83fc21dbc0841f9210f04bdb073d73cd1 (diff)
downloadrneovim-usermarks.tar.gz
rneovim-usermarks.tar.bz2
rneovim-usermarks.zip
Merge remote-tracking branch 'upstream/master' into usermarksusermarks
Diffstat (limited to 'test/functional/lua/help_spec.lua')
-rw-r--r--test/functional/lua/help_spec.lua50
1 files changed, 50 insertions, 0 deletions
diff --git a/test/functional/lua/help_spec.lua b/test/functional/lua/help_spec.lua
new file mode 100644
index 0000000000..b396e2ba30
--- /dev/null
+++ b/test/functional/lua/help_spec.lua
@@ -0,0 +1,50 @@
+-- Tests for gen_help_html.lua. Validates :help tags/links and HTML doc generation.
+--
+-- TODO: extract parts of gen_help_html.lua into Nvim stdlib?
+
+local helpers = require('test.functional.helpers')(after_each)
+local clear = helpers.clear
+local exec_lua = helpers.exec_lua
+local eq = helpers.eq
+local ok = helpers.ok
+
+describe(':help docs', function()
+ before_each(clear)
+ it('validate', function()
+ -- If this test fails, try these steps (in order):
+ -- 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)
+ eq({}, rv.invalid_links, 'invalid tags in :help docs')
+ eq({}, rv.invalid_urls, 'invalid URLs in :help docs')
+ -- Check that parse errors did not increase wildly.
+ -- TODO: Fix all parse errors in :help files.
+ ok(rv.err_count < 250, '<250 parse errors', rv.err_count)
+ end)
+
+ it('gen_help_html.lua generates HTML', function()
+ -- 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 (~30s), this test is limited to a few files.
+ local rv = exec_lua([[
+ local to_dir = ...
+ return require('scripts.gen_help_html').gen(
+ './build/runtime/doc',
+ to_dir,
+ { 'pi_health.txt', 'help.txt', 'index.txt', 'nvim.txt', }
+ )
+ ]],
+ tmpdir
+ )
+ eq(4, #rv.helpfiles)
+ eq(0, rv.err_count, 'parse errors in :help docs')
+ eq({}, rv.invalid_links, 'invalid tags in :help docs')
+ end)
+end)