From e09dcb6b36a9ca406360c218d139484caff89db6 Mon Sep 17 00:00:00 2001 From: Fredrik Averpil Date: Wed, 3 Jul 2024 22:45:41 +0200 Subject: [PATCH] fix: differentiate between "skip" and "debug_skip" --- lua/neotest-golang/init.lua | 4 +++- lua/neotest-golang/parse.lua | 4 ++-- lua/neotest-golang/runspec_dir.lua | 2 +- lua/neotest-golang/runspec_file.lua | 2 +- lua/neotest-golang/runspec_test.lua | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lua/neotest-golang/init.lua b/lua/neotest-golang/init.lua index 8f192ce5..99b9aa30 100644 --- a/lua/neotest-golang/init.lua +++ b/lua/neotest-golang/init.lua @@ -171,7 +171,9 @@ function M.workaround_neotest_issue_391(result) -- FIXME: once output is parsed, erase file contents, so to avoid JSON in -- output panel. This is a workaround for now, only because of -- https://github.com/nvim-neotest/neotest/issues/391 - vim.fn.writefile({ "" }, result.output) + if result.output ~= nil then + vim.fn.writefile({ "" }, result.output) + end end --- Adapter options. diff --git a/lua/neotest-golang/parse.lua b/lua/neotest-golang/parse.lua index c84b95ad..379ca505 100644 --- a/lua/neotest-golang/parse.lua +++ b/lua/neotest-golang/parse.lua @@ -28,7 +28,7 @@ local M = {} --- @param tree neotest.Tree --- @return table function M.results(spec, result, tree) - if spec.context.skip == true then + if spec.context.debug_and_skip == true then ---@type table local results = {} results[spec.context.id] = { @@ -95,7 +95,7 @@ function M.results(spec, result, tree) } -- if the test execution was skipped, return early - if spec.context.skip == true then + if spec.context.test_execution_skipped == true then return neotest_result end diff --git a/lua/neotest-golang/runspec_dir.lua b/lua/neotest-golang/runspec_dir.lua index 444f0bab..71580359 100644 --- a/lua/neotest-golang/runspec_dir.lua +++ b/lua/neotest-golang/runspec_dir.lua @@ -27,7 +27,7 @@ function M.build(pos) command = { "echo", msg }, context = { id = pos.id, - skip = true, + test_execution_skipped = true, pos_type = "dir", }, } diff --git a/lua/neotest-golang/runspec_file.lua b/lua/neotest-golang/runspec_file.lua index 3b829c03..d9ffbeec 100644 --- a/lua/neotest-golang/runspec_file.lua +++ b/lua/neotest-golang/runspec_file.lua @@ -14,7 +14,7 @@ function M.build(pos, tree) command = { "echo", "No tests found in file" }, context = { id = pos.id, - skip = true, + test_execution_skipped = true, pos_type = "test", -- TODO: to be implemented as "file" later }, } diff --git a/lua/neotest-golang/runspec_test.lua b/lua/neotest-golang/runspec_test.lua index 11471ab6..ef830691 100644 --- a/lua/neotest-golang/runspec_test.lua +++ b/lua/neotest-golang/runspec_test.lua @@ -53,7 +53,7 @@ function M.build(pos, strategy) if runspec_strategy ~= nil then run_spec.strategy = runspec_strategy - run_spec.context.skip = true + run_spec.context.debug_and_skip = true end return run_spec