This commit is contained in:
@@ -83,6 +83,7 @@ Additional keymaps:
|
||||
- Press `<cr>` on a `[ FAIL ] ...` line in the listing to open/update the **Detail-Float** as a 20/80 split (left 20% listing, right 80% detail).
|
||||
- ANSI color translation is only applied in the **Detail-Float**; the **Test-Listing-Float** shows raw text without ANSI translation.
|
||||
- `<esc><esc>` hides the floating window; `TSamShowOutput` reopens it.
|
||||
- If no output is captured for a test, the **Detail-Float** shows `No output captured`.
|
||||
|
||||
## Runner architecture
|
||||
|
||||
|
||||
@@ -77,7 +77,8 @@ Detail-Float: right subwindow showing detailed output for a test.
|
||||
After running a test command, the UI opens in listing mode (only the
|
||||
Test-Listing-Float is visible). Press <cr> on a [ FAIL ] entry to open
|
||||
the Detail-Float with a 20/80 split. ANSI colors are translated only
|
||||
inside the Detail-Float.
|
||||
inside the Detail-Float. If no output is captured for a test, the
|
||||
Detail-Float shows "No output captured".
|
||||
|
||||
|
||||
RUNNER ARCHITECTURE *test-samurai-runners*
|
||||
|
||||
@@ -88,6 +88,9 @@ local function help_lines()
|
||||
" <leader>z Toggle Detail-Float full width",
|
||||
" <C-c> Close Detail-Float",
|
||||
" ? Show this help",
|
||||
"",
|
||||
"Notes:",
|
||||
" No output captured -> shows placeholder text",
|
||||
}
|
||||
end
|
||||
|
||||
@@ -1329,7 +1332,7 @@ function M.open_test_output_at_cursor()
|
||||
end
|
||||
end
|
||||
if type(output) ~= "table" or #output == 0 then
|
||||
vim.notify("[test-samurai] No output captured for " .. test_name, vim.log.levels.WARN)
|
||||
open_detail_split({ "", "No output captured" }, "default")
|
||||
return
|
||||
end
|
||||
local border_kind = status and status:lower() or nil
|
||||
|
||||
@@ -554,4 +554,95 @@ describe("test-samurai core (no bundled runners)", function()
|
||||
assert.equals("TestC", build_specs[2].full_name)
|
||||
assert.equals("Suite TestC", build_specs[2].mocha_full_title)
|
||||
end)
|
||||
|
||||
it("opens detail float with placeholder when no output captured", function()
|
||||
local runner = {
|
||||
name = "test-runner-no-output",
|
||||
}
|
||||
|
||||
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 = {}, failures = { "TestMissingOutput" }, 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-no-output-runner"] = runner
|
||||
test_samurai.setup({ runner_modules = { "test-samurai-no-output-runner" } })
|
||||
|
||||
local bufnr = vim.api.nvim_create_buf(false, true)
|
||||
vim.api.nvim_buf_set_name(bufnr, "/tmp/test_samurai_no_output.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()
|
||||
|
||||
local listing_buf = vim.api.nvim_get_current_buf()
|
||||
local lines = vim.api.nvim_buf_get_lines(listing_buf, 0, -1, false)
|
||||
local target = nil
|
||||
for i, line in ipairs(lines) do
|
||||
if line:match("^%[ FAIL %] %- TestMissingOutput") then
|
||||
target = i
|
||||
break
|
||||
end
|
||||
end
|
||||
assert.is_true(target ~= nil)
|
||||
|
||||
vim.api.nvim_win_set_cursor(0, { target, 0 })
|
||||
core.open_test_output_at_cursor()
|
||||
|
||||
local detail_buf = vim.api.nvim_get_current_buf()
|
||||
local detail_lines = vim.api.nvim_buf_get_lines(detail_buf, 0, -1, false)
|
||||
assert.same({ "", "No output captured" }, detail_lines)
|
||||
|
||||
vim.fn.jobstart = orig_jobstart
|
||||
end)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user