2008-10-31 18:38:05 +00:00
|
|
|
--
|
|
|
|
-- tests/testfx.lua
|
|
|
|
-- Automated test framework for Premake.
|
2015-07-28 23:08:28 +00:00
|
|
|
-- Copyright (c) 2008-2015 Jason Perkins and the Premake project
|
2008-10-31 18:38:05 +00:00
|
|
|
--
|
|
|
|
|
2015-07-28 23:08:28 +00:00
|
|
|
local p = premake
|
|
|
|
|
2016-05-16 20:27:14 +00:00
|
|
|
local test = p.modules.self_test
|
|
|
|
|
2008-10-31 18:38:05 +00:00
|
|
|
|
|
|
|
--
|
|
|
|
-- Define a namespace for the testing functions
|
|
|
|
--
|
|
|
|
|
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
|
2015-09-02 21:01:10 +00:00
|
|
|
local ait = actual:gmatch("(.-)" .. premake.eol())
|
|
|
|
local eit = expected:gmatch("(.-)\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
|
2015-03-24 23:15:39 +00:00
|
|
|
local arg = {...}
|
2012-11-04 14:21:40 +00:00
|
|
|
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
|
2015-03-24 23:15:39 +00:00
|
|
|
for i = 1, #arg 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, ...)
|
2015-03-24 23:15:39 +00:00
|
|
|
local ok, err = pcall(fn, ...)
|
2009-07-16 14:29:08 +00:00
|
|
|
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
|
|
|
|
--
|
|
|
|
|
2015-07-28 23:08:28 +00:00
|
|
|
function test.createWorkspace()
|
2015-09-03 22:03:09 +00:00
|
|
|
local wks = workspace("MyWorkspace")
|
2014-07-07 21:03:14 +00:00
|
|
|
configurations { "Debug", "Release" }
|
2015-09-04 19:40:12 +00:00
|
|
|
local prj = test.createproject(wks)
|
2015-07-30 19:30:41 +00:00
|
|
|
return wks, prj
|
2014-07-07 21:03:14 +00:00
|
|
|
end
|
|
|
|
|
2015-09-04 19:40:12 +00:00
|
|
|
-- Eventually we'll want to deprecate this one and move everyone
|
|
|
|
-- over to createWorkspace() instead (4 Sep 2015).
|
|
|
|
function test.createsolution()
|
|
|
|
local wks = workspace("MySolution")
|
|
|
|
configurations { "Debug", "Release" }
|
|
|
|
local prj = test.createproject(wks)
|
|
|
|
return wks, prj
|
|
|
|
end
|
2015-07-28 23:08:28 +00:00
|
|
|
|
2014-07-07 21:03:14 +00:00
|
|
|
|
2015-08-28 20:16:14 +00:00
|
|
|
function test.createproject(wks)
|
|
|
|
local n = #wks.projects + 1
|
2014-07-07 21:03:14 +00:00
|
|
|
if n == 1 then n = "" end
|
|
|
|
|
|
|
|
local prj = project ("MyProject" .. n)
|
|
|
|
language "C++"
|
|
|
|
kind "ConsoleApp"
|
|
|
|
return prj
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2015-08-28 20:16:14 +00:00
|
|
|
function test.getWorkspace(wks)
|
2015-08-10 17:05:26 +00:00
|
|
|
p.oven.bake()
|
2015-08-28 20:16:14 +00:00
|
|
|
return p.global.getWorkspace(wks.name)
|
2015-03-13 20:48:06 +00:00
|
|
|
end
|
|
|
|
|
2015-08-28 20:16:14 +00:00
|
|
|
p.alias(test, "getWorkspace", "getsolution")
|
2015-03-13 20:48:06 +00:00
|
|
|
|
2015-08-28 20:16:14 +00:00
|
|
|
|
|
|
|
function test.getproject(wks, i)
|
|
|
|
wks = test.getWorkspace(wks)
|
|
|
|
return p.workspace.getproject(wks, i or 1)
|
2014-07-07 21:03:14 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-07-21 22:49:56 +00:00
|
|
|
function test.getconfig(prj, buildcfg, platform)
|
2015-08-28 20:16:14 +00:00
|
|
|
local wks = test.getWorkspace(prj.workspace)
|
|
|
|
prj = p.workspace.getproject(wks, prj.name)
|
|
|
|
return p.project.getconfig(prj, buildcfg, platform)
|
2014-07-07 21:03:14 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-05-18 19:56:04 +00:00
|
|
|
function test.runTests(suitename, testname)
|
2009-09-15 21:08:40 +00:00
|
|
|
test.print = print
|
|
|
|
|
2016-05-18 19:56:04 +00:00
|
|
|
local hooks = test.installTestingHooks()
|
2014-03-09 15:47:42 +00:00
|
|
|
|
2016-05-18 19:56:04 +00:00
|
|
|
local startTime = os.clock()
|
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
|
|
|
|
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
|
|
|
|
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
|
|
|
|
|
2016-05-18 19:56:04 +00:00
|
|
|
local result = {
|
|
|
|
passed = numpassed,
|
|
|
|
failed = numfailed,
|
|
|
|
start = startTime,
|
|
|
|
elapsed = os.clock() - startTime
|
|
|
|
}
|
|
|
|
|
|
|
|
test.removeTestingHooks(hooks)
|
2014-03-09 15:47:42 +00:00
|
|
|
|
2016-05-18 19:56:04 +00:00
|
|
|
return result
|
2008-10-31 18:38:05 +00:00
|
|
|
end
|
2013-02-01 19:54:14 +00:00
|
|
|
|