Skip to content

Commit 3a148da

Browse files
committed
Add a after_test callback to dap test functions
Closes #264
1 parent a4d884a commit 3a148da

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

doc/jdtls.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,10 @@ JdtTestOpts *JdtTestOpts*
171171

172172

173173
Fields: ~
174+
{config} (nil|table) Skeleton used for the |dap-configuration|
174175
{config_overrides} (nil|JdtDapConfig) Overrides for the |dap-configuration|, see |JdtDapConfig|
175176
{until_error} (number|nil) Number of times the test should be repeated if it doesn't fail
177+
{after_test} (nil|function) Callback triggered after test run
176178

177179

178180
vim:tw=78:ts=8:noet:ft=help:norl:

lemmy.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
set -Eeuo pipefail
3+
4+
lemmy-help lua/jdtls.lua lua/jdtls/dap.lua >doc/jdtls.txt

lua/jdtls/dap.lua

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ local function maybe_repeat(lens, config, context, opts, items)
338338
end
339339

340340

341+
---@param opts JdtTestOpts
341342
local function run(lens, config, context, opts)
342343
local ok, dap = pcall(require, 'dap')
343344
if not ok then
@@ -350,7 +351,13 @@ local function run(lens, config, context, opts)
350351
local junit = require('jdtls.junit')
351352

352353
if lens.kind == TestKind.TestNG then
353-
dap.run(config)
354+
dap.run(config, {
355+
after = function()
356+
if opts.after_test then
357+
opts.after_test()
358+
end
359+
end
360+
})
354361
return
355362
end
356363

@@ -373,6 +380,9 @@ local function run(lens, config, context, opts)
373380
server:close()
374381
local items = test_results.show()
375382
maybe_repeat(lens, config, context, opts, items)
383+
if opts.after_test then
384+
opts.after_test(items)
385+
end
376386
end;
377387
})
378388
end
@@ -595,7 +605,9 @@ end
595605
---@field noDebug boolean|nil If the test should run in debug mode
596606

597607
---@class JdtTestOpts
608+
---@field config nil|table Skeleton used for the |dap-configuration|
598609
---@field config_overrides nil|JdtDapConfig Overrides for the |dap-configuration|, see |JdtDapConfig|
599610
---@field until_error number|nil Number of times the test should be repeated if it doesn't fail
611+
---@field after_test nil|function Callback triggered after test run
600612

601613
return M

0 commit comments

Comments
 (0)