From ae0a335ef807628191e6eaa38527446f5b734397 Mon Sep 17 00:00:00 2001 From: Michael Utz Date: Thu, 17 Nov 2022 11:18:36 +0300 Subject: [PATCH] Use `filter_dir` for finding tests --- lua/neotest-pest/init.lua | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lua/neotest-pest/init.lua b/lua/neotest-pest/init.lua index d0bf8a1..5c4a2fa 100644 --- a/lua/neotest-pest/init.lua +++ b/lua/neotest-pest/init.lua @@ -15,13 +15,20 @@ local NeotestAdapter = { name = "neotest-pest" } ---@return string | nil @Absolute root dir of test suite NeotestAdapter.root = lib.files.match_root_pattern("composer.json", "pest.xml") +---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 +---@return boolean True when matching +function NeotestAdapter.filter_dir(name, rel_path, root) + return name ~= "tests" or string.match(rel_path, "tests") +end + ---@async ---@param file_path string ---@return boolean function NeotestAdapter.is_test_file(file_path) - if string.match(file_path, "vendor/") or not string.match(file_path, "tests/") then - return false - end return vim.endswith(file_path, "Test.php") end