From e6208df73e39e281331141373c22a83bca6beccd Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Thu, 12 Feb 2015 13:29:48 -0300 Subject: test: Add synchronization helper for functional tests The `wait` function will only return after all input has been processed by nvim. It is useful to time assertions correctly. --- test/functional/helpers.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'test/functional') diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index ea98ff4ce3..fc6bf80d7e 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -229,11 +229,15 @@ local function curbuf(method, ...) return buffer(method, buf, ...) end +local function wait() + session:request('vim_eval', '1') +end + local function curbuf_contents() -- Before inspecting the buffer, execute 'vim_eval' to wait until all -- previously sent keys are processed(vim_eval is a deferred function, and -- only processed after all input) - session:request('vim_eval', '1') + wait() return table.concat(curbuf('get_line_slice', 0, -1, true, true), '\n') end @@ -284,5 +288,6 @@ return { curbuf = curbuf, curwin = curwin, curtab = curtab, - curbuf_contents = curbuf_contents + curbuf_contents = curbuf_contents, + wait = wait } -- cgit From e974b002833ba28ea69bc0969e21926e4e7d301f Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Thu, 12 Feb 2015 14:06:18 -0300 Subject: test: Fix race condition in window_spec.lua Without waiting for the 'gg' command to be processed, its possible that the following assertion will fail. --- test/functional/api/window_spec.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'test/functional') diff --git a/test/functional/api/window_spec.lua b/test/functional/api/window_spec.lua index f3ac90de21..456252522d 100644 --- a/test/functional/api/window_spec.lua +++ b/test/functional/api/window_spec.lua @@ -4,6 +4,7 @@ local clear, nvim, buffer, curbuf, curbuf_contents, window, curwin, eq, neq, ok, feed, rawfeed, insert, eval = helpers.clear, helpers.nvim, helpers.buffer, helpers.curbuf, helpers.curbuf_contents, helpers.window, helpers.curwin, helpers.eq, helpers.neq, helpers.ok, helpers.feed, helpers.rawfeed, helpers.insert, helpers.eval +local wait = helpers.wait -- check if str is visible at the beginning of some line local function is_visible(str) @@ -55,6 +56,7 @@ describe('window_* functions', function() insert("epilogue") win = curwin() feed('gg') + wait() -- let nvim process the 'gg' command -- cursor position is at beginning eq({1, 0}, window('get_cursor', win)) -- cgit From 291e15c60a891bfcff42d244e1ababd3e44cb84f Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Thu, 12 Feb 2015 14:26:08 -0300 Subject: test: Remove unnecessary tests from viml_system_spec.lua The `system` function is never executed with these tests because the ctrl+c is queued with the input string that calls it(The `process_interrupts` function will destroy all previous input when a ctrl+c is found). --- test/functional/shell/viml_system_spec.lua | 42 +----------------------------- 1 file changed, 1 insertion(+), 41 deletions(-) (limited to 'test/functional') diff --git a/test/functional/shell/viml_system_spec.lua b/test/functional/shell/viml_system_spec.lua index b35f070159..85c055d3be 100644 --- a/test/functional/shell/viml_system_spec.lua +++ b/test/functional/shell/viml_system_spec.lua @@ -77,27 +77,7 @@ describe('system()', function() ]]) end) - it('`yes` and is directly interrupted with CTRL-C', function() - feed(':call system("yes")') - screen:expect([[ - ^ | - ~ | - ~ | - ~ | - ~ | - ~ | - ~ | - ~ | - ~ | - ~ | - ~ | - ~ | - ~ | - Type :quit to exit Vim | - ]]) - end) - - it('`yes` and is a little bit later interrupted with CTRL-C', function() + it('`yes` and is interrupted with CTRL-C', function() feed(':call system("yes")') feed('') screen:expect([[ @@ -247,26 +227,6 @@ describe('systemlist()', function() ]]) end) - it('`yes` and is directly interrupted with CTRL-C', function() - feed(':call systemlist("yes | xargs")') - screen:expect([[ - ^ | - ~ | - ~ | - ~ | - ~ | - ~ | - ~ | - ~ | - ~ | - ~ | - ~ | - ~ | - ~ | - Type :quit to exit Vim | - ]]) - end) - it('`yes` and is a little bit later interrupted with CTRL-C', function() feed(':call systemlist("yes | xargs")') feed('') -- cgit From 98dca8a827cda02bd0cfff1da2a3ca5a0ab8ed7a Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Fri, 13 Feb 2015 10:28:02 -0300 Subject: test: Increase default_screen_timeout when running on travis Some screen tests such as system/ctrl+c(viml_system_spec.lua) can take some time to respond(default kill timeout is 2 seconds for an interrupted job) and fail when running under a slow environment such as travis. --- test/functional/ui/screen.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'test/functional') diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index cd8c2bc399..a20907791b 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -116,7 +116,11 @@ local debug_screen local default_screen_timeout = 2500 if os.getenv('VALGRIND') then - default_screen_timeout = 7500 + default_screen_timeout = default_screen_timeout * 3 +end + +if os.getenv('CI_TARGET') then + default_screen_timeout = default_screen_timeout * 3 end local colors = request('vim_get_color_map') -- cgit From d8f3458ec745cf56dc692b55cc76d8323dbbfc53 Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Fri, 13 Feb 2015 12:06:08 -0300 Subject: syntax: Refactor to store all term and gui attributes independently Now the attrentry_T structure will store all attributes in separate fields for cterm and rgb UIs. --- test/functional/legacy/051_highlight_spec.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'test/functional') diff --git a/test/functional/legacy/051_highlight_spec.lua b/test/functional/legacy/051_highlight_spec.lua index f35b70f93f..b4493583b2 100644 --- a/test/functional/legacy/051_highlight_spec.lua +++ b/test/functional/legacy/051_highlight_spec.lua @@ -15,9 +15,9 @@ describe(':highlight', function() -- Test setting colors. -- Test clearing one color and all doesn't generate error or warning - execute('hi NewGroup term=bold cterm=italic ctermfg=DarkBlue ctermbg=Grey gui= guifg=#00ff00 guibg=Cyan') - execute('hi Group2 term= cterm=') - execute('hi Group3 term=underline cterm=bold') + execute('hi NewGroup cterm=italic ctermfg=DarkBlue ctermbg=Grey gui= guifg=#00ff00 guibg=Cyan') + execute('hi Group2 cterm=') + execute('hi Group3 cterm=bold') execute('redir! @a') execute('hi NewGroup') execute('hi Group2') @@ -29,7 +29,7 @@ describe(':highlight', function() execute('hi Group2') execute('hi clear') execute('hi Group3') - execute([[hi Crash term='asdf]]) + execute([[hi Crash cterm='asdf]]) execute('redir END') -- Filter ctermfg and ctermbg, the numbers depend on the terminal @@ -48,11 +48,11 @@ describe(':highlight', function() expect([[ - NewGroup xxx term=bold cterm=italic ctermfg=2 ctermbg=3 + NewGroup xxx cterm=italic ctermfg=2 ctermbg=3 Group2 xxx cleared - Group3 xxx term=underline cterm=bold + Group3 xxx cterm=bold NewGroup xxx cleared @@ -65,6 +65,6 @@ describe(':highlight', function() Group3 xxx cleared - E475: term='asdf]]) + E475: cterm='asdf]]) end) end) -- cgit From 40b7990553997d9eabb21b746346356016b373c5 Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Sun, 15 Feb 2015 10:21:13 -0300 Subject: test: Fix 051_highlight_spec.lua - The syntax `gui=` is invalid when setting properties of highlight group. - Wait for the initial "-- More --" prompt before continuing. Required to avoid a race condition --- test/functional/legacy/051_highlight_spec.lua | 32 ++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'test/functional') diff --git a/test/functional/legacy/051_highlight_spec.lua b/test/functional/legacy/051_highlight_spec.lua index b4493583b2..19eb4104cd 100644 --- a/test/functional/legacy/051_highlight_spec.lua +++ b/test/functional/legacy/051_highlight_spec.lua @@ -1,22 +1,43 @@ -- vim: set foldmethod=marker foldmarker=[[,]] : -- Tests for ":highlight". +local Screen = require('test.functional.ui.screen') local helpers = require('test.functional.helpers') local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert local execute, expect = helpers.execute, helpers.expect +local wait = helpers.wait describe(':highlight', function() setup(clear) it('is working', function() + local screen = Screen.new(35, 10) + screen:attach() -- Basic test if ":highlight" doesn't crash execute('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 + screen:expect([[ + :highlight | + SpecialKey xxx ctermfg=4 | + guifg=Blue | + EndOfBuffer xxx links to NonText| + | + NonText xxx ctermfg=12 | + gui=bold | + guifg=Blue | + Directory xxx ctermfg=4 | + -- More --^ | + ]]) + feed('q') + wait() -- wait until we're back to normal execute('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= guifg=#00ff00 guibg=Cyan') - execute('hi Group2 cterm=') + 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') @@ -48,7 +69,11 @@ describe(':highlight', function() expect([[ - NewGroup xxx cterm=italic ctermfg=2 ctermbg=3 + NewGroup xxx cterm=italic + ctermfg=2 + ctermbg=3 + guifg=#00ff00 + guibg=Cyan Group2 xxx cleared @@ -66,5 +91,6 @@ describe(':highlight', function() Group3 xxx cleared E475: cterm='asdf]]) + screen:detach() end) end) -- cgit