Skip to content

Commit 3117ca5

Browse files
authored
feat: Specify full path for umbrella projects (#30)
1 parent 412e553 commit 3117ca5

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

lua/neotest-elixir/core.lua

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,21 @@ local Path = require("plenary.path")
33

44
local M = {}
55

6+
function M.mix_root(file_path)
7+
local root = lib.files.match_root_pattern("mix.exs")(file_path)
8+
9+
-- If the path found is inside an umbrella, return the root of the umbrella
10+
if root ~= nil and root:match("/apps/[%w_]+$") then
11+
local new_root = lib.files.match_root_pattern("mix.exs")(root:gsub("/apps/[%w_]+$", ""))
12+
13+
return new_root or root
14+
end
15+
16+
return root
17+
end
18+
619
local function relative_to_cwd(path)
7-
local root = lib.files.match_root_pattern("mix.exs")(path)
20+
local root = M.mix_root(path)
821
return Path:new(path):make_relative(root)
922
end
1023

lua/neotest-elixir/init.lua

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,8 @@ local function post_process_command(cmd)
4040
return cmd
4141
end
4242

43-
local function mix_root(file_path)
44-
return lib.files.match_root_pattern("mix.exs")(file_path)
45-
end
46-
4743
local function get_relative_path(file_path)
48-
local mix_root_path = mix_root(file_path)
44+
local mix_root_path = core.mix_root(file_path)
4945
local root_elems = vim.split(mix_root_path, Path.path.sep)
5046
local elems = vim.split(file_path, Path.path.sep)
5147
return table.concat({ unpack(elems, (#root_elems + 1), #elems) }, Path.path.sep)
@@ -70,7 +66,7 @@ function ElixirNeotestAdapter._generate_id(position, parents)
7066
end
7167
end
7268

73-
ElixirNeotestAdapter.root = lib.files.match_root_pattern("mix.exs")
69+
ElixirNeotestAdapter.root = core.mix_root
7470

7571
function ElixirNeotestAdapter.filter_dir(_, rel_path, _)
7672
return rel_path == "test"

0 commit comments

Comments
 (0)