mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 11:06:54 -04:00
test(indent): drop plenary.path
This commit is contained in:
parent
b9f9d692f1
commit
c9fea86a5a
1 changed files with 10 additions and 12 deletions
|
|
@ -3,11 +3,10 @@ local M = {}
|
||||||
local assert = require('luassert')
|
local assert = require('luassert')
|
||||||
local say = require('say')
|
local say = require('say')
|
||||||
local scan_dir = require('plenary.scandir').scan_dir
|
local scan_dir = require('plenary.scandir').scan_dir
|
||||||
local Path = require('plenary.path')
|
|
||||||
|
|
||||||
M.XFAIL = 'xfail'
|
M.XFAIL = 'xfail'
|
||||||
|
|
||||||
local function same_indent(state, arguments)
|
local function same_indent(_, arguments)
|
||||||
local before = arguments[1]
|
local before = arguments[1]
|
||||||
local after = arguments[2]
|
local after = arguments[2]
|
||||||
|
|
||||||
|
|
@ -166,7 +165,7 @@ Runner.__index = Runner
|
||||||
function Runner:new(it, base_dir, buf_opts)
|
function Runner:new(it, base_dir, buf_opts)
|
||||||
local runner = {}
|
local runner = {}
|
||||||
runner.it = it
|
runner.it = it
|
||||||
runner.base_dir = Path:new(base_dir)
|
runner.base_dir = base_dir
|
||||||
runner.buf_opts = buf_opts
|
runner.buf_opts = buf_opts
|
||||||
return setmetatable(runner, self)
|
return setmetatable(runner, self)
|
||||||
end
|
end
|
||||||
|
|
@ -175,19 +174,18 @@ function Runner:whole_file(dirs, opts)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
local expected_failures = opts.expected_failures or {}
|
local expected_failures = opts.expected_failures or {}
|
||||||
expected_failures = vim.tbl_map(function(f)
|
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)
|
end, expected_failures)
|
||||||
dirs = type(dirs) == 'table' and dirs or { dirs }
|
dirs = type(dirs) == 'table' and dirs or { dirs }
|
||||||
dirs = vim.tbl_map(function(dir)
|
dirs = vim.tbl_map(function(dir)
|
||||||
dir = self.base_dir / Path:new(dir)
|
dir = vim.fs.normalize(vim.fs.joinpath(self.base_dir, dir))
|
||||||
assert.is.same(1, vim.fn.isdirectory(dir.filename))
|
assert.is.same(1, vim.fn.isdirectory(dir))
|
||||||
return dir.filename
|
return dir
|
||||||
end, dirs)
|
end, dirs)
|
||||||
local files = vim.iter(vim.tbl_map(scan_dir, dirs)):flatten():totable()
|
local files = vim.iter(vim.tbl_map(scan_dir, dirs)):flatten():totable()
|
||||||
for _, file in ipairs(files) do
|
for _, file in ipairs(files) do
|
||||||
local relpath = Path:new(file):make_relative(self.base_dir.filename)
|
self.it(file, function()
|
||||||
self.it(relpath, function()
|
M.indent_whole_file(file, self.buf_opts, vim.tbl_contains(expected_failures, file))
|
||||||
M.indent_whole_file(file, self.buf_opts, vim.tbl_contains(expected_failures, relpath))
|
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -195,8 +193,8 @@ end
|
||||||
function Runner:new_line(file, spec, title, xfail)
|
function Runner:new_line(file, spec, title, xfail)
|
||||||
title = title and title or tostring(spec.on_line)
|
title = title and title or tostring(spec.on_line)
|
||||||
self.it(string.format('%s[%s]', file, title), function()
|
self.it(string.format('%s[%s]', file, title), function()
|
||||||
local path = self.base_dir / file
|
local path = vim.fs.joinpath(self.base_dir, file)
|
||||||
M.indent_new_line(path.filename, spec, self.buf_opts, xfail)
|
M.indent_new_line(path, spec, self.buf_opts, xfail)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue