-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
cmake: Add new DISCOVERY_MODE option to catch_discover_tests #2670
Conversation
Move test discovery logic into new catch_discover_tests_impl method and make CatchAddTests aware of whether it is being launched in CMake's script mode. When launched in script mode, catch_discover_tests_impl is called passing arguments obtained from the definitions passed into the call to cmake. This preserves the existing behavior assumed by Catch.cmake. Looking ahead, it also allows CatchAddTests to be included in generated files and call catch_discover_tests_impl to perform test discovery at test runtime with the new PRE_TEST discovery mode introduced later.
Codecov Report
@@ Coverage Diff @@
## devel #2670 +/- ##
==========================================
+ Coverage 91.24% 91.25% +0.01%
==========================================
Files 192 192
Lines 7808 7808
==========================================
+ Hits 7124 7125 +1
+ Misses 684 683 -1 |
Introducing a new DISCOVERY_MODE mode option, which provides greater control over when catch_discover_tests perforsm test discovery. It has two supported modes: * POST_BUILD: The default behavior, which adds a POST_BUILD command to perform test discovery after the test has been built as was always done so far. * PRE_TEST: New mode, which delays test discovery until test execution. The generated include file generates the appropriate CTest files at runtime and regenerates the CTest files when the executable is updated. This mode can be used in build-environments that don't allow for executing the linked binaries at build-time (like in a cross-compilation environment). DISCOVERY_MODE can be controlled in two ways: 1. Setting the DISCOVERY_MODE when calling catch_discover_tests. 2. Setting the global CMAKE_CATCH_DISCOVER_TESTS_DISCOVERY_MODE prior to calling gtest_discover_tests. Closes catchorg#2493
3211fac
to
d03fafe
Compare
Sorry, forgot that you prefer fixup commits in your review process. But shoudl not be a big deal in this PR, pls cf. incremental diff here |
LGTM, thanks. |
Hi @riandrake, thx for spotting this. Indeed currently multi-config generators are not supported with Could you maybe test #2739? Works for me so far, though I still miss testing all combinations. Thx |
@hkaelber this worked, thanks! I have a question though. I noted that it didn't collect the tests until Am I misunderstanding how |
Not sure I understood your point, @riandrake. I've never used multi-config so far, but to my understanding
Correct? (Though I'm 100% sure how ctest is supposed to be executed in a multi-config env.) |
Understood, thank you.
…On Mon, 11 Sep 2023 at 03:10, Holger Kaelberer ***@***.***> wrote:
@hkaelber <https://github.com/hkaelber> this worked, thanks! I have a
question though.
I noted that it didn't collect the tests until PRE_TEST time as expected,
but this happened only once. My hope was that I could change the TEST_SPEC
variable between runs and have it collect the tests again for targeted
testing.
Am I misunderstanding how PRE_TEST works? If so, could I feature request
this additional functionality somewhere?
Not sure I understood your point, @riandrake
<https://github.com/riandrake>.
I've never used multi-config so far, but to my understanding
1. at configure/cmake time the config-specifc test includes are
generated (containing the postponed discovery command) together with the
main include file, that simply pulls in the config-specific test-include
2. at every ctest invocation (per concrete config, Debug, Release,
etc) the actual config-specific test file should be generated and executed
Correct? (Though I'm 100% sure how ctest is supposed to be executed in a
multi-config env.)
That means that the TEST_SPEC is already fixed in 1. for all configs.
—
Reply to this email directly, view it on GitHub
<#2670 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABMYESQLTLRLWLKQ76H7AFTXZXJ6PANCNFSM6AAAAAAW2BI2K4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Description
Provide
DISCOVERY_MODE
option tocatch_discover_tests
to allow forPRE_TEST
discovery mode.Cf. details in commit msg-es.
This change follows closely the corresponding functionality / changes in the GoogleTest counterpart to maintain the convenient similarity to
gtest_discover_tests()
and friends.GitHub Issues
Closes #2493