Skip to content

Commit de0a88d

Browse files
committed
feat(test)!: soft deprecate ignore_lines in expect_screenshot()
Details: - Use new `ignore_text` and `ignore_attr` options instead. Related to #1300
1 parent 5860a9e commit de0a88d

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ There are following change types:
6161

6262
## mini.test
6363

64+
### Refine
65+
66+
- Soft deprecate `ignore_lines` option in `expect.reference_screenshot()` in favor of more capable `ignore_text` and `ignore_attr` options. For example, `ignore_lines = { 1 }` is the same as supplying both `ignore_text = { 1 }` and `ignore_attr = { 1 }`.
67+
68+
It will work at least until the next release, after which its support will be removed. Sorry for the inconvenience.
69+
6470
### Expand
6571

6672
- Update `expect.reference_screenshot()` to support separate ignoring of text and attribute screenshot data via new `ignore_text` and `ignore_attr` options.

doc/mini-test.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -587,9 +587,6 @@ Parameters ~
587587
- <ignore_attr> `(boolean|table)` - whether to ignore all or some attr lines.
588588
If `true` - ignore all, if number array - ignore attr of those lines,
589589
if `false` - do not ignore any. Default: `false`.
590-
- <ignore_lines> `(table)` - array of line numbers to ignore during compare.
591-
Same as supplying line number as part of <ignore_text> and <ignore_attr>.
592-
Default: `nil` to check all lines.
593590
- <directory> `(string)` - directory where automatically constructed `path`
594591
is located. Default: "tests/screenshots".
595592

lua/mini/test.lua

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -746,18 +746,24 @@ end
746746
--- - <ignore_attr> `(boolean|table)` - whether to ignore all or some attr lines.
747747
--- If `true` - ignore all, if number array - ignore attr of those lines,
748748
--- if `false` - do not ignore any. Default: `false`.
749-
--- - <ignore_lines> `(table)` - array of line numbers to ignore during compare.
750-
--- Same as supplying line number as part of <ignore_text> and <ignore_attr>.
751-
--- Default: `nil` to check all lines.
752749
--- - <directory> `(string)` - directory where automatically constructed `path`
753750
--- is located. Default: "tests/screenshots".
754751
MiniTest.expect.reference_screenshot = function(screenshot, path, opts)
755752
if screenshot == nil then return true end
756753

757-
local default_opts = { force = false, ignore_lines = {}, directory = 'tests/screenshots' }
758-
default_opts.ignore_text, default_opts.ignore_attr = false, false
754+
local default_opts = { force = false, ignore_text = false, ignore_attr = false, directory = 'tests/screenshots' }
759755
opts = vim.tbl_extend('force', default_opts, opts or {})
760756

757+
-- TODO: Remove after releasing 'mini.nvim' 0.17.0
758+
if opts.ignore_lines ~= nil then
759+
vim.notify(
760+
'(mini.test) `ignore_lines` is soft deprecated in favor of separate `ignore_text` and `ignore_attr`.'
761+
.. ' It will work at least until the next release, after which its support will be removed.'
762+
.. ' Sorry for the inconvenience.'
763+
)
764+
end
765+
opts.ignore_lines = opts.ignore_lines or {}
766+
761767
H.cache.n_screenshots = H.cache.n_screenshots + 1
762768

763769
if path == nil then

tests/test_test.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -969,6 +969,11 @@ T['expect']['reference_screenshot()']['respects `opts.force` argument'] = functi
969969
end
970970

971971
T['expect']['reference_screenshot()']['respects `opts.ignore_lines`'] = function()
972+
-- Do not show soft deprecation message
973+
local notify_orig = vim.notify
974+
vim.notify = function() end
975+
MiniTest.finally(function() vim.notify = notify_orig end)
976+
972977
local path = get_ref_path('reference-screenshot')
973978
child.set_size(5, 12)
974979
local validate = function(ignore_lines, ref)

0 commit comments

Comments
 (0)