Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix docker path #18

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lua/neotest-phpunit/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,12 @@ M.get_filter_dirs = function()
return { ".git", "node_modules" }
end

M.transform_spec_path = function(path)
return path
end

M.results_path = function()
return require("neotest.async").fn.tempname()
end

return M
32 changes: 25 additions & 7 deletions lua/neotest-phpunit/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ function NeotestAdapter.root(dir)

for _, root_file in ipairs(config.get_root_files()) do
result = lib.files.match_root_pattern(root_file)(dir)
if result then break end
if result then
break
end
end

return result
Expand All @@ -41,7 +43,9 @@ end
---@return boolean
function NeotestAdapter.filter_dir(name)
for _, filter_dir in ipairs(config.get_filter_dirs()) do
if name == filter_dir then return false end
if name == filter_dir then
return false
end
end

return true
Expand Down Expand Up @@ -73,26 +77,26 @@ function NeotestAdapter.discover_positions(path)
})
end


---@param args neotest.RunArgs
---@return neotest.RunSpec | nil
function NeotestAdapter.build_spec(args)
local position = args.tree:data()
local results_path = async.fn.tempname()
local spec_path = config.transform_spec_path(position.path)
local results_path = config.results_path()

local command = vim.tbl_flatten({
config.get_phpunit_cmd(),
position.name ~= "tests" and position.path,
position.name ~= "tests" and spec_path,
"--log-junit=" .. results_path,
})

if position.type == "test" then
local script_args = vim.tbl_flatten({
"--filter",
'::' .. position.name .. '( with data set .*)?$',
"::" .. position.name .. "( with data set .*)?$",
})

logger.info("position.path:", { position.path })
logger.info("spec_path:", { spec_path })
logger.info("--filter position.name:", { position.name })

command = vim.tbl_flatten({
Expand Down Expand Up @@ -165,6 +169,20 @@ setmetatable(NeotestAdapter, {
return opts.filter_dirs
end
end
if is_callable(opts.transform_spec_path) then
config.transform_spec_path = opts.transform_spec_path
elseif opts.transform_spec_path then
config.transform_spec_path = function()
return opts.transform_spec_path
end
end
if is_callable(opts.results_path) then
config.results_path = opts.results_path
elseif opts.results_path then
config.results_path = function()
return opts.results_path
end
end
return NeotestAdapter
end,
})
Expand Down