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 52515963b4 Make test framework module aware
- Move test action into main project script
- Look for and load test suites from manifest files
- Make individual tests play nicer with third-party modifications
2014-09-17 19:19:47 -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/_manifest.lua")
local manifests = os.matchfiles(mask)
-- Hmm, "**" should probably also match against "."?
local top = path.join(_MAIN_SCRIPT_DIR, "tests/_manifest.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