Skip to content

Commit

Permalink
Merge pull request #5 from x1unix/feat/filetests
Browse files Browse the repository at this point in the history
feat: support filetests
  • Loading branch information
x1unix authored Jan 31, 2025
2 parents 1d25f4a + 257ca10 commit 29b63d2
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lua/gno-nvim/gnotest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ local M = {}

---@class GnoTestCtx
---@field is_unit? boolean
---@field is_golden? boolean
---@field file? string
---@field testcase? string
---@field label string
Expand All @@ -32,6 +33,7 @@ local function get_test_context()
if is_unit or is_golden then
return {
is_unit = is_unit,
is_golden = is_golden,
file = vim.fn.fnamemodify(current_file, ":t"),
label = vim.fn.fnamemodify(current_file, ":."),
dir = dirname,
Expand Down Expand Up @@ -102,7 +104,13 @@ local function show_test_picker(ctx, gno_opts, opts)
local bufnr = vim.api.nvim_get_current_buf()
local row, _ = unpack(vim.api.nvim_win_get_cursor(0))

local options = queries.find_test_cases(bufnr, row)
local options
if ctx.is_unit then
options = queries.find_test_cases(bufnr, row)
else
options = { "file/" .. ctx.file }
end

if not options or #options == 0 then
call_gnotest({
label = ctx.label,
Expand Down Expand Up @@ -165,7 +173,7 @@ function M.run_command(opts, gno_opts)
verb = { ctx.file or "." }
test_label = ctx.label

if ctx.is_unit then
if ctx.is_unit or ctx.is_golden then
show_test_picker(ctx, gno_opts, opts)
return
end
Expand Down

0 comments on commit 29b63d2

Please sign in to comment.