diff options
Diffstat (limited to 'tests/indent/common.lua')
| -rw-r--r-- | tests/indent/common.lua | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/tests/indent/common.lua b/tests/indent/common.lua index 6add58c7f..ccc126870 100644 --- a/tests/indent/common.lua +++ b/tests/indent/common.lua @@ -2,12 +2,10 @@ local M = {} local assert = require('luassert') local say = require('say') -local scan_dir = require('plenary.scandir').scan_dir -local Path = require('plenary.path') M.XFAIL = 'xfail' -local function same_indent(state, arguments) +local function same_indent(_, arguments) local before = arguments[1] local after = arguments[2] @@ -166,7 +164,7 @@ Runner.__index = Runner function Runner:new(it, base_dir, buf_opts) local runner = {} runner.it = it - runner.base_dir = Path:new(base_dir) + runner.base_dir = base_dir runner.buf_opts = buf_opts return setmetatable(runner, self) end @@ -175,19 +173,23 @@ function Runner:whole_file(dirs, opts) opts = opts or {} local expected_failures = opts.expected_failures or {} expected_failures = vim.tbl_map(function(f) - return Path:new(f):make_relative(self.base_dir.filename) + return vim.fs.normalize(vim.fs.joinpath(self.base_dir, f)) end, expected_failures) dirs = type(dirs) == 'table' and dirs or { dirs } dirs = vim.tbl_map(function(dir) - dir = self.base_dir / Path:new(dir) - assert.is.same(1, vim.fn.isdirectory(dir.filename)) - return dir.filename + dir = vim.fs.normalize(vim.fs.joinpath(self.base_dir, dir)) + assert.is.same(1, vim.fn.isdirectory(dir)) + return dir end, dirs) - local files = vim.iter(vim.tbl_map(scan_dir, dirs)):flatten():totable() - for _, file in ipairs(files) do - local relpath = Path:new(file):make_relative(self.base_dir.filename) - self.it(relpath, function() - M.indent_whole_file(file, self.buf_opts, vim.tbl_contains(expected_failures, relpath)) + local scandir = function(dir) + return vim.fs.find(function() + return true + end, { path = dir, limit = math.huge }) + end + local files = vim.iter(dirs):map(scandir):flatten() + for _, file in files:enumerate() do + self.it(file, function() + M.indent_whole_file(file, self.buf_opts, vim.tbl_contains(expected_failures, file)) end) end end @@ -195,8 +197,8 @@ end function Runner:new_line(file, spec, title, xfail) title = title and title or tostring(spec.on_line) self.it(string.format('%s[%s]', file, title), function() - local path = self.base_dir / file - M.indent_new_line(path.filename, spec, self.buf_opts, xfail) + local path = vim.fs.joinpath(self.base_dir, file) + M.indent_new_line(path, spec, self.buf_opts, xfail) end) end |
