mirror of
https://github.com/pnx/neotest-phpunit
synced 2026-06-18 04:10:01 +02:00
Use filter_dir for finding tests
This commit is contained in:
parent
759565f9ac
commit
ae0a335ef8
1 changed files with 10 additions and 3 deletions
|
|
@ -15,13 +15,20 @@ local NeotestAdapter = { name = "neotest-pest" }
|
||||||
---@return string | nil @Absolute root dir of test suite
|
---@return string | nil @Absolute root dir of test suite
|
||||||
NeotestAdapter.root = lib.files.match_root_pattern("composer.json", "pest.xml")
|
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
|
---@async
|
||||||
---@param file_path string
|
---@param file_path string
|
||||||
---@return boolean
|
---@return boolean
|
||||||
function NeotestAdapter.is_test_file(file_path)
|
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")
|
return vim.endswith(file_path, "Test.php")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue