api: enable nvim_get_runtime_file to find subdirectories

This commit is contained in:
Björn Linse
2020-11-24 14:18:46 +01:00
parent 7dfeadb0fc
commit d285fa73da
2 changed files with 34 additions and 15 deletions

View File

@@ -1885,25 +1885,40 @@ describe('API', function()
end)
describe('nvim_get_runtime_file', function()
it('works', function()
local p = helpers.alter_slashes
it('can find files', function()
eq({}, meths.get_runtime_file("bork.borkbork", false))
eq({}, meths.get_runtime_file("bork.borkbork", true))
eq(1, #meths.get_runtime_file("autoload/msgpack.vim", false))
eq(1, #meths.get_runtime_file("autoload/msgpack.vim", true))
local val = meths.get_runtime_file("autoload/remote/*.vim", true)
eq(2, #val)
local p = helpers.alter_slashes
if endswith(val[1], "define.vim") then
ok(endswith(val[1], p("autoload/remote/define.vim")))
ok(endswith(val[2], p("autoload/remote/host.vim")))
ok(endswith(val[1], p"autoload/remote/define.vim"))
ok(endswith(val[2], p"autoload/remote/host.vim"))
else
ok(endswith(val[1], p("autoload/remote/host.vim")))
ok(endswith(val[2], p("autoload/remote/define.vim")))
ok(endswith(val[1], p"autoload/remote/host.vim"))
ok(endswith(val[2], p"autoload/remote/define.vim"))
end
val = meths.get_runtime_file("autoload/remote/*.vim", false)
eq(1, #val)
ok(endswith(val[1], p("autoload/remote/define.vim"))
or endswith(val[1], p("autoload/remote/host.vim")))
ok(endswith(val[1], p"autoload/remote/define.vim")
or endswith(val[1], p"autoload/remote/host.vim"))
eq({}, meths.get_runtime_file("lua", true))
eq({}, meths.get_runtime_file("lua/vim", true))
end)
it('can find directories', function()
local val = meths.get_runtime_file("lua/", true)
eq(1, #val)
ok(endswith(val[1], p"lua/"))
val = meths.get_runtime_file("lua/vim/", true)
eq(1, #val)
ok(endswith(val[1], p"lua/vim/"))
eq({}, meths.get_runtime_file("foobarlang/", true))
end)
end)
end)