This repository has been archived on 2022-12-23. You can view files and clone it, but cannot push or open issues or pull requests.
fuck-premake-old2/scripts/test.lua
Jason Perkins 90ae7aaa70 Rework embedded scripts to be loaded on-demand and by name
This will be required in order to migrate modules into the executable for binary releases
2014-09-26 09:25:14 -04:00

54 lines
1.1 KiB
Lua

---
-- Premake automated test runner.
---
include "../tests/testfx.lua"
local focus = {}
if _OPTIONS["test"] then
focus = string.explode(_OPTIONS["test"] or "", ".", true)
end
--
-- Find and load all of the test file manifests
--
local mask = path.join(_MAIN_SCRIPT_DIR, "**/tests/_tests.lua")
local manifests = os.matchfiles(mask)
-- Hmm, "**" should probably also match against "."?
local top = path.join(_MAIN_SCRIPT_DIR, "tests/_tests.lua")
if os.isfile(top) then
table.insert(manifests, 1, top)
end
for i = 1, #manifests do
local manifest = manifests[i]
_TESTS_DIR = path.getdirectory(manifest)
local files = dofile(manifest)
for f = 1, #files do
dofile(path.join(_TESTS_DIR, files[f]))
end
end
--
-- Run them and show the results
--
local startTime = os.clock()
passed, failed = test.runall(focus[1], focus[2])
io.write('running time : ', os.clock() - startTime,'\n')
msg = string.format("%d tests passed, %d failed", passed, failed)
if (failed > 0) then
print(msg)
os.exit(5)
else
print(msg)
end