mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
fix(healthcheck): handle empty reports
This commit is contained in:
parent
07c97fa02d
commit
300b009f47
@ -21,10 +21,17 @@ function! health#check(plugin_names) abort
|
|||||||
throw 'healthcheck_not_found'
|
throw 'healthcheck_not_found'
|
||||||
endif
|
endif
|
||||||
eval type == 'v' ? call(func, []) : luaeval(func)
|
eval type == 'v' ? call(func, []) : luaeval(func)
|
||||||
|
" in the event the healthcheck doesn't return anything
|
||||||
|
" (the plugin author should avoid this possibility)
|
||||||
|
if len(s:output) == 0
|
||||||
|
throw 'healthcheck_no_return_value'
|
||||||
|
endif
|
||||||
catch
|
catch
|
||||||
let s:output = [] " Clear the output
|
let s:output = [] " Clear the output
|
||||||
if v:exception =~# 'healthcheck_not_found'
|
if v:exception =~# 'healthcheck_not_found'
|
||||||
call health#report_error('No healthcheck found for "'.name.'" plugin.')
|
call health#report_error('No healthcheck found for "'.name.'" plugin.')
|
||||||
|
elseif v:exception =~# 'healthcheck_no_return_value'
|
||||||
|
call health#report_error('The healthcheck report for "'.name.'" plugin is empty.')
|
||||||
else
|
else
|
||||||
call health#report_error(printf(
|
call health#report_error(printf(
|
||||||
\ "Failed to run healthcheck for \"%s\" plugin. Exception:\n%s\n%s",
|
\ "Failed to run healthcheck for \"%s\" plugin. Exception:\n%s\n%s",
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
local M = {}
|
||||||
|
|
||||||
|
M.check = function()
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
@ -153,6 +153,10 @@ describe('health.vim', function()
|
|||||||
## report 2
|
## report 2
|
||||||
- OK: nothing to see here
|
- OK: nothing to see here
|
||||||
|
|
||||||
|
test_plug.submodule_empty: require("test_plug.submodule_empty.health").check()
|
||||||
|
========================================================================
|
||||||
|
- ERROR: The healthcheck report for "test_plug.submodule_empty" plugin is empty.
|
||||||
|
|
||||||
test_plug.submodule_failed: require("test_plug.submodule_failed.health").check()
|
test_plug.submodule_failed: require("test_plug.submodule_failed.health").check()
|
||||||
========================================================================
|
========================================================================
|
||||||
- ERROR: Failed to run healthcheck for "test_plug.submodule_failed" plugin. Exception:
|
- ERROR: Failed to run healthcheck for "test_plug.submodule_failed" plugin. Exception:
|
||||||
@ -172,6 +176,16 @@ describe('health.vim', function()
|
|||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it("... including empty reports", function()
|
||||||
|
command("checkhealth test_plug.submodule_empty")
|
||||||
|
helpers.expect([[
|
||||||
|
|
||||||
|
test_plug.submodule_empty: require("test_plug.submodule_empty.health").check()
|
||||||
|
========================================================================
|
||||||
|
- ERROR: The healthcheck report for "test_plug.submodule_empty" plugin is empty.
|
||||||
|
]])
|
||||||
|
end)
|
||||||
|
|
||||||
it("gracefully handles broken lua healthcheck", function()
|
it("gracefully handles broken lua healthcheck", function()
|
||||||
command("checkhealth test_plug.submodule_failed")
|
command("checkhealth test_plug.submodule_failed")
|
||||||
local buf_lines = helpers.curbuf('get_lines', 0, -1, true)
|
local buf_lines = helpers.curbuf('get_lines', 0, -1, true)
|
||||||
|
Loading…
Reference in New Issue
Block a user