File size: 1,169 Bytes
7e9dc27 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
local command = {}
local fs = require("luarocks.fs")
local dir = require("luarocks.dir")
local cfg = require("luarocks.core.cfg")
local unpack = table.unpack or unpack
function command.detect_type()
if fs.exists("test.lua") then
return true
end
return false
end
function command.run_tests(test, args)
if not test then
test = {
script = "test.lua"
}
end
if not test.script and not test.command then
test.script = "test.lua"
end
if type(test.flags) == "table" then
-- insert any flags given in test.flags at the front of args
for i = 1, #test.flags do
table.insert(args, i, test.flags[i])
end
end
if test.script then
if not fs.exists(test.script) then
return nil, "Test script " .. test.script .. " does not exist"
end
local lua = fs.Q(dir.path(cfg.variables["LUA_BINDIR"], cfg.lua_interpreter)) -- get lua interpreter configured
return fs.execute(lua, test.script, unpack(args))
elseif test.command then
return fs.execute(test.command, unpack(args))
end
end
return command
|