From 2afcdbd63a5b0cbeaad9d83b096a3af5201c67a9 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Fri, 2 Sep 2022 15:20:29 +0100 Subject: feat(Man): port to Lua (#19912) Co-authored-by: zeertzjq --- test/functional/plugin/man_spec.lua | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'test/functional/plugin/man_spec.lua') diff --git a/test/functional/plugin/man_spec.lua b/test/functional/plugin/man_spec.lua index 9304aa6da9..3e63c5df9a 100644 --- a/test/functional/plugin/man_spec.lua +++ b/test/functional/plugin/man_spec.lua @@ -1,7 +1,8 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') -local command, eval, rawfeed = helpers.command, helpers.eval, helpers.rawfeed +local command, rawfeed = helpers.command, helpers.rawfeed local clear = helpers.clear +local exec_lua = helpers.exec_lua local funcs = helpers.funcs local nvim_prog = helpers.nvim_prog local matches = helpers.matches @@ -50,7 +51,7 @@ describe(':Man', function() | ]]} - eval('man#init_pager()') + exec_lua[[require'man'.init_pager()]] screen:expect([[ ^this {b:is} {b:a} test | @@ -74,7 +75,7 @@ describe(':Man', function() | ]=]} - eval('man#init_pager()') + exec_lua[[require'man'.init_pager()]] screen:expect([[ ^this {b:is }{bi:a }{biu:test} | @@ -89,7 +90,7 @@ describe(':Man', function() rawfeed([[ ithis iiss ああ test with _ö_v_e_r_s_t_r_u_̃_c_k te[3mxt¶[0m]]) - eval('man#init_pager()') + exec_lua[[require'man'.init_pager()]] screen:expect([[ ^this {b:is} {b:あ} test | @@ -105,7 +106,7 @@ describe(':Man', function() i__bbeeggiinnss mmiidd__ddllee _m_i_d___d_l_e]]) - eval('man#init_pager()') + exec_lua[[require'man'.init_pager()]] screen:expect([[ {b:^_begins} | @@ -121,7 +122,7 @@ describe(':Man', function() i· ·· +o ++oo double]]) - eval('man#init_pager()') + exec_lua[[require'man'.init_pager()]] screen:expect([[ ^· {b:·} | @@ -138,7 +139,7 @@ describe(':Man', function() [44m 4 [45m 5 [46m 6 [47m 7 [100m 8 [101m 9 [102m 10 [103m 11 [104m 12 [105m 13 [106m 14 [107m 15 [48:5:16m 16 ]]) - eval('man#init_pager()') + exec_lua[[require'man'.init_pager()]] screen:expect([[ ^ 0 1 2 3 | -- cgit From 39911d76be560c998cc7dee51c5d94f811164f66 Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Mon, 17 Oct 2022 04:37:44 -0500 Subject: fix(man): handle absolute paths as `:Man` targets (#20624) * fix(man): handle absolute paths as :Man targets Previously, attempting to provide `:Man` with an absolute path as the name would cause neovim to return the following error: ``` Error detected while processing command line: /usr/local/share/nvim/runtime/lua/man.lua:690: /usr/local/share/nvim/runtime/lua/man.lua:683: Vim:E426: tag not found: nil(nil) Press ENTER or type command to continue ``` ..because it would try to validate the existence of a man page for the provided name by executing `man -w /some/path` which (on at least some Linux machines [0]) returns `/some/path` instead of the path to the nroff files that would be formatted to satisfy the man(1) lookup. While man pages are not normally named after absolute paths, users shouldn't be blamed for trying. Given such a name/path, neovim would **not** complain that the path didn't have a corresponding man file but would error out when trying to call the tag function for the null-propagated name-and-section `nil(nil)`. (The same underlying error existed before this function was ported to lua, but did not exhibit the lua-specific `nil(nil)` name; instead a tag lookup for `()` would fail and error out.) With this patch, we detect the case where `man -w ...` returns the same value as the provided name to not only prevent invoking the tag function for a non-existent/malformed name+sect but also to properly report the non-existence of a man page for the provided lookup (the absolute path). While man(1) can be used to directly read an nroff-formatted document via `man /path/to/nroff.doc`, `:Man /path/to/nroff.doc` never supported this behavior so no functionality is lost in case the provided path _was_ an nroff file. [0]: `man -w /absolute/path` returning `/absolute/path` observed on an Ubuntu 18.04 installation. * test: add regression test for #20624 Add a functional test to `man_spec.lua` to check for a regression for #20624 by first obtaining an absolute path to a random file and materializing it to disk, then attempting to query `:Man` for an entry by that same name/path. The test passes if nvim correctly reports that there is no man page correspending to the provided name/path and fails if any other error (or no error) is shown. --- test/functional/plugin/man_spec.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test/functional/plugin/man_spec.lua') diff --git a/test/functional/plugin/man_spec.lua b/test/functional/plugin/man_spec.lua index 3e63c5df9a..203424c855 100644 --- a/test/functional/plugin/man_spec.lua +++ b/test/functional/plugin/man_spec.lua @@ -6,6 +6,8 @@ local exec_lua = helpers.exec_lua local funcs = helpers.funcs local nvim_prog = helpers.nvim_prog local matches = helpers.matches +local write_file = helpers.write_file +local tmpname = helpers.tmpname clear() if funcs.executable('man') == 0 then @@ -156,4 +158,16 @@ describe(':Man', function() local args = {nvim_prog, '--headless', '+autocmd VimLeave * echo "quit works!!"', '+Man!', '+call nvim_input("q")'} matches('quit works!!', funcs.system(args, {'manpage contents'})) end) + + it('reports non-existent man pages for absolute paths', function() + local actual_file = tmpname() + -- actual_file must be an absolute path to an existent file for us to test against it + matches('^/.+', actual_file) + write_file(actual_file, '') + local args = {nvim_prog, '--headless', '+:Man ' .. actual_file, '+q'} + matches(('Error detected while processing command line:\r\n' .. + 'man.lua: "no manual entry for %s"'):format(actual_file), + funcs.system(args, {''})) + os.remove(actual_file) + end) end) -- cgit From 5046b4b4adb154bbdb50a5e96e29f777b5f807ac Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Mon, 17 Oct 2022 17:16:31 +0200 Subject: ci: add cirrus to isCI function to skip tests (#20526) The environment variable CIRRUS_CI is manually passed to RunTests.cmake as it doesn't get passed when using cmake script mode. --- test/functional/plugin/man_spec.lua | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'test/functional/plugin/man_spec.lua') diff --git a/test/functional/plugin/man_spec.lua b/test/functional/plugin/man_spec.lua index 203424c855..ebf131fd4a 100644 --- a/test/functional/plugin/man_spec.lua +++ b/test/functional/plugin/man_spec.lua @@ -8,6 +8,7 @@ local nvim_prog = helpers.nvim_prog local matches = helpers.matches local write_file = helpers.write_file local tmpname = helpers.tmpname +local isCI = helpers.isCI clear() if funcs.executable('man') == 0 then @@ -160,6 +161,9 @@ describe(':Man', function() end) it('reports non-existent man pages for absolute paths', function() + if isCI('cirrus') then + pending('FIXME: cirrus') + end local actual_file = tmpname() -- actual_file must be an absolute path to an existent file for us to test against it matches('^/.+', actual_file) -- cgit From 736c36c02f316c979da363c5120495179a2b6c2a Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Sun, 13 Nov 2022 14:52:19 +0100 Subject: test: introduce skip() #21010 This is essentially a convenience wrapper around the `pending()` function, similar to `skip_fragile()` but more general-purpose. Also remove `pending_win32` function as it can be replaced by `skip(iswin())`. --- test/functional/plugin/man_spec.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'test/functional/plugin/man_spec.lua') diff --git a/test/functional/plugin/man_spec.lua b/test/functional/plugin/man_spec.lua index ebf131fd4a..c57f43c632 100644 --- a/test/functional/plugin/man_spec.lua +++ b/test/functional/plugin/man_spec.lua @@ -9,6 +9,7 @@ local matches = helpers.matches local write_file = helpers.write_file local tmpname = helpers.tmpname local isCI = helpers.isCI +local skip = helpers.skip clear() if funcs.executable('man') == 0 then @@ -161,9 +162,7 @@ describe(':Man', function() end) it('reports non-existent man pages for absolute paths', function() - if isCI('cirrus') then - pending('FIXME: cirrus') - end + skip(isCI('cirrus')) local actual_file = tmpname() -- actual_file must be an absolute path to an existent file for us to test against it matches('^/.+', actual_file) -- cgit From 5eb5f4948826e9d47685ea9e257409cc3e693614 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Tue, 22 Nov 2022 01:13:30 +0100 Subject: test: simplify platform detection (#21020) Extend the capabilities of is_os to detect more platforms such as freebsd and openbsd. Also remove `iswin()` helper function as it can be replaced by `is_os("win")`. --- test/functional/plugin/man_spec.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/functional/plugin/man_spec.lua') diff --git a/test/functional/plugin/man_spec.lua b/test/functional/plugin/man_spec.lua index c57f43c632..c6c7d2b03d 100644 --- a/test/functional/plugin/man_spec.lua +++ b/test/functional/plugin/man_spec.lua @@ -8,8 +8,8 @@ local nvim_prog = helpers.nvim_prog local matches = helpers.matches local write_file = helpers.write_file local tmpname = helpers.tmpname -local isCI = helpers.isCI local skip = helpers.skip +local is_ci = helpers.is_ci clear() if funcs.executable('man') == 0 then @@ -162,7 +162,7 @@ describe(':Man', function() end) it('reports non-existent man pages for absolute paths', function() - skip(isCI('cirrus')) + skip(is_ci('cirrus')) local actual_file = tmpname() -- actual_file must be an absolute path to an existent file for us to test against it matches('^/.+', actual_file) -- cgit