aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/lua_runner.lua (renamed from test/busted_runner.lua)27
1 files changed, 23 insertions, 4 deletions
diff --git a/test/busted_runner.lua b/test/lua_runner.lua
index 8176292bcf..686df9feec 100644
--- a/test/busted_runner.lua
+++ b/test/lua_runner.lua
@@ -1,11 +1,16 @@
local platform = vim.uv.os_uname()
-local deps_install_dir = os.getenv 'DEPS_INSTALL_DIR'
+local deps_install_dir = table.remove(_G.arg, 1)
+local subcommand = table.remove(_G.arg, 1)
local suffix = (platform and platform.sysname:lower():find'windows') and '.dll' or '.so'
package.path = deps_install_dir.."/share/lua/5.1/?.lua;"..deps_install_dir.."/share/lua/5.1/?/init.lua;"..package.path
package.cpath = deps_install_dir.."/lib/lua/5.1/?"..suffix..";"..package.cpath;
local uv = vim.uv
+-- we use busted and luacheck and their lua dependencies
+-- But installing their binary dependencies with luarocks is very
+-- slow, replace them with vim.uv wrappers
+
local system = {}
package.loaded['system.core'] = system
function system.monotime()
@@ -26,13 +31,17 @@ function term.isatty(_)
return uv.guess_handle(1) == 'tty'
end
-local lfs = {}
+local lfs = {_VERSION = 'fake'}
package.loaded['lfs'] = lfs
function lfs.attributes(path, attr)
+ local stat = uv.fs_stat(path)
if attr == 'mode' then
- local stat = uv.fs_stat(path)
return stat and stat.type or ''
+ elseif attr == 'modification' then
+ if not stat then return nil end
+ local mtime = stat.mtime
+ return mtime.sec + mtime.nsec*1e-9
else
error('not implemented')
end
@@ -61,4 +70,14 @@ function lfs.dir(path)
end
end
-require 'busted.runner'({ standalone = false })
+function lfs.mkdir(dir)
+ return uv.fs_mkdir(dir, 493) -- octal 755
+end
+
+if subcommand == "busted" then
+ require 'busted.runner'({ standalone = false })
+elseif subcommand == "luacheck" then
+ require 'luacheck.main'
+else
+ error 'unknown subcommand'
+end