diff options
Diffstat (limited to 'test')
12 files changed, 47 insertions, 143 deletions
diff --git a/test/functional/fixtures/autoload/health/broken.vim b/test/functional/fixtures/autoload/health/broken.vim deleted file mode 100644 index a2a595b96f..0000000000 --- a/test/functional/fixtures/autoload/health/broken.vim +++ /dev/null @@ -1,3 +0,0 @@ -function! health#broken#check() - throw 'caused an error' -endfunction diff --git a/test/functional/fixtures/autoload/health/full_render.vim b/test/functional/fixtures/autoload/health/full_render.vim deleted file mode 100644 index 2064b8606e..0000000000 --- a/test/functional/fixtures/autoload/health/full_render.vim +++ /dev/null @@ -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 diff --git a/test/functional/fixtures/autoload/health/success1.vim b/test/functional/fixtures/autoload/health/success1.vim deleted file mode 100644 index a360347455..0000000000 --- a/test/functional/fixtures/autoload/health/success1.vim +++ /dev/null @@ -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 diff --git a/test/functional/fixtures/autoload/health/success2.vim b/test/functional/fixtures/autoload/health/success2.vim deleted file mode 100644 index b742b4879d..0000000000 --- a/test/functional/fixtures/autoload/health/success2.vim +++ /dev/null @@ -1,4 +0,0 @@ -function! health#success2#check() - call health#report_start("another 1") - call health#report_ok("ok") -endfunction diff --git a/test/functional/fixtures/lua/test_plug/autoload/health/test_plug.vim b/test/functional/fixtures/lua/test_plug/autoload/health/test_plug.vim deleted file mode 100644 index de05f56e9e..0000000000 --- a/test/functional/fixtures/lua/test_plug/autoload/health/test_plug.vim +++ /dev/null @@ -1,3 +0,0 @@ -function! health#success1#check() - call health#report_start("If you see this I'm broken") -endfunction diff --git a/test/functional/fixtures/lua/test_plug/full_render/health.lua b/test/functional/fixtures/lua/test_plug/full_render/health.lua new file mode 100644 index 0000000000..10833f6239 --- /dev/null +++ b/test/functional/fixtures/lua/test_plug/full_render/health.lua @@ -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 diff --git a/test/functional/fixtures/lua/test_plug/health/init.lua b/test/functional/fixtures/lua/test_plug/health/init.lua index 58162d4515..ef0c5ae3cd 100644 --- a/test/functional/fixtures/lua/test_plug/health/init.lua +++ b/test/functional/fixtures/lua/test_plug/health/init.lua @@ -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 diff --git a/test/functional/fixtures/lua/test_plug/submodule/health.lua b/test/functional/fixtures/lua/test_plug/submodule/health.lua index 58162d4515..ef0c5ae3cd 100644 --- a/test/functional/fixtures/lua/test_plug/submodule/health.lua +++ b/test/functional/fixtures/lua/test_plug/submodule/health.lua @@ -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 diff --git a/test/functional/fixtures/lua/test_plug/submodule_failed/health.lua b/test/functional/fixtures/lua/test_plug/submodule_failed/health.lua deleted file mode 100644 index ee5f4e404b..0000000000 --- a/test/functional/fixtures/lua/test_plug/submodule_failed/health.lua +++ /dev/null @@ -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 diff --git a/test/functional/fixtures/lua/test_plug/success1/health.lua b/test/functional/fixtures/lua/test_plug/success1/health.lua new file mode 100644 index 0000000000..ef0c5ae3cd --- /dev/null +++ b/test/functional/fixtures/lua/test_plug/success1/health.lua @@ -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 diff --git a/test/functional/fixtures/lua/test_plug/success2/health.lua b/test/functional/fixtures/lua/test_plug/success2/health.lua new file mode 100644 index 0000000000..240a2d33de --- /dev/null +++ b/test/functional/fixtures/lua/test_plug/success2/health.lua @@ -0,0 +1,8 @@ +local M = {} + +M.check = function() + vim.health.start('another 1') + vim.health.ok('ok') +end + +return M diff --git a/test/functional/plugin/health_spec.lua b/test/functional/plugin/health_spec.lua index 97d32313e5..926e12ec32 100644 --- a/test/functional/plugin/health_spec.lua +++ b/test/functional/plugin/health_spec.lua @@ -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 - - another 1 ~ - - OK ok - - ============================================================================== - test_plug: require("test_plug.health").check() + test_plug.success1: require("test_plug.success1.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 + test_plug.success2: require("test_plug.success2.health").check() - report 2 ~ - - OK nothing to see here + another 1 ~ + - OK ok ]]) 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 | |