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.
Add a cmake module
cmake/AddTest.cmake
that provides wrappers to simplify test writing, especially when many tiny tests are required (learnt the idea from range-v3).I can't measure how general this module will be, so I propose to add the module here instead of project_options.
Before: (even already abstract the common part out as
catch2_test_common
)After:
add_library_test(my_exe_lib tests CONFIGS common SOURCES tests.cpp) add_executable_test(my_exe no_arg)
Users can also compose CONFIGS for reuse:
Functions:
add_test_config
: generate a test config target that can be used by linking it, the name of this config target will betest_config.<config_name>
.add_library_test
: add a test for the<library>
, the name of this target will betest.<library>.<test_name>
.add_executable_test
: add a test for the<executable>
by running it, the name of this target will betest.<executable>.<test_name>
.add_executable_test(<executable> <test_name> [CONFIGS <arg1...>] # accepts both `${config_name}` and `test_config.${config_name}` [EXECUTE_ARGS <arg1...>] )