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

[TRACKER] Unit Test Porting #40659

Closed
5 of 10 tasks
RevoluPowered opened this issue Jul 24, 2020 · 10 comments · Fixed by #59963
Closed
5 of 10 tasks

[TRACKER] Unit Test Porting #40659

RevoluPowered opened this issue Jul 24, 2020 · 10 comments · Fixed by #59963

Comments

@RevoluPowered
Copy link
Contributor

RevoluPowered commented Jul 24, 2020

We integrated doctest unit test framework and have depreciated old unit tests in favor of headless tests which can run on our CI.

Some useful information and the PR can be found here:
#40148 (comment)

Test status:

  • test_string.h (was ported in initial pr)
  • test_astar: (ported in Port AStar tests to use doctest #40835).
  • test_basis: (ported in Port Basis tests to use doctest. #40940).
  • test_class_db: (ported in Port ClassDB tests to use doctest #40980).
  • test_gdscript: don't port, likely going to be rewritten, see Enable support for C++ modules tests #40720 (comment).
  • test_gui: no assertions found, just random code doing stuff, not sure how to test.
  • ⚠️ test_math ⚠️: catastrophic, need a nuclear weapon to clean this up first 🙂, it seems like the code has accumulated random stuff over the span of Godot's existence. Seems to include code for math parsing, geometry (updated 3 months ago), various file access stuff, even platform specific code like: OS::get_singleton()->execute("/bin/ls");.
  • test_oa_hash_map: ok, but has some stress tests.
  • test_ordered_hash_map: (ported in Port OrderedHashMap tests to doctest #41117).
  • test_physics_2d/3d and test_render: no asserts, just code, not sure how to test.
  • test_shader_lang: need someone from core devs for best results, but likely can be ported without issues.

*updated from Xrayez[m] below
New tests to be written:

  • local_vector.h
  • networking?
  • audio?
  • ... etc
  • every data container we implement

General guide:

  1. Delete the .cpp file and remove the old test harness after copying contents to the header
  2. include the doctest header
  3. if you have to use a specific feature like the classdb you must initialize this manually recommended using init_class_db() and deinit_class_db() at the start and end of each function, you are responsible for initializing that portion of the engine in the test, if you require the renderer, you can see the logic required for this in main.cpp/main.h in main/ directory.
  4. If you have questions check the doctest documentation then if you're stuck ping us on IRC we don't bite.
  5. Remove ALL print logic from the tests, use INFO() when you need a print, but do not use this in place of a print, it's not required to print, just use CHECK() output of the tests is normal for INFO but not in a 'spammed context'

For safety, we actually initialized the os::singleton properly for you so that logging works fine.

Cool stuff we can now do which we couldn't before
./godot --test -d (profile your tests time)
./godot --test --reporters=xml,junit,console (report some details in other formats for CI or Coverage checkers)
./godot --test -s (show what checks are in the tests)

@RevoluPowered RevoluPowered changed the title [Tracker] Unit Test Porting [TRACKER] Unit Test Porting Jul 24, 2020
@Calinou Calinou added this to the 4.0 milestone Jul 24, 2020
@RevoluPowered
Copy link
Contributor Author

crash bug on vscode #40666

@Anutrix
Copy link
Contributor

Anutrix commented Jul 25, 2020

@RevoluPowered Maybe change those bullets to checkboxes.

@RevoluPowered
Copy link
Contributor Author

An update:

  • scons -j16 tools=yes tests=yes is required to build tests now :) Thanks @Xrayez for resurrecting your PR
  • tests are now top level directory in tests/ by @Xrayez

@Xrayez
Copy link
Contributor

Xrayez commented Jul 29, 2020

I went through some existing tests to see the feasibility of them to be ported:

For stress tests I propose prepending "[Stress]" tags to test case names for now, so that they can be excluded to have deterministic results on GitHub's CI, I think those are more useful to run on separate instances to find more bugs rather than regressions.

@fire
Copy link
Member

fire commented Aug 1, 2020

Porting basis currently.

@fire
Copy link
Member

fire commented Aug 1, 2020

Basis is ported #40940

@3akev
Copy link
Contributor

3akev commented Aug 8, 2020

OrderedHashMap is ported in #41117

@Xrayez
Copy link
Contributor

Xrayez commented Aug 17, 2020

ClassDB tests ported in #40980. This opens up possibility to write unit tests for classes which inherit Object (directly or indirectly), so feel free to write some new tests for those!

@RevoluPowered
Copy link
Contributor Author

test_fbx will be ported by me after we can get the 3.2 pr out of the way I've backed up the branch with the originals to RevoluPowered/backup_fbx_tests (they're in the old folder)

@Xrayez
Copy link
Contributor

Xrayez commented Sep 15, 2020

Preliminary documentation is written in godotengine/godot-docs#4017, once merged, should be available under Engine DevelopmentUnit Testing.


Update: available at https://docs.godotengine.org/en/latest/development/cpp/unit_testing.html.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants