feat: Expose list of tests with less magic #136
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prior to this change the static variable
TESTS
had to be declared in the root of the crate in which the#[libtest2::test]
macros were used. This was automatically inserted by the#[libtest2::main]
macro, but if the user did not include this an error would be shown.A consequence of this is that the
#[libtest2::test]
macro could not be used on its own to collect tests, unless the user accessed the hidden, private API exposed in the_private
module.The obvious downside of this change is that the user will no longer receive an error message if they use the
#[libtest2::test]
macro without#[libtest2::main]
, and thus no tests will be run. The compiler will, however, still complain if the user is missing amain
function.Note: This does not have an open issue. I figured the conversation around whether or not this is a good change was better made with some code to look at.