aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua/fs_spec.lua
diff options
context:
space:
mode:
authorMike <Mike325@users.noreply.github.com>2023-03-01 10:51:22 -0600
committerGitHub <noreply@github.com>2023-03-01 08:51:22 -0800
commitbc15b075d14c85098d674a2466d2386e08b0005f (patch)
tree22eb1817988f98c7c55d5fc39e09d2287215c847 /test/functional/lua/fs_spec.lua
parent014981c9006f9b96b8045e609dc27f4a84da5263 (diff)
downloadrneovim-bc15b075d14c85098d674a2466d2386e08b0005f.tar.gz
rneovim-bc15b075d14c85098d674a2466d2386e08b0005f.tar.bz2
rneovim-bc15b075d14c85098d674a2466d2386e08b0005f.zip
feat(vim.fs): pass path to find() predicate, lazy evaluate #22378
Problem: No easy way to find files under certain directories (ex: grab all files under `test/`) or exclude the content of certain paths (ex. `build/`, `.git/`) Solution: Pass the full `path` as an arg to the predicate.
Diffstat (limited to 'test/functional/lua/fs_spec.lua')
-rw-r--r--test/functional/lua/fs_spec.lua11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/functional/lua/fs_spec.lua b/test/functional/lua/fs_spec.lua
index 642d36f63a..03de16c079 100644
--- a/test/functional/lua/fs_spec.lua
+++ b/test/functional/lua/fs_spec.lua
@@ -8,6 +8,7 @@ local mkdir_p = helpers.mkdir_p
local rmdir = helpers.rmdir
local nvim_dir = helpers.nvim_dir
local test_build_dir = helpers.test_build_dir
+local test_source_path = helpers.test_source_path
local nvim_prog = helpers.nvim_prog
local is_os = helpers.is_os
@@ -252,6 +253,16 @@ describe('vim.fs', function()
local opts = { path = dir, upward = true, type = 'directory' }
return vim.fs.find(function(x) return x == 'no-match' end, opts)
]], nvim_dir))
+ eq(
+ exec_lua([[
+ local dir = ...
+ return vim.tbl_map(vim.fs.basename, vim.fn.glob(dir..'/contrib/*', false, true))
+ ]], test_source_path),
+ exec_lua([[
+ local dir = ...
+ local opts = { path = dir, limit = math.huge }
+ return vim.tbl_map(vim.fs.basename, vim.fs.find(function(_, d) return d:match('[\\/]contrib$') end, opts))
+ ]], test_source_path))
end)
end)