aboutsummaryrefslogtreecommitdiff
path: root/test/helpers.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/helpers.lua')
-rw-r--r--test/helpers.lua42
1 files changed, 34 insertions, 8 deletions
diff --git a/test/helpers.lua b/test/helpers.lua
index b01e966464..94dcf86c4d 100644
--- a/test/helpers.lua
+++ b/test/helpers.lua
@@ -3,7 +3,6 @@ local shared = vim
local assert = require('luassert')
local busted = require('busted')
local luv = require('luv')
-local lfs = require('lfs')
local relpath = require('pl.path').relpath
local Paths = require('test.cmakeconfig.paths')
@@ -22,6 +21,28 @@ local module = {
REMOVE_THIS = {},
}
+function module.isdir(path)
+ if not path then
+ return false
+ end
+ local stat = luv.fs_stat(path)
+ if not stat then
+ return false
+ end
+ return stat.type == 'directory'
+end
+
+function module.isfile(path)
+ if not path then
+ return false
+ end
+ local stat = luv.fs_stat(path)
+ if not stat then
+ return false
+ end
+ return stat.type == 'file'
+end
+
function module.argss_to_cmd(...)
local cmd = ''
for i = 1, select('#', ...) do
@@ -228,16 +249,16 @@ function module.glob(initial_path, re, exc_re)
while #paths_to_check > 0 do
local cur_path = paths_to_check[#paths_to_check]
paths_to_check[#paths_to_check] = nil
- for e in lfs.dir(cur_path) do
+ for e in vim.fs.dir(cur_path) do
local full_path = cur_path .. '/' .. e
local checked_path = full_path:sub(#initial_path + 1)
if (not is_excluded(checked_path)) and e:sub(1, 1) ~= '.' then
- local attrs = lfs.attributes(full_path)
- if attrs then
- local check_key = attrs.dev .. ':' .. tostring(attrs.ino)
+ local stat = luv.fs_stat(full_path)
+ if stat then
+ local check_key = stat.dev .. ':' .. tostring(stat.ino)
if not checked_files[check_key] then
checked_files[check_key] = true
- if attrs.mode == 'directory' then
+ if stat.type == 'directory' then
paths_to_check[#paths_to_check + 1] = full_path
elseif not re or checked_path:match(re) then
ret[#ret + 1] = full_path
@@ -253,8 +274,8 @@ end
function module.check_logs()
local log_dir = os.getenv('LOG_DIR')
local runtime_errors = {}
- if log_dir and lfs.attributes(log_dir, 'mode') == 'directory' then
- for tail in lfs.dir(log_dir) do
+ if log_dir and module.isdir(log_dir) then
+ for tail in vim.fs.dir(log_dir) do
if tail:sub(1, 30) == 'valgrind-' or tail:find('san%.') then
local file = log_dir .. '/' .. tail
local fd = io.open(file)
@@ -843,6 +864,11 @@ function module.read_nvim_log(logfile, ci_rename)
return log
end
+function module.mkdir(path)
+ -- 493 is 0755 in decimal
+ return luv.fs_mkdir(path, 493)
+end
+
module = shared.tbl_extend('error', module, Paths, shared, require('test.deprecated'))
return module