Skip to content

Commit

Permalink
test/Screen:expect: replace "{IGNORE}" with "{MATCH:…}"
Browse files Browse the repository at this point in the history
ref #11004
  • Loading branch information
justinmk committed Nov 10, 2019
1 parent c0abaf9 commit e9c3149
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 22 deletions.
2 changes: 1 addition & 1 deletion test/functional/terminal/scrollback_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ describe("'scrollback' option", function()
38: line |
39: line |
40: line |
{IGNORE}|
{MATCH:.*}|
{3:-- TERMINAL --} |
]]}
end
Expand Down
2 changes: 1 addition & 1 deletion test/functional/terminal/tui_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ describe('TUI', function()
|
{4:~ }|
{5: }|
{8:paste: Error executing lua: vim.lua:214: Vim:E21: }|
{MATCH:paste: Error executing lua: vim.lua:%d+: Vim:E21: }|
{8:Cannot make changes, 'modifiable' is off} |
{10:Press ENTER or type command to continue}{1: } |
{3:-- TERMINAL --} |
Expand Down
14 changes: 7 additions & 7 deletions test/functional/ui/messages_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ describe('ui/ext_messages', function()
feed('G$x')
screen:expect{grid=[[
line 1 |
{IGNORE}|
{MATCH:.*}|
{1:~ }|
{1:~ }|
{1:~ }|
Expand Down Expand Up @@ -966,7 +966,7 @@ describe('ui/ext_messages', function()
{1:~ }|
{1:~ }|
{1:~ }|
{IGNORE}|
{MATCH:.*}|
{1:~ }|
{1:~ }Nvim is open source and freely distributable{1: }|
{1:~ }https://neovim.io/#chat{1: }|
Expand All @@ -976,8 +976,8 @@ describe('ui/ext_messages', function()
{1:~ }type :q{5:<Enter>} to exit {1: }|
{1:~ }type :help{5:<Enter>} for help {1: }|
{1:~ }|
{IGNORE}|
{IGNORE}|
{MATCH:.*}|
{MATCH:.*}|
{1:~ }|
{1:~ }|
{1:~ }|
Expand Down Expand Up @@ -1022,7 +1022,7 @@ describe('ui/ext_messages', function()
|
|
|
{IGNORE}|
{MATCH:.*}|
|
Nvim is open source and freely distributable |
https://neovim.io/#chat |
Expand All @@ -1032,8 +1032,8 @@ describe('ui/ext_messages', function()
type :q{5:<Enter>} to exit |
type :help{5:<Enter>} for help |
|
{IGNORE}|
{IGNORE}|
{MATCH:.*}|
{MATCH:.*}|
|
|
|
Expand Down
24 changes: 11 additions & 13 deletions test/functional/ui/screen.lua
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ local ext_keys = {
-- grid: Expected screen state (string). Each line represents a screen
-- row. Last character of each row (typically "|") is stripped.
-- Common indentation is stripped.
-- Lines containing only "{IGNORE}|" are skipped.
-- "{MATCH:pat}|" lines are matched against Lua pattern `pat`.
-- attr_ids: Expected text attributes. Screen rows are transformed according
-- to this table, as follows: each substring S composed of
-- characters having the same attributes will be substituted by
Expand Down Expand Up @@ -390,18 +390,16 @@ function Screen:expect(expected, attr_ids, ...)
err_msg = "Expected screen height " .. #expected_rows
.. ' differs from actual height ' .. #actual_rows .. '.'
end
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
local m = expected_rows[i]:match('{MATCH:(.*)}')
if not m or not actual_rows[i]:match(m) then
msg_expected_rows[i] = '*' .. msg_expected_rows[i]
if i <= #actual_rows then
actual_rows[i] = '*' .. actual_rows[i]
end
if err_msg == nil then
err_msg = 'Row ' .. tostring(i) .. ' did not match.'
end
for i, row in ipairs(expected_rows) do
msg_expected_rows[i] = row
local m = (row ~= actual_rows[i] and row:match('{MATCH:(.*)}') or nil)
if row ~= actual_rows[i] and (not m or not actual_rows[i]:match(m)) then
msg_expected_rows[i] = '*' .. msg_expected_rows[i]
if i <= #actual_rows then
actual_rows[i] = '*' .. actual_rows[i]
end
if err_msg == nil then
err_msg = 'Row ' .. tostring(i) .. ' did not match.'
end
end
end
Expand Down

0 comments on commit e9c3149

Please sign in to comment.