diff --git a/lua/neotest/adapters/interface.lua b/lua/neotest/adapters/interface.lua index 108ecc22..3a59f5ae 100644 --- a/lua/neotest/adapters/interface.lua +++ b/lua/neotest/adapters/interface.lua @@ -9,6 +9,13 @@ local NeotestAdapter = {} ---@return string | nil @Absolute root dir of test suite function NeotestAdapter.root(dir) end +---Filter directories when searching for test files +---@async +---@param name string Name of directory +---@param rel_path string Path to directory, relative to root +---@param root string Root directory of project +function NeotestAdapter.filter_dir(name, rel_path, root) end + ---@async ---@param file_path string ---@return boolean diff --git a/lua/neotest/client/init.lua b/lua/neotest/client/init.lua index 42340e99..4eb7d238 100644 --- a/lua/neotest/client/init.lua +++ b/lua/neotest/client/init.lua @@ -244,7 +244,16 @@ function NeotestClient:_update_positions(path, args) local root_path = existing_root and existing_root:data().path or path local files = lib.func_util.filter_list( adapter.is_test_file, - lib.files.find(path, { filter_dir = config.projects[root_path].discovery.filter_dir }) + + lib.files.find(path, { + filter_dir = function(...) + return (not adapter.filter_dir or adapter.filter_dir(...)) + and ( + not config.projects[root_path].discovery.filter_dir + or config.projects[root_path].discovery.filter_dir(...) + ) + end, + }) ) local positions = lib.files.parse_dir_from_files(path, files) logger.debug("Found", positions) diff --git a/lua/neotest/lib/file/find.lua b/lua/neotest/lib/file/find.lua index 9af5291c..94913ddf 100644 --- a/lua/neotest/lib/file/find.lua +++ b/lua/neotest/lib/file/find.lua @@ -3,7 +3,6 @@ local M = {} local ignored = vim.tbl_add_reverse_lookup({ "node_modules", - "venv", }) --- Find all files under the given directory.