-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
Add runner for GDScript testing #47701
Conversation
5b6e116
to
fc2f19f
Compare
Update to solve a couple of issues (separate commits since not directly related to this). |
This is meant for testing the GDScript implementation, not for testing user scripts nor testing the engine using scripts. Tests consists in a GDScript file and a .out file with the expected output. The .out file format is: expected status (based on the enum GDScriptTest::TestStatus) on the first line, followed by either an error message or the resulting output. Warnings are added after the first line, before the output (or compiler errors) if the parser pass without any error. The test script must have a function called `test()` which takes no argument. Such function will be called by the test runner. The test should not have any dependency unless it's part of the test too. Global classes (using `class_name`) are registered before the runner starts, so those should work if needed. Use the command `godot --gdscript-generate-tests godot-source/modules/gdscript/tests/scripts` to update the .out files with the current output (make sure the output are the expected values before committing). The tests themselves are part of the doctest suite so those can be executed with `godot --test`. Co-authored-by: Andrii Doroshenko (Xrayez) <[email protected]>
Some tests need functions of ProjectSettings that rely on this being available.
Since loading the config might use the resource path, it needs to be set before that happens.
fc2f19f
to
b25ab27
Compare
Another update to fix the CI. I didn't realize that it runs with a Mono build without the glue (we may want to revisit that if tests for Mono are introduced). Since I was initializing the languages to use GDScript, the absence of Mono glue made it crash. I changed to only initialize GDScript. |
On |
I took #47157 and created a new test script for it: # missing-constant-string-for-assert.gd
func test():
var got = "GoDot"
var expected = "Godot"
assert(got == expected, "Error, expected: " + expected) Then generated corresponding
The resulting file looks like this (with the same name):
Then run the GDScript test suite specifically:
So I'd say it's fairly functional! Not sure about the requirement of specifying the path to GDScript test scripts for For testers: don't forget to compile the engine with |
Thanks! |
This is meant for testing the GDScript implementation, not for testing user scripts nor testing the engine using scripts.
Tests consists in a GDScript file and a .out file with the expected output. The .out file format is: expected status (based on the enum GDScriptTest::TestStatus) on the first line, followed by either an error message or the resulting output. Warnings are added after the first line, before the output (or compiler errors) if the parser pass without any error.
The test script must have a function called
test()
which takes no argument. Such function will be called by the test runner. The test should not have any dependency unless it's part of the test too. Global classes (usingclass_name
) are registered before the runner starts, so those should work if needed.Use the command
godot --gdscript-generate-tests godot-source/modules/gdscript/tests/scripts
to update the .out fileswith the current output (make sure the output are the expected values before committing).
The tests themselves are part of the doctest suite so those can be executed with
godot --test
.Thanks @Xrayez for the initial work porting the runner to doctest. This therefore supersedes #41074.
I moved the test suite to its own file because otherwise the tests would run twice.