test updates

- update main love readme to include note on tests
- added module tests for Sensor, Keyboard, Touch, Joystick, Mouse, and Love (for hooks + basic love-level methods)
- general clean-up of main class logic
- couple fixes for runner-specific failures (physics.Joint, audio.getActiveSourceCount, mouse.getPosition)
- change window.close test to run last
This commit is contained in:
ell
2023-12-04 16:13:38 +00:00
parent 8951635abc
commit 2875a96e92
19 changed files with 2917 additions and 381 deletions
+21 -21
View File
@@ -1,6 +1,3 @@
-- & 'c:\Program Files\LOVE\love.exe' ./ --console
-- /Applications/love_12.app/Contents/MacOS/love ./testing
-- load test objs
require('classes.TestSuite')
require('classes.TestModule')
@@ -10,6 +7,8 @@ require('classes.TestMethod')
love.test = TestSuite:new()
-- load test scripts if module is active
-- this is so in future if we have per-module disabling it'll still run
if love ~= nil then require('tests.love') end
if love.audio ~= nil then require('tests.audio') end
if love.data ~= nil then require('tests.data') end
if love.event ~= nil then require('tests.event') end
@@ -17,12 +16,17 @@ if love.filesystem ~= nil then require('tests.filesystem') end
if love.font ~= nil then require('tests.font') end
if love.graphics ~= nil then require('tests.graphics') end
if love.image ~= nil then require('tests.image') end
if love.joystick ~= nil then require('tests.joystick') end
if love.keyboard ~= nil then require('tests.keyboard') end
if love.math ~= nil then require('tests.math') end
if love.mouse ~= nil then require('tests.mouse') end
if love.physics ~= nil then require('tests.physics') end
if love.sensor ~= nil then require('tests.sensor') end
if love.sound ~= nil then require('tests.sound') end
if love.system ~= nil then require('tests.system') end
if love.thread ~= nil then require('tests.thread') end
if love.timer ~= nil then require('tests.timer') end
if love.touch ~= nil then require('tests.touch') end
if love.video ~= nil then require('tests.video') end
if love.window ~= nil then require('tests.window') end
@@ -47,9 +51,8 @@ love.load = function(args)
}
Logo.img = love.graphics.newQuad(0, 0, 64, 64, Logo.texture)
Font = love.graphics.newFont('resources/font.ttf', 8, 'normal')
local txtobj = love.graphics.newTextBatch or love.graphics.newText
TextCommand = txtobj(Font, 'Loading...')
TextRun = txtobj(Font, '')
TextCommand = 'Loading...'
TextRun = ''
end
end
@@ -73,14 +76,14 @@ love.load = function(args)
local method = ''
local cmderr = 'Invalid flag used'
local modules = {
'audio', 'data', 'event', 'filesystem', 'font', 'graphics',
'image', 'math', 'physics', 'sound', 'system',
'thread', 'timer', 'video', 'window'
'audio', 'data', 'event', 'filesystem', 'font', 'graphics', 'image',
'joystick', 'keyboard', 'love', 'math', 'mouse', 'physics', 'sensor',
'sound', 'system', 'thread', 'timer', 'touch', 'video', 'window'
}
GITHUB_RUNNER = false
for a=1,#arglist do
if testcmd == '--runSpecificMethod' then
if module == '' and love[ arglist[a] ] ~= nil then
if module == '' and (arglist[a] == 'love' or love[ arglist[a] ] ~= nil) then
module = arglist[a]
table.insert(modules, module)
elseif module ~= '' and love[module] ~= nil and method == '' then
@@ -88,7 +91,7 @@ love.load = function(args)
end
end
if testcmd == '--runSpecificModules' then
if love[ arglist[a] ] ~= nil and arglist[a] ~= '--isRunner' then
if (arglist[a] == 'love' or love[ arglist[a] ] ~= nil) and arglist[a] ~= '--isRunner' then
table.insert(modules, arglist[a])
end
end
@@ -157,7 +160,7 @@ love.load = function(args)
love.event.quit(0)
else
-- start first module
TextCommand:set(testcmd)
TextCommand = testcmd
love.test.module:runTests()
end
@@ -173,18 +176,19 @@ end
-- love.draw
-- draw a little logo to the screen
love.draw = function()
local lw = (love.graphics.getPixelWidth() - 128) / 2
local lh = (love.graphics.getPixelHeight() - 128) / 2
local lw = (love.graphics.getWidth() - 128) / 2
local lh = (love.graphics.getHeight() - 128) / 2
love.graphics.draw(Logo.texture, Logo.img, lw, lh, 0, 2, 2)
love.graphics.draw(TextCommand, 4, 12, 0, 2, 2)
love.graphics.draw(TextRun, 4, 32, 0, 2, 2)
love.graphics.setFont(Font)
love.graphics.print(TextCommand, 4, 12, 0, 2, 2)
love.graphics.print(TextRun, 4, 32, 0, 2, 2)
end
-- love.quit
-- add a hook to allow test modules to fake quit
love.quit = function()
if love.test.module ~= nil and love.test.module.fakequit == true then
if love.test.module ~= nil and love.test.module.fakequit then
return true
else
return false
@@ -210,7 +214,3 @@ end
function UtilTimeFormat(seconds)
return string.format("%.3f", tostring(seconds))
end
function UtilDebugLog(a, b, c)
if GITHUB_RUNNER == true then print("DEBUG ==> ", a, b, c) end
end