Update generated neovim config
This commit is contained in:
@ -0,0 +1,15 @@
|
||||
vim.cmd('set rtp+=.')
|
||||
|
||||
require('mini.test').setup()
|
||||
|
||||
local group_depth = tonumber(vim.env.TEST_GROUP_DEPTH)
|
||||
|
||||
local quit_on_finish
|
||||
if vim.env.TEST_QUIT_ON_FINISH ~= nil then quit_on_finish = vim.env.TEST_QUIT_ON_FINISH == 'true' end
|
||||
|
||||
local reporter = MiniTest.gen_reporter.stdout({
|
||||
group_depth = group_depth,
|
||||
quit_on_finish = quit_on_finish,
|
||||
})
|
||||
|
||||
MiniTest.run_file('tests/dir-test/testref_reporters.lua', { execute = { reporter = reporter } })
|
||||
@ -0,0 +1,13 @@
|
||||
-|---------|---------|
|
||||
1|This is a call to `r
|
||||
2|eference_screenshot(
|
||||
3|)` with manual path
|
||||
4|<ame] [+] 1,1 All
|
||||
5|
|
||||
|
||||
-|---------|---------|
|
||||
1|00000000000000000000
|
||||
2|00000000000000000000
|
||||
3|00000000000000000000
|
||||
4|11111111111111111111
|
||||
5|22222222222222222222
|
||||
@ -0,0 +1,13 @@
|
||||
-|---------|--
|
||||
1|aaa
|
||||
2|~
|
||||
3|~
|
||||
4|< [+] 1,1
|
||||
5|
|
||||
|
||||
-|---------|--
|
||||
1|000000000000
|
||||
2|111111111111
|
||||
3|111111111111
|
||||
4|222222222222
|
||||
5|333333333333
|
||||
@ -0,0 +1,32 @@
|
||||
local T = MiniTest.new_set()
|
||||
|
||||
local finally_with_error, finally_no_error = false, false
|
||||
|
||||
T['finally() with error'] = function()
|
||||
MiniTest.finally(function() finally_with_error = true end)
|
||||
error()
|
||||
end
|
||||
|
||||
T['finally() with error; check'] = function() MiniTest.expect.equality(finally_with_error, true) end
|
||||
|
||||
T['finally() no error'] = function()
|
||||
MiniTest.finally(function() finally_no_error = true end)
|
||||
local res = true
|
||||
return res
|
||||
end
|
||||
|
||||
T['finally() no error; check'] = function() MiniTest.expect.equality(finally_no_error, true) end
|
||||
|
||||
T['skip(); no message'] = function()
|
||||
MiniTest.skip()
|
||||
error('This error should not take effect')
|
||||
end
|
||||
|
||||
T['skip(); with message'] = function()
|
||||
MiniTest.skip('This is a custom skip message')
|
||||
error('This error should not take effect')
|
||||
end
|
||||
|
||||
T['add_note()'] = function() MiniTest.add_note('This note should be appended') end
|
||||
|
||||
return T
|
||||
@ -0,0 +1,61 @@
|
||||
local eq = MiniTest.expect.equality
|
||||
|
||||
describe('describe()/it()', function()
|
||||
describe('nested', function()
|
||||
it('Case 1', function() end)
|
||||
it('Case 2', function() end)
|
||||
end)
|
||||
|
||||
it('Case 3', function() end)
|
||||
end)
|
||||
|
||||
describe('setup()/teardown()', function()
|
||||
local n = 0
|
||||
|
||||
describe('nested', function()
|
||||
setup(function() n = n + 1 end)
|
||||
it('setup() works', function() eq(n, 1) end)
|
||||
teardown(function() n = n + 1 end)
|
||||
end)
|
||||
|
||||
it('teardown() works', function() eq(n, 2) end)
|
||||
end)
|
||||
|
||||
describe('before_each()/after_each()', function()
|
||||
local n, m = 0, 0
|
||||
|
||||
before_each(function() n = n + 1 end)
|
||||
after_each(function() m = m + 1 end)
|
||||
|
||||
describe('nested', function()
|
||||
describe('nested 2', function()
|
||||
it('work', function() eq({ n, m }, { 1, 0 }) end)
|
||||
end)
|
||||
it('work 2', function() eq({ n, m }, { 2, 1 }) end)
|
||||
it('work 3', function() eq({ n, m }, { 3, 2 }) end)
|
||||
end)
|
||||
|
||||
it('work 4', function() eq({ n, m }, { 4, 3 }) end)
|
||||
end)
|
||||
|
||||
describe('MiniTest.skip()', function()
|
||||
it('works', function() MiniTest.skip() end)
|
||||
end)
|
||||
|
||||
describe('MiniTest.finally()', function()
|
||||
local n = 0
|
||||
|
||||
it('no error', function()
|
||||
MiniTest.finally(function() n = n + 1 end)
|
||||
eq(n, 0)
|
||||
end)
|
||||
|
||||
it('works with no error', function() eq(n, 1) end)
|
||||
|
||||
it('with error', function()
|
||||
MiniTest.finally(function() n = n + 1 end)
|
||||
error('Some error')
|
||||
end)
|
||||
|
||||
it('works with error', function() eq(n, 2) end)
|
||||
end)
|
||||
@ -0,0 +1,12 @@
|
||||
_G.custom_script_result = 'This actually ran'
|
||||
|
||||
-- Dummy call to `run()` to ensure there is no infinite loop
|
||||
MiniTest.run({
|
||||
collect = {
|
||||
find_files = function() return {} end,
|
||||
},
|
||||
})
|
||||
|
||||
-- Buffer local and global configs should be later restored
|
||||
MiniTest.config.aaa = true
|
||||
vim.b.minitest_config = { aaa = true }
|
||||
@ -0,0 +1,9 @@
|
||||
local new_set = MiniTest.new_set
|
||||
|
||||
local f = function() end
|
||||
local T = new_set({ hooks = { pre_once = f, pre_case = f, post_case = f, post_once = f } })
|
||||
|
||||
T['case 1'] = function() error('Some error') end
|
||||
T['case 2'] = function() end
|
||||
|
||||
return T
|
||||
@ -0,0 +1,14 @@
|
||||
local new_set = MiniTest.new_set
|
||||
|
||||
local T = new_set()
|
||||
|
||||
-- Collection order -----------------------------------------------------------
|
||||
T['order'] = new_set(nil, { ['From initial call'] = function() return 1 end })
|
||||
|
||||
T['order']['zzz First added'] = function() end
|
||||
T['order']['aaa Second added'] = function() end
|
||||
|
||||
-- Implicit additions should be also collected
|
||||
table.insert(T['order'], function() end)
|
||||
|
||||
return T
|
||||
@ -0,0 +1,28 @@
|
||||
local new_set = MiniTest.new_set
|
||||
|
||||
local T = new_set()
|
||||
|
||||
--stylua: ignore start
|
||||
T['first group'] = new_set()
|
||||
T['first group']['pass'] = function() end
|
||||
T['first group']['pass with notes'] = function() MiniTest.add_note('Passed note') end
|
||||
T['first group']['fail'] = function() error('Custom error', 0) end
|
||||
T['first group']['fail with notes'] = function()
|
||||
MiniTest.add_note('Failed note')
|
||||
error('Custom error after note', 0)
|
||||
end
|
||||
|
||||
T['second group'] = new_set()
|
||||
T['second group']['pass'] = function() end
|
||||
T['second group']['pass with notes'] = function() MiniTest.add_note('Passed note #2') end
|
||||
T['second group']['fail'] = function() error('Custom error #2', 0) end
|
||||
T['second group']['fail with notes'] = function()
|
||||
MiniTest.add_note('Failed note #2')
|
||||
error('Custom error after note #2', 0)
|
||||
end
|
||||
|
||||
T['third group with \n in name'] = new_set()
|
||||
T['third group with \n in name']['case with \n in name'] = function() MiniTest.add_note('Passed note #3') end
|
||||
--stylua: ignore end
|
||||
|
||||
return T
|
||||
@ -0,0 +1,13 @@
|
||||
local new_set = MiniTest.new_set
|
||||
|
||||
local T = new_set()
|
||||
|
||||
T['data'] = new_set({ data = { a = 1, b = 2 } })
|
||||
|
||||
T['data']['first level'] = function() end
|
||||
|
||||
T['data']['nested'] = new_set({ data = { a = 10, c = 30 } })
|
||||
|
||||
T['data']['nested']['should override'] = function() end
|
||||
|
||||
return T
|
||||
@ -0,0 +1,68 @@
|
||||
local new_set = MiniTest.new_set
|
||||
|
||||
_G.log = {}
|
||||
local logging = function(msg)
|
||||
return function() table.insert(_G.log, msg) end
|
||||
end
|
||||
|
||||
local T = new_set()
|
||||
|
||||
-- Track order of hook execution via adding to `_G.log`
|
||||
T['order'] = new_set({
|
||||
hooks = {
|
||||
pre_once = logging('pre_once_1'),
|
||||
pre_case = logging('pre_case_1'),
|
||||
post_case = logging('post_case_1'),
|
||||
post_once = logging('post_once_1'),
|
||||
},
|
||||
})
|
||||
|
||||
T['order']['first level'] = logging('First level test')
|
||||
|
||||
T['order']['nested'] = new_set({
|
||||
hooks = {
|
||||
pre_once = logging('pre_once_2'),
|
||||
pre_case = logging('pre_case_2'),
|
||||
post_case = logging('post_case_2'),
|
||||
post_once = logging('post_once_2'),
|
||||
},
|
||||
})
|
||||
|
||||
T['order']['nested']['first'] = logging('Nested #1')
|
||||
T['order']['nested']['second'] = logging('Nested #2')
|
||||
|
||||
-- Test that non-post-hooks are not executed if there is an error in pre hook
|
||||
local erroring = function(x)
|
||||
return function() error(x, 0) end
|
||||
end
|
||||
|
||||
T['skip_case_on_hook_error #1'] = new_set({
|
||||
hooks = {
|
||||
pre_once = erroring('pre_once_3'),
|
||||
pre_case = logging('pre_case_3'),
|
||||
post_case = logging('post_case_3'),
|
||||
post_once = logging('post_once_3'),
|
||||
},
|
||||
})
|
||||
|
||||
T['skip_case_on_hook_error #1']['case'] = logging('Skipped Case #1')
|
||||
|
||||
T['skip_case_on_hook_error #2'] = new_set({
|
||||
hooks = {
|
||||
pre_once = logging('pre_once_4'),
|
||||
pre_case = erroring('pre_case_4'),
|
||||
post_case = logging('post_case_4'),
|
||||
post_once = logging('post_once_4'),
|
||||
},
|
||||
})
|
||||
|
||||
T['skip_case_on_hook_error #2']['case'] = logging('Skipped Case #2')
|
||||
|
||||
-- Ensure that this will be called even if represented by the same function.
|
||||
-- Use this in several `_once` hooks and see that they all got executed.
|
||||
local f = logging('Same function')
|
||||
T['same `*_once` hooks'] = new_set({ hooks = { pre_once = f, post_once = f } })
|
||||
T['same `*_once` hooks']['nested'] = new_set({ hooks = { pre_once = f, post_once = f } })
|
||||
T['same `*_once` hooks']['nested']['test'] = logging('Same hook test')
|
||||
|
||||
return T
|
||||
@ -0,0 +1,3 @@
|
||||
local T = MiniTest.new_set()
|
||||
T['parametrize'] = MiniTest.new_set({ parametrize = { 'a' } }, { test = function() end })
|
||||
return T
|
||||
@ -0,0 +1,27 @@
|
||||
local new_set = MiniTest.new_set
|
||||
|
||||
local T = new_set()
|
||||
|
||||
local error_vararg = function(...)
|
||||
local args = vim.tbl_map(vim.inspect, { ... })
|
||||
error('Passed arguments: ' .. table.concat(args, ', '))
|
||||
end
|
||||
|
||||
T['parametrize'] = new_set({ parametrize = { { 'a' }, { 'b' } } })
|
||||
|
||||
-- Should be parametrized with 'a' and 'b'
|
||||
T['parametrize']['first level'] = error_vararg
|
||||
|
||||
T['parametrize']['nested'] = new_set({ parametrize = { { 1 }, { 2 } } })
|
||||
|
||||
-- Should be parametrized with cartesian product of {'a', 'b'} and {1, 2}
|
||||
T['parametrize']['nested']['test'] = error_vararg
|
||||
|
||||
T['multiple args'] = new_set({ parametrize = { { 'a', 'a' }, { 'b', 'b' } } })
|
||||
|
||||
T['multiple args']['nested'] = new_set({ parametrize = { { 1, 1 }, { 2, 2 } } })
|
||||
|
||||
-- Should be parametrized with cartesian product and each have 4 arguments
|
||||
T['multiple args']['nested']['test'] = error_vararg
|
||||
|
||||
return T
|
||||
@ -0,0 +1,9 @@
|
||||
local T = MiniTest.new_set()
|
||||
|
||||
T['run_at_location()'] = function()
|
||||
-- Should be the only one collected with `run_at_location()`
|
||||
end
|
||||
|
||||
T['extra case'] = function() end
|
||||
|
||||
return T
|
||||
Reference in New Issue
Block a user