Implement auto test
This commit is contained in:
@@ -1,8 +1,17 @@
|
|||||||
NONE={}function NULL()end
|
NONE={}function NULL()end
|
||||||
EDITING=""
|
EDITING=""
|
||||||
LOADED=false
|
LOADED=false
|
||||||
|
TEST_MODE=false
|
||||||
ERRDATA={}
|
ERRDATA={}
|
||||||
|
|
||||||
|
--Test script
|
||||||
|
--[[
|
||||||
|
Yield a number to sleep for that many frames, otherwise just do it!
|
||||||
|
We will set the script after we load stuff.
|
||||||
|
--]]
|
||||||
|
TESTS = nil
|
||||||
|
TEST_SLEEP = 0
|
||||||
|
|
||||||
--Pure lua modules (basic)
|
--Pure lua modules (basic)
|
||||||
COLOR= require'Zframework.color'
|
COLOR= require'Zframework.color'
|
||||||
TABLE= require'Zframework.tableExtend'
|
TABLE= require'Zframework.tableExtend'
|
||||||
@@ -400,6 +409,12 @@ function love.errorhandler(msg)
|
|||||||
love.audio.stop()
|
love.audio.stop()
|
||||||
gc.reset()
|
gc.reset()
|
||||||
|
|
||||||
|
--In test mode, we fail early
|
||||||
|
if TEST_MODE then
|
||||||
|
print("\27[91m\27[1mAutomatic Test Failed :(\27[0m\nWe are in test mode, so we error out. The error message is:\n"..msg.."\27[91m\nAborting\27[0m")
|
||||||
|
love.event.quit(1)
|
||||||
|
end
|
||||||
|
|
||||||
if LOADED and #ERRDATA<3 then
|
if LOADED and #ERRDATA<3 then
|
||||||
BG.set('none')
|
BG.set('none')
|
||||||
local scn=SCN and SCN.cur or"NULL"
|
local scn=SCN and SCN.cur or"NULL"
|
||||||
@@ -533,6 +548,14 @@ function love.run()
|
|||||||
|
|
||||||
love.resize(gc.getWidth(),gc.getHeight())
|
love.resize(gc.getWidth(),gc.getHeight())
|
||||||
|
|
||||||
|
-- Argument parsing
|
||||||
|
-- TODO: currently very simple, only support one argument
|
||||||
|
for i, c in ipairs(arg) do
|
||||||
|
if c=='--test' then
|
||||||
|
TEST_MODE = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--Scene Launch
|
--Scene Launch
|
||||||
while #SCN.stack>0 do SCN.pop()end
|
while #SCN.stack>0 do SCN.pop()end
|
||||||
SCN.push('quit','slowFade')
|
SCN.push('quit','slowFade')
|
||||||
@@ -692,6 +715,18 @@ function love.run()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--Execute testing tasks
|
||||||
|
if TEST_MODE then
|
||||||
|
if TEST_SLEEP > 0 then
|
||||||
|
TEST_SLEEP = TEST_SLEEP - 1
|
||||||
|
else
|
||||||
|
TEST_SLEEP = TESTS()
|
||||||
|
if TEST_SLEEP == nil then
|
||||||
|
love.event.quit(0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--Keep 60fps
|
--Keep 60fps
|
||||||
_=timer()-lastFrame
|
_=timer()-lastFrame
|
||||||
if _<.0162 then WAIT(.0162-_)end
|
if _<.0162 then WAIT(.0162-_)end
|
||||||
|
|||||||
16
main.lua
16
main.lua
@@ -576,3 +576,19 @@ table.sort(REPLAY,function(a,b)return a.fileName>b.fileName end)
|
|||||||
table.insert(_LOADTIMELIST_,("Initialize Data: %.3fs"):format(TIME()-_LOADTIME_))
|
table.insert(_LOADTIMELIST_,("Initialize Data: %.3fs"):format(TIME()-_LOADTIME_))
|
||||||
|
|
||||||
for i=1,#_LOADTIMELIST_ do LOG(_LOADTIMELIST_[i])end
|
for i=1,#_LOADTIMELIST_ do LOG(_LOADTIMELIST_[i])end
|
||||||
|
|
||||||
|
TESTS = coroutine.wrap(function()
|
||||||
|
print("\27[92m\27[1mAutomatic Test Started\27[0m")
|
||||||
|
YIELD(60)
|
||||||
|
MES.new('check', 'Test mode engaged!!')
|
||||||
|
for i, mode in pairs(MODES) do
|
||||||
|
if i == 'PCbase' or i == 'PClist' or i == 'netBattle' then else
|
||||||
|
print("Scanning mode "..mode.name)
|
||||||
|
loadGame(mode.name)
|
||||||
|
YIELD(120)
|
||||||
|
SCN.back()
|
||||||
|
YIELD(30)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
print("\27[92m\27[1mAutomatic Test Passed :)\27[0m")
|
||||||
|
end)
|
||||||
|
|||||||
Reference in New Issue
Block a user