forked from panel-attack/panel-game
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestLauncher.lua
More file actions
97 lines (89 loc) · 3.13 KB
/
testLauncher.lua
File metadata and controls
97 lines (89 loc) · 3.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
---@diagnostic disable: duplicate-set-field
-- with love 12 you can pass the name of a lua file as an argument when starting love
-- this will cause that file to be used in place of main.lua
-- so by passing "./testLauncher.lua" as the first arg this becomes a testrunner that shares the game's conf.lua
require("common.lib.mathExtensions")
local util = require("common.lib.util")
util.addToCPath("./common/lib/??")
util.addToCPath("./server/lib/??")
local logger = require("common.lib.logger")
require("client.src.globals")
local Game = require("client.src.Game")
if arg[2] == "debug" then
require("client.src.developer")
end
function love.load()
-- this is necessary setup of globals while non-client tests still depend on client components
GAME = Game()
GAME:load()
GAME.muteSound = true
local cr = coroutine.create(GAME.setupRoutine)
while coroutine.status(cr) ~= "dead" do
local success, status = coroutine.resume(cr, GAME)
if not success then
GAME.crashTrace = debug.traceback(cr)
error(status)
end
end
end
local tests = {
"server.tests.ServerTests",
"server.tests.LeaderboardTests",
"server.tests.RoomTests",
"server.tests.LoginTests",
"client.tests.FileUtilsTests",
"client.tests.ModControllerTests",
"common.tests.engine.StackRollbackReplayTests",
"client.tests.QueueTests",
"client.tests.ServerQueueTests",
"client.tests.StackGraphicsTests",
"client.tests.TcpClientTests",
"client.tests.ThemeTests",
"common.tests.engine.GarbageQueueTests",
"common.tests.engine.HealthTests",
"common.tests.engine.PanelGenTests",
"common.tests.engine.PuzzleTests",
"common.tests.engine.ReplayTests",
"common.tests.engine.RollbackBufferTests",
"common.tests.engine.StackTests",
"common.tests.engine.StackReplayTests",
"common.tests.engine.StackTouchReplayTests",
-- disabled for testLauncher because it needs the client love callbacks
--"common.tests.lib.InputTests",
"common.tests.lib.JsonEncodingTests",
"common.tests.lib.tableUtilsTest",
"common.tests.lib.utf8AdditionsTests",
"common.tests.lib.utilTests",
"common.tests.network.NetworkProtocolTests",
"common.tests.network.TouchDataEncodingTests",
}
local updateCount = 0
function love.update(dt)
if tests[updateCount] then
logger.info("running test file " .. tests[updateCount])
require(tests[updateCount])
end
updateCount = updateCount + 1
end
-- the drawing somehow doesn't really work because the update does not wait for the require to finish?
function love.draw()
local width, height = love.window.getMode()
if tests[updateCount + 1] then
love.graphics.printf("Running " .. tests[updateCount + 1], 0, height / 2, width, "center")
elseif updateCount > #tests then
love.graphics.printf("All tests completed", 0, height / 2, width, "center")
end
end
function love.quit()
love.filesystem.write("test.log", table.concat(logger.messages, "\n"))
end
local love_errorhandler = love.errorhandler
function love.errorhandler(msg)
logger.info(msg)
pcall(love.filesystem.write, "test-crash.log", table.concat(logger.messages, "\n"))
if lldebugger then
error(msg, 2)
else
return love_errorhandler(msg)
end
end