1
0
Fork 0
mirror of https://github.com/pnx/neotest-phpunit synced 2026-06-16 03:54:55 +02:00

Use filter_dir for finding tests

This commit is contained in:
Michael Utz 2022-11-17 11:18:36 +03:00
parent 759565f9ac
commit ae0a335ef8

View file

@ -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