2016-06-16 14:01:47 -07:00
|
|
|
local helpers = require('test.functional.helpers')(after_each)
|
2017-10-15 02:56:02 -07:00
|
|
|
local Screen = require('test.functional.ui.screen')
|
2016-06-16 14:01:47 -07:00
|
|
|
|
2017-10-15 09:29:53 -07:00
|
|
|
local clear = helpers.clear
|
2017-10-16 15:10:52 -07:00
|
|
|
local curbuf_contents = helpers.curbuf_contents
|
2017-04-08 14:12:26 -07:00
|
|
|
local command = helpers.command
|
2022-10-29 22:41:28 -07:00
|
|
|
local eq, neq, matches = helpers.eq, helpers.neq, helpers.matches
|
2018-01-18 07:54:25 -07:00
|
|
|
local getcompletion = helpers.funcs.getcompletion
|
2017-10-15 09:29:53 -07:00
|
|
|
|
|
|
|
describe(':checkhealth', function()
|
|
|
|
it("detects invalid $VIMRUNTIME", function()
|
|
|
|
clear({
|
|
|
|
env={ VIMRUNTIME='bogus', },
|
|
|
|
})
|
|
|
|
local status, err = pcall(command, 'checkhealth')
|
|
|
|
eq(false, status)
|
|
|
|
eq('Invalid $VIMRUNTIME: bogus', string.match(err, 'Invalid.*'))
|
|
|
|
end)
|
2017-11-10 14:37:54 -07:00
|
|
|
it("detects invalid 'runtimepath'", function()
|
|
|
|
clear()
|
|
|
|
command('set runtimepath=bogus')
|
|
|
|
local status, err = pcall(command, 'checkhealth')
|
|
|
|
eq(false, status)
|
|
|
|
eq("Invalid 'runtimepath'", string.match(err, 'Invalid.*'))
|
|
|
|
end)
|
2017-10-15 09:29:53 -07:00
|
|
|
it("detects invalid $VIM", function()
|
2017-10-16 15:10:52 -07:00
|
|
|
clear()
|
|
|
|
-- Do this after startup, otherwise it just breaks $VIMRUNTIME.
|
|
|
|
command("let $VIM='zub'")
|
|
|
|
command("checkhealth nvim")
|
2022-11-11 19:33:31 -07:00
|
|
|
matches('ERROR $VIM .* zub', curbuf_contents())
|
2017-10-15 09:29:53 -07:00
|
|
|
end)
|
2018-01-18 07:54:25 -07:00
|
|
|
it('completions can be listed via getcompletion()', function()
|
|
|
|
clear()
|
|
|
|
eq('nvim', getcompletion('nvim', 'checkhealth')[1])
|
|
|
|
eq('provider', getcompletion('prov', 'checkhealth')[1])
|
2021-09-23 18:33:43 -07:00
|
|
|
eq('vim.lsp', getcompletion('vim.ls', 'checkhealth')[1])
|
2022-06-01 07:10:10 -07:00
|
|
|
neq('vim', getcompletion('^vim', 'checkhealth')[1]) -- should not complete vim.health
|
2018-01-18 07:54:25 -07:00
|
|
|
end)
|
2017-10-15 09:29:53 -07:00
|
|
|
end)
|
2017-04-08 14:12:26 -07:00
|
|
|
|
2016-06-16 14:01:47 -07:00
|
|
|
describe('health.vim', function()
|
|
|
|
before_each(function()
|
2019-08-05 01:25:49 -07:00
|
|
|
clear{args={'-u', 'NORC'}}
|
2023-04-15 14:40:48 -07:00
|
|
|
-- Provides healthcheck functions
|
2017-04-08 14:12:26 -07:00
|
|
|
command("set runtimepath+=test/functional/fixtures")
|
2016-06-16 14:01:47 -07:00
|
|
|
end)
|
|
|
|
|
2021-08-03 14:09:26 -07:00
|
|
|
describe(":checkhealth", function()
|
2023-04-15 14:40:48 -07:00
|
|
|
it("functions report_*() render correctly", function()
|
2021-08-03 14:09:26 -07:00
|
|
|
command("checkhealth full_render")
|
|
|
|
helpers.expect([[
|
|
|
|
|
2022-11-11 19:33:31 -07:00
|
|
|
==============================================================================
|
2023-04-15 14:40:48 -07:00
|
|
|
test_plug.full_render: require("test_plug.full_render.health").check()
|
2022-11-11 19:33:31 -07:00
|
|
|
|
|
|
|
report 1 ~
|
|
|
|
- OK life is fine
|
|
|
|
- WARNING no what installed
|
|
|
|
- ADVICE:
|
|
|
|
- pip what
|
|
|
|
- make what
|
|
|
|
|
|
|
|
report 2 ~
|
|
|
|
- stuff is stable
|
|
|
|
- ERROR why no hardcopy
|
|
|
|
- ADVICE:
|
|
|
|
- :help |:hardcopy|
|
|
|
|
- :help |:TOhtml|
|
2021-08-03 14:09:26 -07:00
|
|
|
]])
|
|
|
|
end)
|
2016-06-16 14:01:47 -07:00
|
|
|
|
2016-08-20 16:37:18 -07:00
|
|
|
it("concatenates multiple reports", function()
|
2021-08-03 14:09:26 -07:00
|
|
|
command("checkhealth success1 success2 test_plug")
|
2016-08-20 16:37:18 -07:00
|
|
|
helpers.expect([[
|
2016-09-04 19:57:19 -07:00
|
|
|
|
2022-11-11 19:33:31 -07:00
|
|
|
==============================================================================
|
2023-04-15 14:40:48 -07:00
|
|
|
test_plug: require("test_plug.health").check()
|
2016-06-16 14:01:47 -07:00
|
|
|
|
2022-11-11 19:33:31 -07:00
|
|
|
report 1 ~
|
|
|
|
- OK everything is fine
|
|
|
|
|
|
|
|
report 2 ~
|
|
|
|
- OK nothing to see here
|
2016-08-20 16:37:18 -07:00
|
|
|
|
2022-11-11 19:33:31 -07:00
|
|
|
==============================================================================
|
2023-04-15 14:40:48 -07:00
|
|
|
test_plug.success1: require("test_plug.success1.health").check()
|
2021-08-03 14:09:26 -07:00
|
|
|
|
2022-11-11 19:33:31 -07:00
|
|
|
report 1 ~
|
|
|
|
- OK everything is fine
|
|
|
|
|
|
|
|
report 2 ~
|
|
|
|
- OK nothing to see here
|
2021-08-03 14:09:26 -07:00
|
|
|
|
2022-11-11 19:33:31 -07:00
|
|
|
==============================================================================
|
2023-04-15 14:40:48 -07:00
|
|
|
test_plug.success2: require("test_plug.success2.health").check()
|
2022-11-11 19:33:31 -07:00
|
|
|
|
2023-04-15 14:40:48 -07:00
|
|
|
another 1 ~
|
|
|
|
- OK ok
|
2016-09-04 19:57:19 -07:00
|
|
|
]])
|
2016-06-16 14:01:47 -07:00
|
|
|
end)
|
|
|
|
|
2021-08-03 14:09:26 -07:00
|
|
|
it("lua plugins submodules", function()
|
|
|
|
command("checkhealth test_plug.submodule")
|
|
|
|
helpers.expect([[
|
|
|
|
|
2022-11-11 19:33:31 -07:00
|
|
|
==============================================================================
|
2021-08-03 14:09:26 -07:00
|
|
|
test_plug.submodule: require("test_plug.submodule.health").check()
|
|
|
|
|
2022-11-11 19:33:31 -07:00
|
|
|
report 1 ~
|
|
|
|
- OK everything is fine
|
|
|
|
|
|
|
|
report 2 ~
|
|
|
|
- OK nothing to see here
|
2021-08-03 14:09:26 -07:00
|
|
|
]])
|
|
|
|
end)
|
|
|
|
|
2022-01-19 11:30:20 -07:00
|
|
|
it("... including empty reports", function()
|
|
|
|
command("checkhealth test_plug.submodule_empty")
|
|
|
|
helpers.expect([[
|
|
|
|
|
2022-11-11 19:33:31 -07:00
|
|
|
==============================================================================
|
2022-01-19 11:30:20 -07:00
|
|
|
test_plug.submodule_empty: require("test_plug.submodule_empty.health").check()
|
2022-11-11 19:33:31 -07:00
|
|
|
|
|
|
|
- ERROR The healthcheck report for "test_plug.submodule_empty" plugin is empty.
|
2022-01-19 11:30:20 -07:00
|
|
|
]])
|
|
|
|
end)
|
|
|
|
|
2017-10-15 02:56:02 -07:00
|
|
|
it("highlights OK, ERROR", function()
|
2022-11-11 19:33:31 -07:00
|
|
|
local screen = Screen.new(50, 12)
|
2017-10-15 02:56:02 -07:00
|
|
|
screen:attach()
|
|
|
|
screen:set_default_attr_ids({
|
2023-05-05 09:15:44 -07:00
|
|
|
Ok = { foreground = Screen.colors.LightGreen },
|
|
|
|
Error = { foreground = Screen.colors.Red },
|
2022-11-11 19:33:31 -07:00
|
|
|
Heading = { foreground = tonumber('0x6a0dad') },
|
|
|
|
Bar = { foreground = Screen.colors.LightGrey, background = Screen.colors.DarkGrey },
|
2017-10-15 02:56:02 -07:00
|
|
|
})
|
2017-10-15 11:31:12 -07:00
|
|
|
command("checkhealth foo success1")
|
2023-06-06 08:42:26 -07:00
|
|
|
command("set nofoldenable nowrap laststatus=0")
|
2019-10-12 04:29:51 -07:00
|
|
|
screen:expect{grid=[[
|
2022-11-11 19:33:31 -07:00
|
|
|
^ |
|
|
|
|
{Bar:──────────────────────────────────────────────────}|
|
|
|
|
{Heading:foo: } |
|
|
|
|
|
|
|
|
|
- {Error:ERROR} No healthcheck found for "foo" plugin. |
|
|
|
|
|
|
|
|
|
{Bar:──────────────────────────────────────────────────}|
|
2023-04-15 14:40:48 -07:00
|
|
|
{Heading:test_plug.success1: require("test_plug.success1.he}|
|
2022-11-11 19:33:31 -07:00
|
|
|
|
|
|
|
|
{Heading:report 1} |
|
|
|
|
- {Ok:OK} everything is fine |
|
|
|
|
|
|
2023-06-06 08:42:26 -07:00
|
|
|
]]}
|
|
|
|
end)
|
|
|
|
|
|
|
|
it("fold healthchecks", function()
|
|
|
|
local screen = Screen.new(50, 7)
|
|
|
|
screen:attach()
|
|
|
|
command("checkhealth foo success1")
|
|
|
|
command("set nowrap laststatus=0")
|
|
|
|
screen:expect{grid=[[
|
|
|
|
^ |
|
|
|
|
──────────────────────────────────────────────────|
|
|
|
|
+WE 4 lines: foo: ·······························|
|
|
|
|
──────────────────────────────────────────────────|
|
|
|
|
+-- 8 lines: test_plug.success1: require("test_pl|
|
|
|
|
~ |
|
|
|
|
|
|
2019-10-12 04:29:51 -07:00
|
|
|
]]}
|
2017-10-15 02:56:02 -07:00
|
|
|
end)
|
|
|
|
|
2016-08-20 16:37:18 -07:00
|
|
|
it("gracefully handles invalid healthcheck", function()
|
2017-10-15 11:31:12 -07:00
|
|
|
command("checkhealth non_existent_healthcheck")
|
2021-08-03 14:09:26 -07:00
|
|
|
-- luacheck: ignore 613
|
2016-08-20 16:37:18 -07:00
|
|
|
helpers.expect([[
|
2016-09-04 19:57:19 -07:00
|
|
|
|
2022-11-11 19:33:31 -07:00
|
|
|
==============================================================================
|
2021-08-03 14:09:26 -07:00
|
|
|
non_existent_healthcheck:
|
2022-11-11 19:33:31 -07:00
|
|
|
|
|
|
|
- ERROR No healthcheck found for "non_existent_healthcheck" plugin.
|
2016-09-04 19:57:19 -07:00
|
|
|
]])
|
2016-08-20 16:37:18 -07:00
|
|
|
end)
|
2022-06-01 07:10:10 -07:00
|
|
|
|
|
|
|
it("does not use vim.health as a healtcheck", function()
|
|
|
|
-- vim.health is not a healthcheck
|
|
|
|
command("checkhealth vim")
|
|
|
|
helpers.expect([[
|
|
|
|
ERROR: No healthchecks found.]])
|
|
|
|
end)
|
2016-06-16 14:01:47 -07:00
|
|
|
end)
|
|
|
|
end)
|
2022-02-03 02:19:51 -07:00
|
|
|
|
|
|
|
describe(':checkhealth provider', function()
|
|
|
|
it("works correctly with a wrongly configured 'shell'", function()
|
|
|
|
clear()
|
|
|
|
command([[set shell=echo\ WRONG!!!]])
|
|
|
|
command('let g:loaded_perl_provider = 0')
|
|
|
|
command('let g:loaded_python3_provider = 0')
|
|
|
|
command('checkhealth provider')
|
|
|
|
eq(nil, string.match(curbuf_contents(), 'WRONG!!!'))
|
|
|
|
end)
|
|
|
|
end)
|