mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 11:58:17 +00:00
test: make expect_unchanged() less confusing (#22255)
Problem: The sleep before collecting the initial screen state is confusing and may lead to unexpected success if it comes after a blocking RPC call. Solution: Remove that sleep and add an "intermediate" argument.
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
local Screen = require('test.functional.ui.screen')
|
local Screen = require('test.functional.ui.screen')
|
||||||
local clear, feed, exec, command = helpers.clear, helpers.feed, helpers.exec, helpers.command
|
local clear, feed, exec, command = helpers.clear, helpers.feed, helpers.exec, helpers.command
|
||||||
local poke_eventloop = helpers.poke_eventloop
|
|
||||||
|
|
||||||
describe('search stat', function()
|
describe('search stat', function()
|
||||||
local screen
|
local screen
|
||||||
@@ -80,12 +79,11 @@ describe('search stat', function()
|
|||||||
{1:~ }|
|
{1:~ }|
|
||||||
/foo [1/2] |
|
/foo [1/2] |
|
||||||
]])
|
]])
|
||||||
|
-- Note: there is an intermediate state where the search stat disappears.
|
||||||
feed('n')
|
feed('n')
|
||||||
poke_eventloop()
|
screen:expect_unchanged(true)
|
||||||
screen:expect_unchanged()
|
|
||||||
feed('n')
|
feed('n')
|
||||||
poke_eventloop()
|
screen:expect_unchanged(true)
|
||||||
screen:expect_unchanged()
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- oldtest: Test_search_stat_then_gd()
|
-- oldtest: Test_search_stat_then_gd()
|
||||||
|
@@ -77,13 +77,8 @@ describe('vim.ui_attach', function()
|
|||||||
}
|
}
|
||||||
|
|
||||||
feed '<c-y>'
|
feed '<c-y>'
|
||||||
screen:expect{grid=[[
|
-- There is an intermediate state where the 'showmode' message disappears.
|
||||||
foobar^ |
|
screen:expect_unchanged(true)
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
{2:-- INSERT --} |
|
|
||||||
]], intermediate=true}
|
|
||||||
expect_events {
|
expect_events {
|
||||||
{ "popupmenu_hide" };
|
{ "popupmenu_hide" };
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,6 @@ local meths = helpers.meths
|
|||||||
local exec = helpers.exec
|
local exec = helpers.exec
|
||||||
local exec_lua = helpers.exec_lua
|
local exec_lua = helpers.exec_lua
|
||||||
local assert_alive = helpers.assert_alive
|
local assert_alive = helpers.assert_alive
|
||||||
local poke_eventloop = helpers.poke_eventloop
|
|
||||||
|
|
||||||
|
|
||||||
local content1 = [[
|
local content1 = [[
|
||||||
@@ -30,8 +29,6 @@ describe("folded lines", function()
|
|||||||
local function with_ext_multigrid(multigrid)
|
local function with_ext_multigrid(multigrid)
|
||||||
local screen
|
local screen
|
||||||
before_each(function()
|
before_each(function()
|
||||||
clear()
|
|
||||||
command('hi VertSplit gui=reverse')
|
|
||||||
screen = Screen.new(45, 8)
|
screen = Screen.new(45, 8)
|
||||||
screen:attach({rgb=true, ext_multigrid=multigrid})
|
screen:attach({rgb=true, ext_multigrid=multigrid})
|
||||||
screen:set_default_attr_ids({
|
screen:set_default_attr_ids({
|
||||||
@@ -166,12 +163,10 @@ describe("folded lines", function()
|
|||||||
end
|
end
|
||||||
-- CursorLine is applied correctly with screenrow motions #22232
|
-- CursorLine is applied correctly with screenrow motions #22232
|
||||||
feed("jgk")
|
feed("jgk")
|
||||||
poke_eventloop()
|
screen:expect_unchanged(true)
|
||||||
screen:expect_unchanged()
|
|
||||||
-- CursorLine is applied correctly when closing a fold when cursor is not at fold start
|
-- CursorLine is applied correctly when closing a fold when cursor is not at fold start
|
||||||
feed("zo4Gzc")
|
feed("zo4Gzc")
|
||||||
poke_eventloop()
|
screen:expect_unchanged(true)
|
||||||
screen:expect_unchanged()
|
|
||||||
command("set cursorlineopt=line")
|
command("set cursorlineopt=line")
|
||||||
if multigrid then
|
if multigrid then
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
|
@@ -2886,7 +2886,8 @@ it(':substitute with inccommand during :terminal activity', function()
|
|||||||
feed('gg')
|
feed('gg')
|
||||||
feed(':%s/foo/ZZZ')
|
feed(':%s/foo/ZZZ')
|
||||||
sleep(20) -- Allow some terminal activity.
|
sleep(20) -- Allow some terminal activity.
|
||||||
helpers.poke_eventloop()
|
poke_eventloop()
|
||||||
|
screen:sleep(0)
|
||||||
screen:expect_unchanged()
|
screen:expect_unchanged()
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
@@ -470,15 +470,19 @@ screen:redraw_debug() to show all intermediate screen states. ]])
|
|||||||
end, expected)
|
end, expected)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Screen:expect_unchanged(waittime_ms, ignore_attrs, request_cb)
|
function Screen:expect_unchanged(intermediate, waittime_ms, ignore_attrs)
|
||||||
waittime_ms = waittime_ms and waittime_ms or 100
|
waittime_ms = waittime_ms and waittime_ms or 100
|
||||||
-- Collect the current screen state.
|
-- Collect the current screen state.
|
||||||
self:sleep(0, request_cb)
|
|
||||||
local kwargs = self:get_snapshot(nil, ignore_attrs)
|
local kwargs = self:get_snapshot(nil, ignore_attrs)
|
||||||
|
|
||||||
-- Check that screen state does not change.
|
if intermediate then
|
||||||
|
kwargs.intermediate = true
|
||||||
|
else
|
||||||
kwargs.unchanged = true
|
kwargs.unchanged = true
|
||||||
|
end
|
||||||
|
|
||||||
kwargs.timeout = waittime_ms
|
kwargs.timeout = waittime_ms
|
||||||
|
-- Check that screen state does not change.
|
||||||
self:expect(kwargs)
|
self:expect(kwargs)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@@ -317,6 +317,7 @@ describe('search highlighting', function()
|
|||||||
]])
|
]])
|
||||||
feed('/foo')
|
feed('/foo')
|
||||||
helpers.poke_eventloop()
|
helpers.poke_eventloop()
|
||||||
|
screen:sleep(0)
|
||||||
screen:expect_unchanged()
|
screen:expect_unchanged()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@@ -251,15 +251,7 @@ describe('timers', function()
|
|||||||
:good^ |
|
:good^ |
|
||||||
]])
|
]])
|
||||||
command('let g:val = 1')
|
command('let g:val = 1')
|
||||||
|
screen:expect_unchanged(true, load_adjust(200))
|
||||||
screen:expect{grid=[[
|
|
||||||
|
|
|
||||||
{0:~ }|
|
|
||||||
{0:~ }|
|
|
||||||
{0:~ }|
|
|
||||||
{0:~ }|
|
|
||||||
:good^ |
|
|
||||||
]], intermediate=true, timeout=load_adjust(200)}
|
|
||||||
|
|
||||||
eq(2, eval('g:val'))
|
eq(2, eval('g:val'))
|
||||||
end)
|
end)
|
||||||
|
Reference in New Issue
Block a user