Skip to content

Commit b00bd57

Browse files
authored
feat: run_test to take config to override the calculated launch config (#12)
1 parent 5ef224f commit b00bd57

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

lua/java-core/dap.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ function M.dap_run(config)
105105
---@type uv_tcp_t
106106
local server
107107

108-
require('dap').run(config, {
108+
require('dap').run(config --[[@as Configuration]], {
109109
before = function(conf)
110110
log.debug('running before dap callback')
111111

lua/java-core/ls/adapters/test-adapter.lua

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,26 @@ local JavaTestClient = require('java-core.ls.clients.java-test-client')
44

55
local M = {}
66

7-
---@class JavaTestLauncherConfig
7+
---@class JavaTestLauncherConfigOverridable: JavaDapConfiguration
8+
---@field name? string
9+
---@field type? string
10+
---@field request? string
11+
---@field mainClass? string
12+
---@field projectName? string
13+
---@field cwd? string
14+
---@field classPaths? string[]
15+
---@field modulePaths? string[]
16+
---@field vmArgs? string
17+
---@field noDebug? boolean
18+
---@field javaExec? string
19+
---@field args? string
20+
---@field env? { [string]: string; }
21+
---@field envFile? string
22+
---@field sourcePaths? string[]
23+
---@field preLaunchTask? string
24+
---@field postDebugTask? string
25+
26+
---@class JavaTestLauncherConfig: JavaDapConfiguration
827
---@field name string
928
---@field type string
1029
---@field request string

lua/java-core/ls/helpers/test-helper.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,9 @@ end
9898

9999
---Run the given test
100100
---@param tests JavaTestFindJavaProjectsResponse
101+
---@param config? JavaTestLauncherConfigOverridable config to override the default values in test launcher config
101102
---@return Promise
102-
function M:run_test(tests)
103+
function M:run_test(tests, config)
103104
---@type JavaTestJunitLaunchArguments
104105
local launch_args
105106

@@ -129,6 +130,9 @@ function M:run_test(tests)
129130

130131
log.debug('dap launcher config is: ', dap_launcher_config)
131132

133+
dap_launcher_config =
134+
vim.tbl_deep_extend('force', dap_launcher_config, config or {})
135+
132136
return JavaDap.dap_run(dap_launcher_config)
133137
end
134138
)

0 commit comments

Comments
 (0)