Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test suite cleanup + updates #1989

Merged
merged 3 commits into from
Dec 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ There are also unstable/nightly builds:
- For ubuntu linux they are in [ppa:bartbes/love-unstable][unstableppa]
- For arch linux there's [love-git][aur] in the AUR.

Test Suite
----------

The test suite in `testing/` covers all the LÖVE APIs, and tests them the same way developers use them. You can view current test coverage from any [12.0-dev action][12devworkflows].
You can run the suite locally like you would run a normal LÖVE project, i.e.:
`love testing/main.lua`

See the [readme][testsuite] in the testing folder for more info.
You can contribute to the test suite [here][testsuitemain]

Contributing
------------

Expand Down Expand Up @@ -107,3 +117,6 @@ Dependencies
[codestyle]: https://love2d.org/wiki/Code_Style
[android-repository]: https://github.com/love2d/love-android
[releases]: https://github.com/love2d/love/releases
[testsuite]: https://github.com/love2d/love/tree/12.0-development/testing
[testsuitemain]: https://github.com/ellraiser/love-test
[12devworkflows]: https://github.com/love2d/love/actions/workflows/main.yml?query=branch%3A12.0-development
27 changes: 13 additions & 14 deletions testing/classes/TestMethod.lua
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ TestMethod = {
-- @method - TestMethod:assertPixels()
-- @desc - checks a list of coloured pixels agaisnt given imgdata
-- @param {ImageData} imgdata - image data to check
-- @param {table} pixels - map of colors to list of pixel coords, i.e.
-- { blue = { {1, 1}, {2, 2}, {3, 4} } }
-- @param {table} pixelchecks - map of colors to list of pixel coords, i.e.
-- { blue = { {1, 1}, {2, 2}, {3, 4} } }
-- @return {nil}
assertPixels = function(self, imgdata, pixels, label)
for i, v in pairs(pixels) do
assertPixels = function(self, imgdata, pixelchecks, label)
for i, v in pairs(pixelchecks) do
local col = self.colors[i]
local pixels = v
for p=1,#pixels do
Expand Down Expand Up @@ -379,17 +379,17 @@ TestMethod = {
local failure = ''
local failures = 0
for a=1,#self.asserts do
-- @TODO just return first failed assertion msg? or all?
-- @TODO show all failued assertion methods?
ellraiser marked this conversation as resolved.
Show resolved Hide resolved
-- currently just shows the first assert that failed
if self.asserts[a].passed == false and self.skipped == false then
if not self.asserts[a].passed and not self.skipped then
if failure == '' then failure = self.asserts[a] end
failures = failures + 1
end
end
if self.fatal ~= '' then failure = self.fatal end
local passed = tostring(#self.asserts - failures)
local total = '(' .. passed .. '/' .. tostring(#self.asserts) .. ')'
if self.skipped == true then
if self.skipped then
self.testmodule.skipped = self.testmodule.skipped + 1
love.test.totals[3] = love.test.totals[3] + 1
self.result = {
Expand Down Expand Up @@ -454,7 +454,6 @@ TestMethod = {
printResult = function(self)

-- get total timestamp
-- @TODO make nicer, just need a 3DP ms value
self.finish = love.timer.getTime() - self.start
love.test.time = love.test.time + self.finish
self.testmodule.time = self.testmodule.time + self.finish
Expand All @@ -463,15 +462,15 @@ TestMethod = {
-- get failure/skip message for output (if any)
local failure = ''
local output = ''
if self.passed == false and self.skipped == false then
if not self.passed and not self.skipped then
failure = '\t\t\t<failure message="' .. self.result.key .. ' ' ..
self.result.message .. '">' .. self.result.key .. ' ' .. self.result.message .. '</failure>\n'
output = self.result.key .. ' ' .. self.result.message
-- append failures if any to report md
love.test.mdfailures = love.test.mdfailures .. '> 🔴 ' .. self.method .. ' \n' ..
'> ' .. output .. ' \n\n'
end
if output == '' and self.skipped == true then
if output == '' and self.skipped then
failure = '\t\t\t<skipped message="' .. self.skipreason .. '" />\n'
output = self.skipreason
end
Expand Down Expand Up @@ -504,8 +503,8 @@ TestMethod = {
-- append HTML for the test class result
local status = '🔴'
local cls = 'red'
if self.passed == true then status = '🟢'; cls = '' end
if self.skipped == true then status = '🟡'; cls = '' end
if self.passed then status = '🟢'; cls = '' end
if self.skipped then status = '🟡'; cls = '' end
self.testmodule.html = self.testmodule.html ..
'<tr class=" ' .. cls .. '">' ..
'<td>' .. status .. '</td>' ..
Expand All @@ -516,11 +515,11 @@ TestMethod = {

-- add message if assert failed
local msg = ''
if self.result.message ~= nil and self.skipped == false then
if self.result.message ~= nil and not self.skipped then
msg = ' - ' .. self.result.key ..
' failed - (' .. self.result.message .. ')'
end
if self.skipped == true then
if self.skipped then
msg = self.result.message
end

Expand Down
11 changes: 7 additions & 4 deletions testing/classes/TestSuite.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ TestSuite = {
graphics = {},
image = {},
joystick = {},
love = {},
keyboard = {},
math = {},
mouse = {},
physics = {},
sensor = {},
sound = {},
system = {},
thread = {},
Expand All @@ -60,7 +63,7 @@ TestSuite = {
-- stagger between tests
if self.module ~= nil then

if self.module.start == true then
if self.module.start then

-- work through each test method 1 by 1
if self.module.index <= #self.module.running then
Expand All @@ -70,13 +73,13 @@ TestSuite = {
self.module.called[self.module.index] = true
local method = self.module.running[self.module.index]
self.test = TestMethod:new(method, self.module)
TextRun:set('love.' .. self.module.module .. '.' .. method)
TextRun = 'love.' .. self.module.module .. '.' .. method

self.test.co = coroutine.create(function()
local ok, chunk, err = pcall(love.test[love.test.module.module][method], love.test.test)
if ok == false then
love.test.test.passed = false
love.test.test.fatal = tostring(chunk) .. tostring(err)
love.test.test['passed'] = false
love.test.test['fatal'] = tostring(chunk) .. tostring(err)
end
end)

Expand Down
16 changes: 0 additions & 16 deletions testing/conf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,4 @@ function love.conf(t)
t.window.height = 240
t.window.resizable = true
t.renderers = {"opengl"}
t.modules.audio = true
t.modules.data = true
t.modules.event = true
t.modules.filesystem = true
t.modules.font = true
t.modules.graphics = true
t.modules.image = true
t.modules.math = true
t.modules.objects = true
t.modules.physics = true
t.modules.sound = true
t.modules.system = true
t.modules.thread = true
t.modules.timer = true
t.modules.video = true
t.modules.window = true
end
2 changes: 1 addition & 1 deletion testing/examples/lovetest_runAllTests.html

Large diffs are not rendered by default.

36 changes: 21 additions & 15 deletions testing/examples/lovetest_runAllTests.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
<!-- PASSED 287 || FAILED 0 || SKIPPED 14 || TIME 14.726 -->
<!-- PASSED 339 || FAILED 0 || SKIPPED 9 || TIME 14.445 -->

### Info
**301** tests were completed in **14.726s** with **287** passed, **0** failed, and **14** skipped
**348** tests were completed in **14.445s** with **339** passed, **0** failed, and **9** skipped

Renderer: OpenGL | 4.1 Metal - 76.3 | Apple | Apple M1 Max

### Report
| Module | Pass | Fail | Skip | Time |
| --------------------- | ------ | ------ | ------- | ------ |
| 🟢 audio | 28 | 0 | 0 | 0.894s |
| 🟢 audio | 28 | 0 | 0 | 0.865s |
| 🟢 data | 12 | 0 | 0 | 0.209s |
| 🟢 event | 4 | 0 | 2 | 0.103s |
| 🟢 filesystem | 29 | 0 | 2 | 0.550s |
| 🟢 font | 7 | 0 | 0 | 0.124s |
| 🟢 graphics | 102 | 0 | 3 | 3.231s |
| 🟢 image | 5 | 0 | 0 | 0.098s |
| 🟢 math | 20 | 0 | 0 | 0.353s |
| 🟢 physics | 23 | 0 | 3 | 0.449s |
| 🟢 sound | 4 | 0 | 0 | 0.074s |
| 🟢 system | 6 | 0 | 2 | 0.144s |
| 🟢 thread | 5 | 0 | 0 | 0.377s |
| 🟢 timer | 6 | 0 | 0 | 2.093s |
| 🟢 event | 4 | 0 | 2 | 0.104s |
| 🟢 filesystem | 29 | 0 | 2 | 0.546s |
| 🟢 font | 7 | 0 | 0 | 0.117s |
| 🟢 graphics | 104 | 0 | 1 | 2.948s |
| 🟢 image | 5 | 0 | 0 | 0.085s |
| 🟢 joystick | 6 | 0 | 0 | 0.106s |
| 🟢 keyboard | 9 | 0 | 0 | 0.151s |
| 🟢 love | 10 | 0 | 0 | 0.166s |
| 🟢 math | 20 | 0 | 0 | 0.339s |
| 🟢 mouse | 18 | 0 | 0 | 0.303s |
| 🟢 physics | 26 | 0 | 0 | 0.439s |
| 🟢 sensor | 1 | 0 | 0 | 0.016s |
| 🟢 sound | 4 | 0 | 0 | 0.073s |
| 🟢 system | 6 | 0 | 2 | 0.137s |
| 🟢 thread | 5 | 0 | 0 | 0.363s |
| 🟢 timer | 6 | 0 | 0 | 2.076s |
| 🟢 touch | 3 | 0 | 0 | 0.007s |
| 🟢 video | 2 | 0 | 0 | 0.040s |
| 🟢 window | 34 | 0 | 2 | 5.986s |
| 🟢 window | 34 | 0 | 2 | 5.355s |

### Failures
Loading
Loading