test: don't use minimal timeout for "intermediate" flag (#27620)

With "intermediate" flag, only using minimal timeout is too short and
may lead to failures.
Also remove the fallback timeout in screen:expect_unchanged(), as having
a different fallback timeout than screen:expect() is confusing.
This commit is contained in:
zeertzjq
2024-02-25 13:35:24 +08:00
committed by GitHub
parent 2e1f5055ac
commit b72dc2d8ad
3 changed files with 8 additions and 12 deletions

View File

@@ -2669,10 +2669,9 @@ describe("TUI 'term' option", function()
}) })
local full_timeout = screen.timeout local full_timeout = screen.timeout
screen.timeout = 250 -- We want screen:expect() to fail quickly.
retry(nil, 2 * full_timeout, function() -- Wait for TUI thread to set 'term'. retry(nil, 2 * full_timeout, function() -- Wait for TUI thread to set 'term'.
feed_data(":echo 'term='.(&term)\n") feed_data(":echo 'term='.(&term)\n")
screen:expect { any = 'term=' .. term_expected } screen:expect { any = 'term=' .. term_expected, timeout = 250 }
end) end)
end end

View File

@@ -638,7 +638,6 @@ screen:redraw_debug() to show all intermediate screen states.]]
end end
function Screen:expect_unchanged(intermediate, waittime_ms, ignore_attrs) function Screen:expect_unchanged(intermediate, waittime_ms, ignore_attrs)
waittime_ms = waittime_ms and waittime_ms or 100
-- Collect the current screen state. -- Collect the current screen state.
local kwargs = self:get_snapshot(nil, ignore_attrs) local kwargs = self:get_snapshot(nil, ignore_attrs)
@@ -689,8 +688,8 @@ function Screen:_wait(check, flags)
-- For an "unchanged" test, flags.timeout is the time during which the state -- For an "unchanged" test, flags.timeout is the time during which the state
-- must not change, so always wait this full time. -- must not change, so always wait this full time.
if (flags.unchanged or flags.intermediate) and flags.timeout then if flags.unchanged then
minimal_timeout = timeout minimal_timeout = flags.timeout or default_timeout_factor * 20
end end
assert(timeout >= minimal_timeout) assert(timeout >= minimal_timeout)
@@ -711,12 +710,12 @@ function Screen:_wait(check, flags)
intermediate_seen = true intermediate_seen = true
end end
if not err then if not err and (not flags.intermediate or intermediate_seen) then
success_seen = true success_seen = true
if did_minimal_timeout then if did_minimal_timeout then
self._session:stop() self._session:stop()
end end
elseif success_seen and #args > 0 then elseif err and success_seen and #args > 0 then
success_seen = false success_seen = false
failure_after_success = true failure_after_success = true
-- print(inspect(args)) -- print(inspect(args))

View File

@@ -231,10 +231,6 @@ describe("'wildmenu'", function()
end) end)
it('with laststatus=0, :vsplit, :term #2255', function() it('with laststatus=0, :vsplit, :term #2255', function()
-- Because this test verifies a _lack_ of activity after screen:sleep(), we
-- must wait the full timeout. So make it reasonable.
screen.timeout = 1000
if not is_os('win') then if not is_os('win') then
command('set shell=sh') -- Need a predictable "$" prompt. command('set shell=sh') -- Need a predictable "$" prompt.
command('let $PS1 = "$"') command('let $PS1 = "$"')
@@ -257,7 +253,9 @@ describe("'wildmenu'", function()
-- Check only the last 2 lines, because the shell output is -- Check only the last 2 lines, because the shell output is
-- system-dependent. -- system-dependent.
screen:expect { any = '! # & < = > @ > |\n:!^' } screen:expect { any = '! # & < = > @ > |\n:!^' }
screen:expect_unchanged() -- Because this test verifies a _lack_ of activity, we must wait the full timeout.
-- So make it reasonable.
screen:expect_unchanged(false, 1000)
end) end)
it('wildmode=list,full and messages interaction #10092', function() it('wildmode=list,full and messages interaction #10092', function()