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

basic API test suite #1974

Merged
merged 57 commits into from
Nov 30, 2023
Merged

basic API test suite #1974

merged 57 commits into from
Nov 30, 2023

Conversation

ellraiser
Copy link
Contributor

@ellraiser ellraiser commented Oct 4, 2023

Initial commit of a basic test framework, see readme.md in /testing for more

Most modules are covered with basic unit tests, and there's an example test for a graphics draw (rectangle) and object (File) - for object tests doing more scenario based so we can check multiple things together, if style is fine will carry on working through the other graphics methods + object types (which is the bulk of the work tbh)

Initial commit of a basic test framework, see readme.md for more

Most modules are covered with basic unit tests, and there's an example test for a graphics draw (rectangle) and object (File) - for object tests doing more scenario based so we can check multiple things together
testing/classes/TestMethod.lua Outdated Show resolved Hide resolved
testing/classes/TestSuite.lua Outdated Show resolved Hide resolved
testing/tests/audio.lua Outdated Show resolved Hide resolved
testing/tests/audio.lua Outdated Show resolved Hide resolved
testing/tests/window.lua Outdated Show resolved Hide resolved
- Added tests for all obj creation, transformation, window + system info graphics methods
- Added half the state methods for graphics + added placeholders for missing drawing methods
- Added TestMethod:assertNotNil() for quick nil checking
- Added time total to the end of each module summary in console log to match file output

- Removed a bunch of unessecary nil checks
- Removed :release() from test methods, collectgarbage("collect") is called between methods instead

- Renamed /output to /examples to avoid confusion

- Replaced love.filesystem.newFile with love.filesystem.openFile
- Replaced love.math.noise with love.math.perlinNoise / love.math.simplexNoise

- Fixed newGearJoint throwing an error in 12 as body needs to be dynamic not static now

- Some general cleanup, incl. better comments and time format in file output
dorny/test-reporter@v1 will fail to parse <failure> tags that are empty as it's expected a message both in the attr and inside
added md support to work with love-test-report, a basic action made to just dump md files into repo checks
@slime73
Copy link
Member

slime73 commented Oct 8, 2023

I think the place I'd expect to have object tests is inside the file for the module that owns the object, e.g. Transform and RandomGenerator tests would be in math.lua rather than objects.lua. That'd more closely match where the object code lives in love's codebase and where the documentation for those objects lives in the wiki.

@ellraiser
Copy link
Contributor Author

Sure! Can do that - do you still want them accessible under the love.test.objects "module" or would you prefer having them directly under the module, i.e. love.test.graphics.Rasterizer()?

@slime73
Copy link
Member

slime73 commented Oct 8, 2023

Directly under the module like love.test.graphics.Texture.getDimensions probably makes sense, although that's a bit wordy

- added mostly all graphics draw tests
- added a basic set of "expected" images (generated from successful tests)
- HTML output now shows the expected vs actual generated images for each of the graphics tests applicable
- finished audio module
- finished data module
- finished filesystem module
- finished font module (note: glphy test fails, but seems to be a 12.0 issue)
- finished image module
- finished maths module
- finished sound module
- finished thread module
- finished video module
- fixed pcall error not showing in results for invalid test code
- added graphics.Canvas, graphics.Font, graphics.Image, graphics.Quad, graphics.Shader and graphics.Text
- removed rogue resource img
- removed event wait test placeholder
- updated todo list
- added obj tests for graphics.SpriteBatch, and graphics.Video
- added obj tests for physics.World
- added test for setStencilMode and removed deprecated stencil+setStencilTest
- added graphics.drawInstanced
- fixed deprecated physic shape calls (body now added as first param)
- added an automatic check for expected vs actual with the images already shown in the report - used a 1px tolerance for now for each of the pixels checked
- added physics.Contact, physics.Body, and physics.Shape obj tests
- added graphics.Mesh and graphics.ParticleSystem obj tests
- fixed some rgba tolerance needed on a couple methods
- added test conclusion to zip artifact name for quick checking on PRs
- ignored testsuite on compat mode windows builds
@ellraiser ellraiser marked this pull request as ready for review November 20, 2023 20:24
testing/tests/physics.lua Outdated Show resolved Hide resolved
testing/tests/physics.lua Outdated Show resolved Hide resolved
testing/tests/physics.lua Outdated Show resolved Hide resolved
testing/tests/physics.lua Outdated Show resolved Hide resolved
- spaced out object class tests and added more defined comment groups

- changed reusing vars in case it causes unexpected asserts in future

- fixed some shape:point test having wrong params

- added assertTrue + assertFalse for basic checks

- used assertRange more for some of the physics + audio tests
Copy link
Member

@slime73 slime73 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a few comments but I don't think any of them need to be addressed before this version is merged. This was a huge amount of effort, thanks so much for taking it on! I like that it's already found several legit bugs in love 12 even while it was being fleshed out.

testing/main.lua Show resolved Hide resolved
testing/main.lua Show resolved Hide resolved
testing/main.lua Show resolved Hide resolved
testing/classes/TestSuite.lua Show resolved Hide resolved
@slime73
Copy link
Member

slime73 commented Nov 30, 2023

I might have more comments once I start adding to the tests myself, but for now I'll press the big green button and see what happens

@slime73 slime73 merged commit 36783d3 into love2d:12.0-development Nov 30, 2023
8 checks passed
@ellraiser ellraiser deleted the 12.0-testsuite branch December 4, 2023 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants