2008-10-31 18:38:05 +00:00
|
|
|
--
|
|
|
|
-- tests/testfx.lua
|
|
|
|
-- Automated test framework for Premake.
|
2014-02-08 15:44:57 +00:00
|
|
|
-- Copyright (c) 2008-2014 Jason Perkins and the Premake project
|
2008-10-31 18:38:05 +00:00
|
|
|
--
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Define a namespace for the testing functions
|
|
|
|
--
|
|
|
|
|
2012-12-04 16:45:26 +00:00
|
|
|
test = {}
|
2014-09-17 23:19:47 +00:00
|
|
|
test.suppressed = {}
|
2009-09-15 21:08:40 +00:00
|
|
|
|
2008-10-31 18:38:05 +00:00
|
|
|
|
2013-02-01 19:54:14 +00:00
|
|
|
--
|
|
|
|
-- Capture stderr for testing.
|
|
|
|
--
|
|
|
|
|
|
|
|
local stderr_capture = nil
|
|
|
|
|
|
|
|
local mt = getmetatable(io.stderr)
|
|
|
|
local builtin_write = mt.write
|
|
|
|
mt.write = function(...)
|
|
|
|
if select(1,...) == io.stderr then
|
|
|
|
stderr_capture = (stderr_capture or "") .. select(2,...)
|
|
|
|
else
|
|
|
|
return builtin_write(...)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2008-10-31 18:38:05 +00:00
|
|
|
--
|
|
|
|
-- Assertion functions
|
|
|
|
--
|
2012-12-04 16:45:26 +00:00
|
|
|
|
2009-03-25 23:04:32 +00:00
|
|
|
function test.capture(expected)
|
2014-02-08 15:44:57 +00:00
|
|
|
local actual = premake.captured() .. premake.eol()
|
2013-02-01 19:54:14 +00:00
|
|
|
|
2011-12-04 19:47:59 +00:00
|
|
|
-- create line-by-line iterators for both values
|
2014-02-08 15:44:57 +00:00
|
|
|
local ait = actual:gfind("(.-)" .. premake.eol())
|
2009-03-25 23:04:32 +00:00
|
|
|
local eit = expected:gfind("(.-)\n")
|
2013-02-01 19:54:14 +00:00
|
|
|
|
2011-12-04 19:47:59 +00:00
|
|
|
-- compare each value line by line
|
2009-03-25 23:04:32 +00:00
|
|
|
local linenum = 1
|
|
|
|
local atxt = ait()
|
|
|
|
local etxt = eit()
|
|
|
|
while etxt do
|
|
|
|
if (etxt ~= atxt) then
|
|
|
|
test.fail("(%d) expected:\n%s\n...but was:\n%s", linenum, etxt, atxt)
|
|
|
|
end
|
2013-02-01 19:54:14 +00:00
|
|
|
|
2009-03-25 23:04:32 +00:00
|
|
|
linenum = linenum + 1
|
|
|
|
atxt = ait()
|
|
|
|
etxt = eit()
|
|
|
|
end
|
|
|
|
end
|
2009-08-12 01:16:15 +00:00
|
|
|
|
2013-02-01 19:54:14 +00:00
|
|
|
|
2009-08-12 01:16:15 +00:00
|
|
|
function test.closedfile(expected)
|
|
|
|
if expected and not test.value_closedfile then
|
|
|
|
test.fail("expected file to be closed")
|
|
|
|
elseif not expected and test.value_closedfile then
|
|
|
|
test.fail("expected file to remain open")
|
|
|
|
end
|
|
|
|
end
|
2013-02-01 19:54:14 +00:00
|
|
|
|
2009-07-14 14:28:26 +00:00
|
|
|
|
2014-07-23 17:10:41 +00:00
|
|
|
function test.contains(expected, actual)
|
|
|
|
if type(expected) == "table" then
|
|
|
|
for i, v in ipairs(expected) do
|
|
|
|
test.contains(v, actual)
|
|
|
|
end
|
|
|
|
elseif not table.contains(actual, expected) then
|
|
|
|
test.fail("expected value %s not found", expected)
|
2009-07-14 14:28:26 +00:00
|
|
|
end
|
|
|
|
end
|
2013-02-01 19:54:14 +00:00
|
|
|
|
|
|
|
|
2014-09-17 23:19:47 +00:00
|
|
|
function test.excludes(expected, actual)
|
|
|
|
if type(expected) == "table" then
|
|
|
|
for i, v in ipairs(expected) do
|
|
|
|
test.excludes(v, actual)
|
|
|
|
end
|
|
|
|
elseif table.contains(actual, expected) then
|
|
|
|
test.fail("excluded value %s found", expected)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2008-10-31 18:38:05 +00:00
|
|
|
function test.fail(format, ...)
|
2013-02-01 19:54:14 +00:00
|
|
|
|
2012-11-04 14:21:40 +00:00
|
|
|
-- if format is a number then it is the stack depth
|
|
|
|
local depth = 3
|
|
|
|
if type(format) == "number" then
|
|
|
|
depth = depth + format
|
|
|
|
format = table.remove(arg, 1)
|
|
|
|
end
|
2013-02-01 19:54:14 +00:00
|
|
|
|
2008-10-31 18:38:05 +00:00
|
|
|
-- convert nils into something more usefuls
|
|
|
|
for i = 1, arg.n do
|
2013-02-01 19:54:14 +00:00
|
|
|
if (arg[i] == nil) then
|
2008-10-31 18:38:05 +00:00
|
|
|
arg[i] = "(nil)"
|
|
|
|
elseif (type(arg[i]) == "table") then
|
|
|
|
arg[i] = "{" .. table.concat(arg[i], ", ") .. "}"
|
|
|
|
end
|
|
|
|
end
|
2013-02-01 19:54:14 +00:00
|
|
|
|
2012-10-31 23:34:04 +00:00
|
|
|
local msg = string.format(format, unpack(arg))
|
2012-11-04 14:21:40 +00:00
|
|
|
error(debug.traceback(msg, depth), depth)
|
2008-10-31 18:38:05 +00:00
|
|
|
end
|
2013-02-01 19:54:14 +00:00
|
|
|
|
|
|
|
|
2008-10-31 18:38:05 +00:00
|
|
|
function test.filecontains(expected, fn)
|
|
|
|
local f = io.open(fn)
|
|
|
|
local actual = f:read("*a")
|
|
|
|
f:close()
|
|
|
|
if (expected ~= actual) then
|
|
|
|
test.fail("expected %s but was %s", expected, actual)
|
|
|
|
end
|
|
|
|
end
|
2013-02-01 19:54:14 +00:00
|
|
|
|
2011-07-01 19:05:16 +00:00
|
|
|
|
2015-03-11 18:40:12 +00:00
|
|
|
function test.hasoutput()
|
|
|
|
local actual = premake.captured()
|
|
|
|
if actual == "" then
|
|
|
|
test.fail("expected output, received none");
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2011-07-01 19:05:16 +00:00
|
|
|
function test.isemptycapture()
|
2014-02-08 15:44:57 +00:00
|
|
|
local actual = premake.captured()
|
2011-07-01 19:05:16 +00:00
|
|
|
if actual ~= "" then
|
|
|
|
test.fail("expected empty capture, but was %s", actual);
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-02-01 19:54:14 +00:00
|
|
|
|
2012-11-04 14:21:40 +00:00
|
|
|
function test.isequal(expected, actual, depth)
|
|
|
|
depth = depth or 0
|
2012-02-17 00:51:14 +00:00
|
|
|
if type(expected) == "table" then
|
2012-10-11 14:59:15 +00:00
|
|
|
if expected and not actual then
|
2012-11-04 14:21:40 +00:00
|
|
|
test.fail(depth, "expected table, got nil")
|
2012-10-11 14:59:15 +00:00
|
|
|
end
|
2012-02-17 00:51:14 +00:00
|
|
|
if #expected < #actual then
|
2012-11-04 14:21:40 +00:00
|
|
|
test.fail(depth, "expected %d items, got %d", #expected, #actual)
|
2012-02-17 00:51:14 +00:00
|
|
|
end
|
2008-10-31 18:38:05 +00:00
|
|
|
for k,v in pairs(expected) do
|
2012-11-04 14:21:40 +00:00
|
|
|
test.isequal(expected[k], actual[k], depth + 1)
|
2008-10-31 18:38:05 +00:00
|
|
|
end
|
|
|
|
else
|
|
|
|
if (expected ~= actual) then
|
2012-11-04 14:21:40 +00:00
|
|
|
test.fail(depth, "expected %s but was %s", expected, actual)
|
2008-10-31 18:38:05 +00:00
|
|
|
end
|
|
|
|
end
|
2010-02-17 22:11:25 +00:00
|
|
|
return true
|
2008-10-31 18:38:05 +00:00
|
|
|
end
|
2013-02-01 19:54:14 +00:00
|
|
|
|
|
|
|
|
2008-10-31 18:38:05 +00:00
|
|
|
function test.isfalse(value)
|
|
|
|
if (value) then
|
|
|
|
test.fail("expected false but was true")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-02-01 19:54:14 +00:00
|
|
|
|
2008-10-31 18:38:05 +00:00
|
|
|
function test.isnil(value)
|
|
|
|
if (value ~= nil) then
|
|
|
|
test.fail("expected nil but was " .. tostring(value))
|
|
|
|
end
|
|
|
|
end
|
2013-02-01 19:54:14 +00:00
|
|
|
|
|
|
|
|
2009-08-18 19:09:17 +00:00
|
|
|
function test.isnotnil(value)
|
|
|
|
if (value == nil) then
|
|
|
|
test.fail("expected not nil")
|
|
|
|
end
|
|
|
|
end
|
2013-02-01 19:54:14 +00:00
|
|
|
|
|
|
|
|
2013-11-20 18:26:52 +00:00
|
|
|
function test.issame(expected, action)
|
|
|
|
if expected ~= action then
|
|
|
|
test.fail("expected same value")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2008-10-31 18:38:05 +00:00
|
|
|
function test.istrue(value)
|
|
|
|
if (not value) then
|
|
|
|
test.fail("expected true but was false")
|
|
|
|
end
|
2009-07-16 14:29:08 +00:00
|
|
|
end
|
|
|
|
|
2013-11-22 19:06:41 +00:00
|
|
|
function test.missing(value, actual)
|
|
|
|
if table.contains(actual, value) then
|
|
|
|
test.fail("unexpected value %s found", value)
|
|
|
|
end
|
|
|
|
end
|
2013-02-01 19:54:14 +00:00
|
|
|
|
2009-08-12 01:16:15 +00:00
|
|
|
function test.openedfile(fname)
|
|
|
|
if fname ~= test.value_openedfilename then
|
|
|
|
local msg = "expected to open file '" .. fname .. "'"
|
|
|
|
if test.value_openedfilename then
|
|
|
|
msg = msg .. ", got '" .. test.value_openedfilename .. "'"
|
|
|
|
end
|
|
|
|
test.fail(msg)
|
|
|
|
end
|
|
|
|
end
|
2013-02-01 19:54:14 +00:00
|
|
|
|
|
|
|
|
2009-07-16 14:29:08 +00:00
|
|
|
function test.success(fn, ...)
|
|
|
|
local ok, err = pcall(fn, unpack(arg))
|
|
|
|
if not ok then
|
|
|
|
test.fail("call failed: " .. err)
|
|
|
|
end
|
2008-10-31 18:38:05 +00:00
|
|
|
end
|
|
|
|
|
2009-08-12 01:16:15 +00:00
|
|
|
|
2013-02-01 19:54:14 +00:00
|
|
|
function test.stderr(expected)
|
|
|
|
if not expected and stderr_capture then
|
|
|
|
test.fail("Unexpected: " .. stderr_capture)
|
|
|
|
elseif expected then
|
|
|
|
if not stderr_capture or not stderr_capture:find(expected) then
|
|
|
|
test.fail(string.format("expected '%s'; got %s", expected, stderr_capture or "(nil)"))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function test.notstderr(expected)
|
|
|
|
if not expected and not stderr_capture then
|
|
|
|
test.fail("Expected output on stderr; none received")
|
|
|
|
elseif expected then
|
|
|
|
if stderr_capture and stderr_capture:find(expected) then
|
|
|
|
test.fail(string.format("stderr contains '%s'; was %s", expected, stderr_capture))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2009-08-12 01:16:15 +00:00
|
|
|
|
2014-07-07 21:03:14 +00:00
|
|
|
--
|
|
|
|
-- Some helper functions
|
|
|
|
--
|
|
|
|
|
2014-07-21 22:49:56 +00:00
|
|
|
function test.createsolution()
|
2014-07-07 21:03:14 +00:00
|
|
|
local sln = solution "MySolution"
|
|
|
|
configurations { "Debug", "Release" }
|
|
|
|
|
|
|
|
local prj = project "MyProject"
|
|
|
|
language "C++"
|
|
|
|
kind "ConsoleApp"
|
|
|
|
|
|
|
|
return sln, prj
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-07-21 22:49:56 +00:00
|
|
|
function test.createproject(sln)
|
2014-07-07 21:03:14 +00:00
|
|
|
local n = #sln.projects + 1
|
|
|
|
if n == 1 then n = "" end
|
|
|
|
|
|
|
|
local prj = project ("MyProject" .. n)
|
|
|
|
language "C++"
|
|
|
|
kind "ConsoleApp"
|
|
|
|
return prj
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-07-21 22:49:56 +00:00
|
|
|
function test.getproject(sln, i)
|
2014-10-16 20:17:59 +00:00
|
|
|
premake.oven.bake()
|
|
|
|
sln = premake.global.getSolution(sln.name)
|
2014-07-07 21:03:14 +00:00
|
|
|
return premake.solution.getproject(sln, i or 1)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-07-21 22:49:56 +00:00
|
|
|
function test.getconfig(prj, buildcfg, platform)
|
2014-10-16 20:17:59 +00:00
|
|
|
premake.oven.bake()
|
|
|
|
local sln = premake.global.getSolution(prj.solution.name)
|
2014-07-07 21:03:14 +00:00
|
|
|
prj = premake.solution.getproject(sln, prj.name)
|
|
|
|
return premake.project.getconfig(prj, buildcfg, platform)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2009-08-12 01:16:15 +00:00
|
|
|
--
|
|
|
|
-- Test stubs
|
|
|
|
--
|
|
|
|
|
|
|
|
local function stub_io_open(fname, mode)
|
|
|
|
test.value_openedfilename = fname
|
|
|
|
test.value_openedfilemode = mode
|
|
|
|
return {
|
|
|
|
close = function()
|
|
|
|
test.value_closedfile = true
|
|
|
|
end
|
|
|
|
}
|
|
|
|
end
|
2013-02-01 19:54:14 +00:00
|
|
|
|
2009-08-12 01:16:15 +00:00
|
|
|
local function stub_io_output(f)
|
|
|
|
end
|
2013-02-01 19:54:14 +00:00
|
|
|
|
2009-08-12 15:22:44 +00:00
|
|
|
local function stub_print(s)
|
|
|
|
end
|
2013-02-01 19:54:14 +00:00
|
|
|
|
|
|
|
|
2008-10-31 18:38:05 +00:00
|
|
|
--
|
|
|
|
-- Define a collection for the test suites
|
|
|
|
--
|
|
|
|
|
2012-12-04 16:45:26 +00:00
|
|
|
T = {}
|
2008-10-31 18:38:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Test execution function
|
|
|
|
--
|
2011-08-21 23:52:49 +00:00
|
|
|
local _OS_host = _OS
|
2014-02-25 18:17:04 +00:00
|
|
|
local _OPTIONS_host = _OPTIONS
|
2012-04-04 20:21:22 +00:00
|
|
|
|
2012-10-24 15:31:30 +00:00
|
|
|
local function error_handler(err)
|
2012-10-31 23:34:04 +00:00
|
|
|
local msg = err
|
2013-02-01 19:54:14 +00:00
|
|
|
|
2012-10-31 23:34:04 +00:00
|
|
|
-- if the error doesn't include a stack trace, add one
|
|
|
|
if not msg:find("stack traceback:", 1, true) then
|
|
|
|
msg = debug.traceback(err, 2)
|
|
|
|
end
|
2013-02-01 19:54:14 +00:00
|
|
|
|
2012-10-31 23:34:04 +00:00
|
|
|
-- trim of the trailing context of the originating xpcall
|
|
|
|
local i = msg:find("[C]: in function 'xpcall'", 1, true)
|
|
|
|
if i then
|
|
|
|
msg = msg:sub(1, i - 3)
|
|
|
|
end
|
2013-02-01 19:54:14 +00:00
|
|
|
|
2012-10-31 23:34:04 +00:00
|
|
|
-- if the resulting stack trace is only one level deep, ignore it
|
|
|
|
local n = select(2, msg:gsub('\n', '\n'))
|
|
|
|
if n == 2 then
|
|
|
|
msg = msg:sub(1, msg:find('\n', 1, true) - 1)
|
|
|
|
end
|
2013-02-01 19:54:14 +00:00
|
|
|
|
2012-10-24 15:31:30 +00:00
|
|
|
return msg
|
|
|
|
end
|
2013-02-01 19:54:14 +00:00
|
|
|
|
|
|
|
|
2009-08-12 01:16:15 +00:00
|
|
|
local function test_setup(suite, fn)
|
|
|
|
_ACTION = "test"
|
2011-08-21 23:52:49 +00:00
|
|
|
_OS = _OS_host
|
2012-04-04 20:21:22 +00:00
|
|
|
|
2014-02-25 18:17:04 +00:00
|
|
|
_OPTIONS = {}
|
|
|
|
setmetatable(_OPTIONS, getmetatable(_OPTIONS_host))
|
|
|
|
|
2013-02-01 19:54:14 +00:00
|
|
|
stderr_capture = nil
|
|
|
|
|
2013-08-29 16:20:53 +00:00
|
|
|
premake.clearWarnings()
|
2014-02-08 15:44:57 +00:00
|
|
|
premake.eol("\n")
|
|
|
|
premake.escaper(nil)
|
|
|
|
premake.indent("\t")
|
2014-06-11 17:52:08 +00:00
|
|
|
premake.api.reset()
|
2009-08-12 01:16:15 +00:00
|
|
|
|
2009-09-15 21:08:40 +00:00
|
|
|
-- reset captured I/O values
|
2009-08-12 01:16:15 +00:00
|
|
|
test.value_openedfilename = nil
|
|
|
|
test.value_openedfilemode = nil
|
2011-05-12 20:00:07 +00:00
|
|
|
test.value_closedfile = false
|
2009-08-12 01:16:15 +00:00
|
|
|
|
|
|
|
if suite.setup then
|
2012-10-24 15:31:30 +00:00
|
|
|
return xpcall(suite.setup, error_handler)
|
2009-08-12 01:16:15 +00:00
|
|
|
else
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
2013-02-01 19:54:14 +00:00
|
|
|
|
2009-08-12 01:16:15 +00:00
|
|
|
|
|
|
|
local function test_run(suite, fn)
|
2013-03-12 22:18:47 +00:00
|
|
|
local result, err
|
2014-02-08 15:44:57 +00:00
|
|
|
premake.capture(function()
|
2013-03-12 22:18:47 +00:00
|
|
|
result, err = xpcall(fn, error_handler)
|
|
|
|
end)
|
|
|
|
return result, err
|
2009-08-12 01:16:15 +00:00
|
|
|
end
|
2013-02-01 19:54:14 +00:00
|
|
|
|
2009-08-12 01:16:15 +00:00
|
|
|
|
|
|
|
local function test_teardown(suite, fn)
|
|
|
|
if suite.teardown then
|
2012-10-24 15:31:30 +00:00
|
|
|
return xpcall(suite.teardown, error_handler)
|
2009-08-12 01:16:15 +00:00
|
|
|
else
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-09-17 23:19:47 +00:00
|
|
|
|
2012-12-29 18:26:41 +00:00
|
|
|
function test.declare(id)
|
|
|
|
if T[id] then
|
|
|
|
error("Duplicate test suite " .. id)
|
|
|
|
end
|
2014-09-17 23:19:47 +00:00
|
|
|
T[id] = {
|
|
|
|
_TESTS_DIR = _TESTS_DIR,
|
|
|
|
_SCRIPT_DIR = _SCRIPT_DIR,
|
|
|
|
}
|
2012-12-29 18:26:41 +00:00
|
|
|
return T[id]
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-09-17 23:19:47 +00:00
|
|
|
|
|
|
|
function test.suppress(id)
|
|
|
|
if type(id) == "table" then
|
|
|
|
for i = 1, #id do
|
|
|
|
test.suppress(id[i])
|
|
|
|
end
|
|
|
|
else
|
|
|
|
test.suppressed[id] = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-04-18 19:14:31 +00:00
|
|
|
function test.runall(suitename, testname)
|
2009-09-15 21:08:40 +00:00
|
|
|
test.print = print
|
|
|
|
|
2014-03-09 15:47:42 +00:00
|
|
|
local real_print = print
|
|
|
|
local real_open = io.open
|
|
|
|
local real_output = io.output
|
|
|
|
|
|
|
|
print = stub_print
|
|
|
|
io.open = stub_io_open
|
|
|
|
io.output = stub_io_output
|
2013-02-01 19:54:14 +00:00
|
|
|
|
2008-10-31 18:38:05 +00:00
|
|
|
local numpassed = 0
|
|
|
|
local numfailed = 0
|
2014-09-17 23:19:47 +00:00
|
|
|
|
2013-02-01 19:54:14 +00:00
|
|
|
|
2012-04-18 19:14:31 +00:00
|
|
|
function runtest(suitename, suitetests, testname, testfunc)
|
2014-09-17 23:19:47 +00:00
|
|
|
if suitetests.setup ~= testfunc and
|
|
|
|
suitetests.teardown ~= testfunc and
|
|
|
|
not test.suppressed[suitename .. "." .. testname]
|
|
|
|
then
|
2012-04-18 19:14:31 +00:00
|
|
|
local ok, err = test_setup(suitetests, testfunc)
|
2009-08-12 01:16:15 +00:00
|
|
|
|
2012-04-18 19:14:31 +00:00
|
|
|
if ok then
|
|
|
|
ok, err = test_run(suitetests, testfunc)
|
|
|
|
end
|
2009-08-12 01:16:15 +00:00
|
|
|
|
2012-04-18 19:14:31 +00:00
|
|
|
local tok, terr = test_teardown(suitetests, testfunc)
|
|
|
|
ok = ok and tok
|
2012-10-31 23:34:04 +00:00
|
|
|
err = err or terr
|
2013-02-01 19:54:14 +00:00
|
|
|
|
2012-04-18 19:14:31 +00:00
|
|
|
if (not ok) then
|
|
|
|
test.print(string.format("%s.%s: %s", suitename, testname, err))
|
|
|
|
numfailed = numfailed + 1
|
|
|
|
else
|
|
|
|
numpassed = numpassed + 1
|
|
|
|
end
|
2013-02-01 19:54:14 +00:00
|
|
|
end
|
2012-04-18 19:14:31 +00:00
|
|
|
end
|
2013-02-01 19:54:14 +00:00
|
|
|
|
2014-09-17 23:19:47 +00:00
|
|
|
|
2012-04-18 19:14:31 +00:00
|
|
|
function runsuite(suitename, suitetests, testname)
|
2014-09-17 23:19:47 +00:00
|
|
|
if suitetests and not test.suppressed[suitename] then
|
|
|
|
_TESTS_DIR = suitetests._TESTS_DIR
|
|
|
|
_SCRIPT_DIR = suitetests._SCRIPT_DIR
|
|
|
|
|
2014-07-29 19:50:55 +00:00
|
|
|
if testname then
|
|
|
|
runtest(suitename, suitetests, testname, suitetests[testname])
|
|
|
|
else
|
|
|
|
for testname, testfunc in pairs(suitetests) do
|
2014-09-17 23:19:47 +00:00
|
|
|
if type(testfunc) == "function" then
|
|
|
|
runtest(suitename, suitetests, testname, testfunc)
|
|
|
|
end
|
2014-07-29 19:50:55 +00:00
|
|
|
end
|
2008-10-31 18:38:05 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2013-02-01 19:54:14 +00:00
|
|
|
|
2014-09-17 23:19:47 +00:00
|
|
|
|
2012-04-18 19:14:31 +00:00
|
|
|
if suitename then
|
|
|
|
runsuite(suitename, T[suitename], testname)
|
|
|
|
else
|
|
|
|
for suitename, suitetests in pairs(T) do
|
|
|
|
runsuite(suitename, suitetests, testname)
|
|
|
|
end
|
2013-02-01 19:54:14 +00:00
|
|
|
end
|
|
|
|
|
2014-03-09 15:47:42 +00:00
|
|
|
print = real_print
|
|
|
|
io.open = real_open
|
|
|
|
io.output = real_output
|
|
|
|
|
2013-02-01 19:54:14 +00:00
|
|
|
return numpassed, numfailed
|
2008-10-31 18:38:05 +00:00
|
|
|
end
|
2013-02-01 19:54:14 +00:00
|
|
|
|