From 65fb622000af8e3dbb65480e1581758ecf4ba3e2 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 9 Apr 2017 00:12:26 +0300 Subject: functests: Replace execute with either command or feed_command Hope this will make people using feed_command less likely: this hides bugs. Already found at least two: 1. msgpackparse() will show internal error: hash_add() in case of duplicate keys, though it will still work correctly. Currently silenced. 2. ttimeoutlen was spelled incorrectly, resulting in option not being set when expected. Test was still functioning somehow though. Currently fixed. --- test/functional/legacy/051_highlight_spec.lua | 75 +++++++++++++-------------- 1 file changed, 37 insertions(+), 38 deletions(-) (limited to 'test/functional/legacy/051_highlight_spec.lua') diff --git a/test/functional/legacy/051_highlight_spec.lua b/test/functional/legacy/051_highlight_spec.lua index d4d9b7d997..b98c1ac2d5 100644 --- a/test/functional/legacy/051_highlight_spec.lua +++ b/test/functional/legacy/051_highlight_spec.lua @@ -1,10 +1,9 @@ --- vim: set foldmethod=marker foldmarker=[[,]] : -- Tests for ":highlight". local Screen = require('test.functional.ui.screen') local helpers = require('test.functional.helpers')(after_each) local clear, feed = helpers.clear, helpers.feed -local execute, expect = helpers.execute, helpers.expect +local command, expect = helpers.command, helpers.expect local wait = helpers.wait if helpers.pending_win32(pending) then return end @@ -16,7 +15,7 @@ describe(':highlight', function() local screen = Screen.new(35, 10) screen:attach() -- Basic test if ":highlight" doesn't crash - execute('set more', 'highlight') + command('set more', 'highlight') -- FIXME(tarruda): We need to be sure the prompt is displayed before -- continuing, or risk a race condition where some of the following input -- is discarded resulting in test failure @@ -34,64 +33,64 @@ describe(':highlight', function() ]]) feed('q') wait() -- wait until we're back to normal - execute('hi Search') + command('hi Search') -- Test setting colors. -- Test clearing one color and all doesn't generate error or warning - execute('hi NewGroup cterm=italic ctermfg=DarkBlue ctermbg=Grey gui=NONE guifg=#00ff00 guibg=Cyan') - execute('hi Group2 cterm=NONE') - execute('hi Group3 cterm=bold') - execute('redir! @a') - execute('hi NewGroup') - execute('hi Group2') - execute('hi Group3') - execute('hi clear NewGroup') - execute('hi NewGroup') - execute('hi Group2') - execute('hi Group2 NONE') - execute('hi Group2') - execute('hi clear') - execute('hi Group3') - execute([[hi Crash cterm='asdf]]) - execute('redir END') + command('hi NewGroup cterm=italic ctermfg=DarkBlue ctermbg=Grey gui=NONE guifg=#00ff00 guibg=Cyan') + command('hi Group2 cterm=NONE') + command('hi Group3 cterm=bold') + command('redir! @a') + command('hi NewGroup') + command('hi Group2') + command('hi Group3') + command('hi clear NewGroup') + command('hi NewGroup') + command('hi Group2') + command('hi Group2 NONE') + command('hi Group2') + command('hi clear') + command('hi Group3') + command([[hi Crash cterm='asdf]]) + command('redir END') -- Filter ctermfg and ctermbg, the numbers depend on the terminal - execute('0put a') - execute([[%s/ctermfg=\d*/ctermfg=2/]]) - execute([[%s/ctermbg=\d*/ctermbg=3/]]) + command('0put a') + command([[%s/ctermfg=\d*/ctermfg=2/]]) + command([[%s/ctermbg=\d*/ctermbg=3/]]) -- Filter out possibly translated error message - execute('%s/E475: [^:]*:/E475:/') + command('%s/E475: [^:]*:/E475:/') -- Fix the fileformat - execute('set ff&') - execute('$d') + command('set ff&') + command('$d') -- Assert buffer contents. expect([[ - - + + NewGroup xxx cterm=italic ctermfg=2 ctermbg=3 guifg=#00ff00 guibg=Cyan - + Group2 xxx cleared - + Group3 xxx cterm=bold - - + + NewGroup xxx cleared - + Group2 xxx cleared - - + + Group2 xxx cleared - - + + Group3 xxx cleared - + E475: cterm='asdf]]) screen:detach() end) -- cgit From ed0ad7ce3e491ec65f05149079dccda22de22241 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 9 Apr 2017 01:43:46 +0300 Subject: functests: Fix legacy/051_highlight_spec test --- test/functional/legacy/051_highlight_spec.lua | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) (limited to 'test/functional/legacy/051_highlight_spec.lua') diff --git a/test/functional/legacy/051_highlight_spec.lua b/test/functional/legacy/051_highlight_spec.lua index b98c1ac2d5..60d29246ff 100644 --- a/test/functional/legacy/051_highlight_spec.lua +++ b/test/functional/legacy/051_highlight_spec.lua @@ -4,7 +4,9 @@ local Screen = require('test.functional.ui.screen') local helpers = require('test.functional.helpers')(after_each) local clear, feed = helpers.clear, helpers.feed local command, expect = helpers.command, helpers.expect +local eq = helpers.eq local wait = helpers.wait +local exc_exec = helpers.exc_exec if helpers.pending_win32(pending) then return end @@ -15,7 +17,8 @@ describe(':highlight', function() local screen = Screen.new(35, 10) screen:attach() -- Basic test if ":highlight" doesn't crash - command('set more', 'highlight') + command('set more') + feed(':highlight') -- FIXME(tarruda): We need to be sure the prompt is displayed before -- continuing, or risk a race condition where some of the following input -- is discarded resulting in test failure @@ -51,7 +54,8 @@ describe(':highlight', function() command('hi Group2') command('hi clear') command('hi Group3') - command([[hi Crash cterm='asdf]]) + eq('Vim(highlight):E475: Invalid argument: cterm=\'asdf', + exc_exec([[hi Crash cterm='asdf]])) command('redir END') -- Filter ctermfg and ctermbg, the numbers depend on the terminal @@ -59,9 +63,6 @@ describe(':highlight', function() command([[%s/ctermfg=\d*/ctermfg=2/]]) command([[%s/ctermbg=\d*/ctermbg=3/]]) - -- Filter out possibly translated error message - command('%s/E475: [^:]*:/E475:/') - -- Fix the fileformat command('set ff&') command('$d') @@ -69,29 +70,17 @@ describe(':highlight', function() -- Assert buffer contents. expect([[ - NewGroup xxx cterm=italic ctermfg=2 ctermbg=3 guifg=#00ff00 guibg=Cyan - Group2 xxx cleared - Group3 xxx cterm=bold - - NewGroup xxx cleared - Group2 xxx cleared - - Group2 xxx cleared - - - Group3 xxx cleared - - E475: cterm='asdf]]) + Group3 xxx cleared]]) screen:detach() end) end) -- cgit