diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-11-09 23:16:52 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-09 23:16:52 -0800 |
commit | ece3d19b026b80c933e650c4422f8b1a4ab4bde9 (patch) | |
tree | 24400f4eb3be31db2a4d9fa0999bb9ca3ef0344c /test/functional/ui/screen.lua | |
parent | 268252c8c729fa6076037c04966c0a6e694dab75 (diff) | |
parent | 4abb67c027e93afac8c2f436d48956fffcd69848 (diff) | |
download | rneovim-ece3d19b026b80c933e650c4422f8b1a4ab4bde9.tar.gz rneovim-ece3d19b026b80c933e650c4422f8b1a4ab4bde9.tar.bz2 rneovim-ece3d19b026b80c933e650c4422f8b1a4ab4bde9.zip |
Merge #11004 'test/Screen:expect: support "{MATCH:…}"'
Diffstat (limited to 'test/functional/ui/screen.lua')
-rw-r--r-- | test/functional/ui/screen.lua | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index 41e022791e..d3f78bf77b 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -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:x}|" lines are matched against Lua pattern `x`. -- 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 @@ -390,9 +390,10 @@ 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 + 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] |