refactor: deprecate checkhealth functions

The following functions are deprecated and will be removed in
Nvim v0.11:

- health#report_start()
- health#report_info()
- health#report_ok()
- health#report_warn()
- health#report_error()
- vim.health.report_start()
- vim.health.report_info()
- vim.health.report_ok()
- vim.health.report_warn()
- vim.health.report_error()

Users should instead use these:

- vim.health.start()
- vim.health.info()
- vim.health.ok()
- vim.health.warn()
- vim.health.error()
This commit is contained in:
dundargoc
2023-04-15 23:40:48 +02:00
committed by GitHub
parent c8667c8756
commit c08b030761
22 changed files with 418 additions and 442 deletions

View File

@@ -1,3 +0,0 @@
function! health#broken#check()
throw 'caused an error'
endfunction

View File

@@ -1,8 +0,0 @@
function! health#full_render#check()
call health#report_start("report 1")
call health#report_ok("life is fine")
call health#report_warn("no what installed", ["pip what", "make what"])
call health#report_start("report 2")
call health#report_info("stuff is stable")
call health#report_error("why no hardcopy", [":h :hardcopy", ":h :TOhtml"])
endfunction

View File

@@ -1,6 +0,0 @@
function! health#success1#check()
call health#report_start("report 1")
call health#report_ok("everything is fine")
call health#report_start("report 2")
call health#report_ok("nothing to see here")
endfunction

View File

@@ -1,4 +0,0 @@
function! health#success2#check()
call health#report_start("another 1")
call health#report_ok("ok")
endfunction

View File

@@ -1,3 +0,0 @@
function! health#success1#check()
call health#report_start("If you see this I'm broken")
endfunction

View File

@@ -0,0 +1,12 @@
local M = {}
M.check = function()
vim.health.start('report 1')
vim.health.ok('life is fine')
vim.health.warn('no what installed', { 'pip what', 'make what' })
vim.health.start('report 2')
vim.health.info('stuff is stable')
vim.health.error('why no hardcopy', { ':h :hardcopy', ':h :TOhtml' })
end
return M

View File

@@ -1,10 +1,10 @@
local M = {}
M.check = function()
vim.health.report_start("report 1")
vim.health.report_ok("everything is fine")
vim.health.report_start("report 2")
vim.health.report_ok("nothing to see here")
vim.health.start('report 1')
vim.health.ok('everything is fine')
vim.health.start('report 2')
vim.health.ok('nothing to see here')
end
return M

View File

@@ -1,10 +1,10 @@
local M = {}
M.check = function()
vim.health.report_start("report 1")
vim.health.report_ok("everything is fine")
vim.health.report_start("report 2")
vim.health.report_ok("nothing to see here")
vim.health.start('report 1')
vim.health.ok('everything is fine')
vim.health.start('report 2')
vim.health.ok('nothing to see here')
end
return M

View File

@@ -1,11 +0,0 @@
local M = {}
M.check = function()
vim.health.report_start("report 1")
vim.health.report_ok("everything is fine")
vim.health.report_warn("About to add a number to nil")
local a = nil + 2
return a
end
return M

View File

@@ -0,0 +1,10 @@
local M = {}
M.check = function()
vim.health.start('report 1')
vim.health.ok('everything is fine')
vim.health.start('report 2')
vim.health.ok('nothing to see here')
end
return M

View File

@@ -0,0 +1,8 @@
local M = {}
M.check = function()
vim.health.start('another 1')
vim.health.ok('ok')
end
return M

View File

@@ -1,5 +1,4 @@
local helpers = require('test.functional.helpers')(after_each)
local global_helpers = require('test.helpers')
local Screen = require('test.functional.ui.screen')
local clear = helpers.clear
@@ -43,20 +42,17 @@ end)
describe('health.vim', function()
before_each(function()
clear{args={'-u', 'NORC'}}
-- Provides functions:
-- health#broken#check()
-- health#success1#check()
-- health#success2#check()
-- Provides healthcheck functions
command("set runtimepath+=test/functional/fixtures")
end)
describe(":checkhealth", function()
it("functions health#report_*() render correctly", function()
it("functions report_*() render correctly", function()
command("checkhealth full_render")
helpers.expect([[
==============================================================================
full_render: health#full_render#check
test_plug.full_render: require("test_plug.full_render.health").check()
report 1 ~
- OK life is fine
@@ -79,7 +75,7 @@ describe('health.vim', function()
helpers.expect([[
==============================================================================
success1: health#success1#check
test_plug: require("test_plug.health").check()
report 1 ~
- OK everything is fine
@@ -88,36 +84,19 @@ describe('health.vim', function()
- OK nothing to see here
==============================================================================
success2: health#success2#check
test_plug.success1: require("test_plug.success1.health").check()
report 1 ~
- OK everything is fine
report 2 ~
- OK nothing to see here
==============================================================================
test_plug.success2: require("test_plug.success2.health").check()
another 1 ~
- OK ok
==============================================================================
test_plug: require("test_plug.health").check()
report 1 ~
- OK everything is fine
report 2 ~
- OK nothing to see here
]])
end)
it("lua plugins, skips vimscript healthchecks with the same name", function()
command("checkhealth test_plug")
-- Existing file in test/functional/fixtures/lua/test_plug/autoload/health/test_plug.vim
-- and the Lua healthcheck is used instead.
helpers.expect([[
==============================================================================
test_plug: require("test_plug.health").check()
report 1 ~
- OK everything is fine
report 2 ~
- OK nothing to see here
]])
end)
@@ -136,57 +115,6 @@ describe('health.vim', function()
]])
end)
it("lua plugins submodules with expression '*'", function()
command("checkhealth test_plug*")
local buf_lines = helpers.curbuf('get_lines', 0, -1, true)
-- avoid dealing with path separators
local received = table.concat(buf_lines, '\n', 1, #buf_lines - 5)
local expected = helpers.dedent([[
==============================================================================
test_plug: require("test_plug.health").check()
report 1 ~
- OK everything is fine
report 2 ~
- OK nothing to see here
==============================================================================
test_plug.submodule: require("test_plug.submodule.health").check()
report 1 ~
- OK everything is fine
report 2 ~
- 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()
- ERROR Failed to run healthcheck for "test_plug.submodule_failed" plugin. Exception:
function health#check, line 25]])
eq(expected, received)
end)
it("gracefully handles broken healthcheck", function()
command("checkhealth broken")
helpers.expect([[
==============================================================================
broken: health#broken#check
- ERROR Failed to run healthcheck for "broken" plugin. Exception:
function health#check[25]..health#broken#check, line 1
caused an error
]])
end)
it("... including empty reports", function()
command("checkhealth test_plug.submodule_empty")
helpers.expect([[
@@ -198,25 +126,6 @@ describe('health.vim', function()
]])
end)
it("gracefully handles broken lua healthcheck", function()
command("checkhealth test_plug.submodule_failed")
local buf_lines = helpers.curbuf('get_lines', 0, -1, true)
local received = table.concat(buf_lines, '\n', 1, #buf_lines - 5)
-- avoid dealing with path separators
local lua_err = "attempt to perform arithmetic on a nil value"
local last_line = buf_lines[#buf_lines - 4]
assert(string.find(last_line, lua_err) ~= nil, "Lua error not present")
local expected = global_helpers.dedent([[
==============================================================================
test_plug.submodule_failed: require("test_plug.submodule_failed.health").check()
- ERROR Failed to run healthcheck for "test_plug.submodule_failed" plugin. Exception:
function health#check, line 25]])
eq(expected, received)
end)
it("highlights OK, ERROR", function()
local screen = Screen.new(50, 12)
screen:attach()
@@ -236,7 +145,7 @@ describe('health.vim', function()
- {Error:ERROR} No healthcheck found for "foo" plugin. |
|
{Bar:──────────────────────────────────────────────────}|
{Heading:success1: health#success1#check} |
{Heading:test_plug.success1: require("test_plug.success1.he}|
|
{Heading:report 1} |
- {Ok:OK} everything is fine |