-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
896: Refactor integration tests by reusing godot_test macro r=Bromeon a=Bromeon Reduces boilerplate of the form ```rs fn test_with_certain_name() -> bool { println!(" -- test_with_certain_name"); let ok = std::panic::catch_unwind(|| { // actual test code here }) .is_ok(); if !ok { godot_error!(" !! Test test_with_certain_name failed"); } ok } ``` to ```rs godot_itest! { test_with_certain_name { // actual test code here }} ``` which reduces repetition and focuses on important things. This is done by slightly adjusting the existing `godot_test` macro to `godot_itest`, which is needed so it can also be used in the `tests` crate. This change leads to a net removal of 300 lines of code. --- I was also considering a proc-macro attribute ```rs #[godot_test] fn test_with_certain_name() { // actual test code here } ``` which might be a tiny bit nicer syntax-wise, and even started implementing it. But I think the declarative macro does the job, is simpler and likely faster to compile (as we don't need `syn` to tokenize the entire code). --- Tests of this form now all have the `#[must_use]` attribute, yielding a warning if a boolean test result is ignored. Co-authored-by: Jan Haller <[email protected]>
- Loading branch information
Showing
15 changed files
with
570 additions
and
867 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.