From 5baeb4a49c061472a125f98af798c522d8504fbe Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 15 Oct 2017 18:29:53 +0200 Subject: ex-cmds: :checkhealth Built-in `:checkhealth` checks for valid $VIMRUNTIME by attempting to autoload `health#check()`. closes #2977 closes #3159 --- test/functional/plugin/health_spec.lua | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/functional/plugin/health_spec.lua b/test/functional/plugin/health_spec.lua index 8646ec98bf..a85a3ce495 100644 --- a/test/functional/plugin/health_spec.lua +++ b/test/functional/plugin/health_spec.lua @@ -2,7 +2,29 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local plugin_helpers = require('test.functional.plugin.helpers') +local clear = helpers.clear local command = helpers.command +local eq = helpers.eq + +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) + it("detects invalid $VIM", function() + clear({ + env={ VIM='bogus', }, + }) + local status, err = pcall(command, 'checkhealth') + eq(false, status) + -- Invalid $VIM causes $VIMRUNTIME to be broken. + eq('Invalid $VIMRUNTIME: bogus', string.match(err, 'Invalid.*')) + end) +end) describe('health.vim', function() before_each(function() @@ -14,7 +36,7 @@ describe('health.vim', function() command("set runtimepath+=test/functional/fixtures") end) - it("reports", function() + it("health#report_*()", function() helpers.source([[ let g:health_report = execute([ \ "call health#report_start('Check Bar')", @@ -44,7 +66,7 @@ describe('health.vim', function() end) - describe(":CheckHealth", function() + describe(":checkhealth", function() it("concatenates multiple reports", function() command("CheckHealth success1 success2") helpers.expect([[ -- cgit From d214df4e9b23b5f2d9f7e6c78624881a7d298cdb Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 15 Oct 2017 20:31:12 +0200 Subject: doc: replace ":CheckHealth" with ":checkhealth" --- test/functional/clipboard/clipboard_provider_spec.lua | 6 +++--- test/functional/plugin/health_spec.lua | 8 ++++---- test/functional/provider/ruby_spec.lua | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'test') diff --git a/test/functional/clipboard/clipboard_provider_spec.lua b/test/functional/clipboard/clipboard_provider_spec.lua index b90335e70a..a3ea3b568f 100644 --- a/test/functional/clipboard/clipboard_provider_spec.lua +++ b/test/functional/clipboard/clipboard_provider_spec.lua @@ -100,7 +100,7 @@ describe('clipboard', function() ^ | ~ | ~ | - clipboard: No provider. Try ":CheckHealth" or ":h clipboard". | + clipboard: No provider. Try ":checkhealth" or ":h clipboard". | ]], nil, {{bold = true, foreground = Screen.colors.Blue}}) end) @@ -112,7 +112,7 @@ describe('clipboard', function() feed_command('redir @+> | bogus_cmd | redir END') screen:expect([[ ~ | - clipboard: No provider. Try ":CheckHealth" or ":h clipboard". | + clipboard: No provider. Try ":checkhealth" or ":h clipboard". | E492: Not an editor command: bogus_cmd | redir END | Press ENTER or type command to continue^ | ]], nil, {{bold = true, foreground = Screen.colors.Blue}}) @@ -132,7 +132,7 @@ describe('clipboard', function() ^ | ~ | ~ | - clipboard: No provider. Try ":CheckHealth" or ":h clipboard". | + clipboard: No provider. Try ":checkhealth" or ":h clipboard". | ]], nil, {{bold = true, foreground = Screen.colors.Blue}}) end) diff --git a/test/functional/plugin/health_spec.lua b/test/functional/plugin/health_spec.lua index a85a3ce495..a91c0b401b 100644 --- a/test/functional/plugin/health_spec.lua +++ b/test/functional/plugin/health_spec.lua @@ -68,7 +68,7 @@ describe('health.vim', function() describe(":checkhealth", function() it("concatenates multiple reports", function() - command("CheckHealth success1 success2") + command("checkhealth success1 success2") helpers.expect([[ health#success1#check @@ -87,7 +87,7 @@ describe('health.vim', function() end) it("gracefully handles broken healthcheck", function() - command("CheckHealth broken") + command("checkhealth broken") helpers.expect([[ health#broken#check @@ -111,7 +111,7 @@ describe('health.vim', function() Bar = { foreground=Screen.colors.Purple }, Bullet = { bold=true, foreground=Screen.colors.Brown }, }) - command("CheckHealth foo success1") + command("checkhealth foo success1") command("1tabclose") command("set laststatus=0") screen:expect([[ @@ -129,7 +129,7 @@ describe('health.vim', function() end) it("gracefully handles invalid healthcheck", function() - command("CheckHealth non_existent_healthcheck") + command("checkhealth non_existent_healthcheck") helpers.expect([[ health#non_existent_healthcheck#check diff --git a/test/functional/provider/ruby_spec.lua b/test/functional/provider/ruby_spec.lua index 9f5ef3b3fc..c70f90da1c 100644 --- a/test/functional/provider/ruby_spec.lua +++ b/test/functional/provider/ruby_spec.lua @@ -16,7 +16,7 @@ do clear() if missing_provider('ruby') then pending( - "Cannot find the neovim RubyGem. Try :CheckHealth", + "Cannot find the neovim RubyGem. Try :checkhealth", function() end) return end -- cgit From 3bcee71cc8ef782fc89de7d72cb784cfb6d984d3 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 17 Oct 2017 00:10:52 +0200 Subject: :checkhealth : validate $VIM --- test/functional/plugin/health_spec.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'test') diff --git a/test/functional/plugin/health_spec.lua b/test/functional/plugin/health_spec.lua index a91c0b401b..b5374210e6 100644 --- a/test/functional/plugin/health_spec.lua +++ b/test/functional/plugin/health_spec.lua @@ -3,6 +3,7 @@ local Screen = require('test.functional.ui.screen') local plugin_helpers = require('test.functional.plugin.helpers') local clear = helpers.clear +local curbuf_contents = helpers.curbuf_contents local command = helpers.command local eq = helpers.eq @@ -16,13 +17,12 @@ describe(':checkhealth', function() eq('Invalid $VIMRUNTIME: bogus', string.match(err, 'Invalid.*')) end) it("detects invalid $VIM", function() - clear({ - env={ VIM='bogus', }, - }) - local status, err = pcall(command, 'checkhealth') - eq(false, status) - -- Invalid $VIM causes $VIMRUNTIME to be broken. - eq('Invalid $VIMRUNTIME: bogus', string.match(err, 'Invalid.*')) + clear() + -- Do this after startup, otherwise it just breaks $VIMRUNTIME. + command("let $VIM='zub'") + command("checkhealth nvim") + eq("ERROR: $VIM is invalid: zub", + string.match(curbuf_contents(), "ERROR: $VIM .* zub")) end) end) -- cgit