fix missing summary after TSamLast call
All checks were successful
tests / test (push) Successful in 9s
All checks were successful
tests / test (push) Successful in 9s
This commit is contained in:
@@ -262,8 +262,24 @@ describe("test-samurai core (no bundled runners)", function()
|
||||
"gamma -- delta",
|
||||
})
|
||||
|
||||
local cmd_calls = {}
|
||||
local orig_cmd = vim.cmd
|
||||
vim.cmd = function(cmd)
|
||||
table.insert(cmd_calls, cmd)
|
||||
return orig_cmd(cmd)
|
||||
end
|
||||
|
||||
core.listing_break_on_dashes()
|
||||
|
||||
local has_noh = false
|
||||
for _, cmd in ipairs(cmd_calls) do
|
||||
if cmd == "noh" then
|
||||
has_noh = true
|
||||
break
|
||||
end
|
||||
end
|
||||
assert.is_true(has_noh)
|
||||
|
||||
local broken = vim.api.nvim_buf_get_lines(buf, 0, -1, false)
|
||||
assert.same({
|
||||
"alpha \\",
|
||||
@@ -279,6 +295,164 @@ describe("test-samurai core (no bundled runners)", function()
|
||||
"alpha -- beta",
|
||||
"gamma -- delta",
|
||||
}, joined)
|
||||
|
||||
vim.cmd = orig_cmd
|
||||
end)
|
||||
|
||||
it("saves all buffers before running tests", function()
|
||||
local runner = {
|
||||
name = "test-runner-save-buffers",
|
||||
}
|
||||
|
||||
function runner.is_test_file(_bufnr)
|
||||
return true
|
||||
end
|
||||
|
||||
function runner.find_nearest(bufnr, _row, _col)
|
||||
return { file = vim.api.nvim_buf_get_name(bufnr), cwd = vim.loop.cwd(), test_name = "TestA" }
|
||||
end
|
||||
|
||||
function runner.build_command(spec)
|
||||
return { cmd = { "echo", "nearest" }, cwd = spec.cwd }
|
||||
end
|
||||
|
||||
function runner.parse_results(_output)
|
||||
return { passes = {}, failures = {}, skips = {} }
|
||||
end
|
||||
|
||||
function runner.output_parser()
|
||||
return {
|
||||
on_line = function(_line, _state)
|
||||
return nil
|
||||
end,
|
||||
on_complete = function(output, _state)
|
||||
return runner.parse_results(output)
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
function runner.parse_test_output(_output)
|
||||
return {}
|
||||
end
|
||||
|
||||
function runner.collect_failed_locations(_failures, _command, _scope_kind)
|
||||
return {}
|
||||
end
|
||||
|
||||
package.loaded["test-samurai-save-buffers-runner"] = runner
|
||||
test_samurai.setup({ runner_modules = { "test-samurai-save-buffers-runner" } })
|
||||
|
||||
local bufnr = vim.api.nvim_create_buf(false, true)
|
||||
vim.api.nvim_buf_set_name(bufnr, "/tmp/test_samurai_save_buffers.go")
|
||||
vim.bo[bufnr].filetype = "go"
|
||||
vim.api.nvim_set_current_buf(bufnr)
|
||||
|
||||
local cmd_calls = {}
|
||||
local orig_cmd = vim.cmd
|
||||
vim.cmd = function(cmd)
|
||||
table.insert(cmd_calls, cmd)
|
||||
end
|
||||
|
||||
local orig_jobstart = vim.fn.jobstart
|
||||
vim.fn.jobstart = function(_cmd, opts)
|
||||
if opts.on_exit then
|
||||
opts.on_exit(nil, 0, nil)
|
||||
end
|
||||
return 1
|
||||
end
|
||||
|
||||
core.run_nearest()
|
||||
|
||||
vim.fn.jobstart = orig_jobstart
|
||||
vim.cmd = orig_cmd
|
||||
|
||||
local has_wall = false
|
||||
for _, cmd in ipairs(cmd_calls) do
|
||||
if cmd == "wall" then
|
||||
has_wall = true
|
||||
break
|
||||
end
|
||||
end
|
||||
assert.is_true(has_wall)
|
||||
end)
|
||||
|
||||
it("renders the summary in the listing after TSamLast", function()
|
||||
local runner = {
|
||||
name = "test-runner-last-summary",
|
||||
}
|
||||
|
||||
function runner.is_test_file(_bufnr)
|
||||
return true
|
||||
end
|
||||
|
||||
function runner.find_nearest(bufnr, _row, _col)
|
||||
return { file = vim.api.nvim_buf_get_name(bufnr), cwd = vim.loop.cwd(), test_name = "TestA" }
|
||||
end
|
||||
|
||||
function runner.build_command(spec)
|
||||
return { cmd = { "echo", "nearest" }, cwd = spec.cwd }
|
||||
end
|
||||
|
||||
function runner.build_file_command(_bufnr)
|
||||
return { cmd = { "echo", "file" } }
|
||||
end
|
||||
|
||||
function runner.build_all_command(_bufnr)
|
||||
return { cmd = { "echo", "all" } }
|
||||
end
|
||||
|
||||
function runner.build_failed_command(last_command, _failures, _scope_kind)
|
||||
return { cmd = { "echo", "failed" }, cwd = last_command and last_command.cwd or nil }
|
||||
end
|
||||
|
||||
function runner.parse_results(_output)
|
||||
return { passes = { "TestA" }, failures = { "TestB" }, skips = {} }
|
||||
end
|
||||
|
||||
function runner.output_parser()
|
||||
return {
|
||||
on_line = function(_line, _state)
|
||||
return nil
|
||||
end,
|
||||
on_complete = function(output, _state)
|
||||
return runner.parse_results(output)
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
function runner.parse_test_output(_output)
|
||||
return {}
|
||||
end
|
||||
|
||||
function runner.collect_failed_locations(_failures, _command, _scope_kind)
|
||||
return {}
|
||||
end
|
||||
|
||||
package.loaded["test-samurai-last-summary-runner"] = runner
|
||||
test_samurai.setup({ runner_modules = { "test-samurai-last-summary-runner" } })
|
||||
|
||||
local bufnr = vim.api.nvim_create_buf(false, true)
|
||||
vim.api.nvim_buf_set_name(bufnr, "/tmp/test_samurai_last_summary.go")
|
||||
vim.bo[bufnr].filetype = "go"
|
||||
vim.api.nvim_set_current_buf(bufnr)
|
||||
|
||||
local orig_jobstart = vim.fn.jobstart
|
||||
vim.fn.jobstart = function(_cmd, opts)
|
||||
if opts.on_exit then
|
||||
opts.on_exit(nil, 0, nil)
|
||||
end
|
||||
return 1
|
||||
end
|
||||
|
||||
core.run_nearest()
|
||||
core.run_last()
|
||||
|
||||
local listing_buf = vim.api.nvim_get_current_buf()
|
||||
local lines = vim.api.nvim_buf_get_lines(listing_buf, 0, -1, false)
|
||||
local joined = table.concat(lines, "\n")
|
||||
assert.is_true(joined:find("TOTAL", 1, true) ~= nil)
|
||||
|
||||
vim.fn.jobstart = orig_jobstart
|
||||
end)
|
||||
|
||||
it("filters listing entries and restores them", function()
|
||||
|
||||
Reference in New Issue
Block a user