mirror of
https://github.com/neovim/neovim.git
synced 2025-12-17 11:55:34 +00:00
test/ui: make screen:expect() print full state when height does not match
This commit is contained in:
@@ -391,27 +391,31 @@ function Screen:expect(expected, attr_ids, attr_ignore, ...)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if grid ~= nil then
|
if grid ~= nil then
|
||||||
|
local err_msg, msg_expected_rows = nil, {}
|
||||||
-- `expected` must match the screen lines exactly.
|
-- `expected` must match the screen lines exactly.
|
||||||
if #actual_rows ~= #expected_rows then
|
if #actual_rows ~= #expected_rows then
|
||||||
return "Expected screen state's row count(" .. #expected_rows
|
err_msg = "Expected screen height " .. #expected_rows
|
||||||
.. ') differs from configured height(' .. #actual_rows .. ') of Screen.'
|
.. ' differs from actual height ' .. #actual_rows .. '.'
|
||||||
end
|
end
|
||||||
for i = 1, #actual_rows do
|
for i = 1, #expected_rows do
|
||||||
|
msg_expected_rows[i] = expected_rows[i]
|
||||||
if expected_rows[i] ~= actual_rows[i] and expected_rows[i] ~= "{IGNORE}|" then
|
if expected_rows[i] ~= actual_rows[i] and expected_rows[i] ~= "{IGNORE}|" then
|
||||||
local msg_expected_rows = {}
|
|
||||||
for j = 1, #expected_rows do
|
|
||||||
msg_expected_rows[j] = expected_rows[j]
|
|
||||||
end
|
|
||||||
msg_expected_rows[i] = '*' .. msg_expected_rows[i]
|
msg_expected_rows[i] = '*' .. msg_expected_rows[i]
|
||||||
actual_rows[i] = '*' .. actual_rows[i]
|
if i <= #actual_rows then
|
||||||
return (
|
actual_rows[i] = '*' .. actual_rows[i]
|
||||||
'Row ' .. tostring(i) .. ' did not match.\n'
|
end
|
||||||
..'Expected:\n |'..table.concat(msg_expected_rows, '\n |')..'\n'
|
if err_msg == nil then
|
||||||
..'Actual:\n |'..table.concat(actual_rows, '\n |')..'\n\n'..[[
|
err_msg = 'Row ' .. tostring(i) .. ' did not match.'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if err_msg ~= nil then
|
||||||
|
return (
|
||||||
|
err_msg..'\nExpected:\n |'..table.concat(msg_expected_rows, '\n |')..'\n'
|
||||||
|
..'Actual:\n |'..table.concat(actual_rows, '\n |')..'\n\n'..[[
|
||||||
To print the expect() call that would assert the current screen state, use
|
To print the expect() call that would assert the current screen state, use
|
||||||
screen:snapshot_util(). In case of non-deterministic failures, use
|
screen:snapshot_util(). In case of non-deterministic failures, use
|
||||||
screen:redraw_debug() to show all intermediate screen states. ]])
|
screen:redraw_debug() to show all intermediate screen states. ]])
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user