-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
Added doctest unit test framework #40148
Conversation
#30743 - updated doctest for 4.0 fixed conflicts |
How would future tests be handled? Would it be Once this is merged, I think we should port all other tests to doctest and document the workflow. |
Some style issues: https://travis-ci.org/github/godotengine/godot/jobs/705243011 Also make sure to use braces around single-line You lost some of @aaronfranke's changes in |
@akien-mga I have applied the requested changes, but made a slight improvement to the mingw specific section. I used PRId64 (inttypes.h) to correct this issue as it handles the platform specific issue here for us, but I need to test this on mingw, so will do this in a bit and if it works would it be okay to keep this? The fix is based on https://stackoverflow.com/questions/9225567/how-to-print-a-int64-t-type-in-c this article, just so we don't have to duplicate code or do extra casting. Also just applied the fix you mentioned regarding the {} parenthesis |
I will write a quick fix for this now, to make it so |
2213a77
to
092e9e1
Compare
@akien-mga OK all points raised should now be sorted, I expanded the run functionality to make it more usable for regression testing too, it's super simple lets you run whatever specific test you would like too, also leaves legacy compatibility in. @aaronfranke can you possibly take a look at the fix I applied here, I think it could be simpler for godot to use this instead, it should remove the need for the preprocessor. reference: https://stackoverflow.com/questions/9225567/how-to-print-a-int64-t-type-in-c |
7d36065
to
387ac0b
Compare
387ac0b
to
84b05b8
Compare
4396b43
to
e6c3c8e
Compare
That's fine, I don't think there was much to salvage in most legacy tests in the first place. It's better to start cleanly with the new framework, and then port and modernize the tests which were up-to-date enough with the Godot API (like hashmaps and AStar tests). |
Cool, so I left the real files in main/tests/ but they do nothing at the moment to clarify that I didn't remove the actual files, just the legacy test runner, so whoever ports them its simpler, I will try to help with this effort and get them across but need to do this after merge, basis, fbx and math will probably be the ones I port after merge |
Possibly we need some system for measuring the code coverage later on too. |
Needs a rebase after #40556. |
9ae8f1d
to
972a8cd
Compare
Done, I ensured no extra whitespace. |
9c503ca
to
5099faa
Compare
.github/workflows/macos_builds.yml
Outdated
@@ -51,6 +51,11 @@ jobs: | |||
run: | | |||
scons -j2 verbose=yes warnings=all werror=yes platform=osx tools=yes target=release_debug | |||
|
|||
# execute unit tests for the editor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# execute unit tests for the editor | |
# Execute unit tests for the editor |
Consistency! :)
5099faa
to
785aa98
Compare
Implements exit codes into the engine so tests can return their statuses. Ideally we don't do this, and we use FIXUP logic to 'begin' and 'end' the engine execution for tests specifically. Since realistically we're initialising the engine here we don't want to do that, since String should not require an engine startup to test a single header. This lowers the complexity of running the unit tests and even for physics should be possible to implement such a fix.
785aa98
to
5793428
Compare
For Devs: In order to make sure your test is built, once you write your test include the header for it in To run tests you can use The basics: TEST_CASE("some regression test") {
CHECK(something_worked());
} Reference guide Things which wont work // by design errors a check should be a SINGULAR check.
CHECK(something && something_else);
CHECK(something || something_else); |
Thanks a ton! |
|
@aaronfranke As of 6831da6, I can see it at the end of the text returned by
|
Yes, this was done in #40832, the old tests are inaccessible but are still there, but some of those are resurrected now: #41355. See preliminary documentation about tests and those additional test tools in godotengine/godot-docs#4017. |
This uses doctest to implement unit testing for the core of godot.
This includes the following:
Benefits
Current test runner can be executed by running ./bin/godot.x11.tools.64 --test string, or by specific test name
Demo with
./godot --test
argumentDemo with backward compatibility with other core tests
![image](https://user-images.githubusercontent.com/748770/67679871-fea78680-f981-11e9-829e-87543e3403fd.png)
--test math
Articles of supporting info: