Catch2 icon indicating copy to clipboard operation
Catch2 copied to clipboard

`catch_discover_tests` pass `<target>_TESTS` variable to `PARENT_SCOPE`

Open david-fong opened this issue 3 years ago • 0 comments

Description

The following documentation is for the TEST_LIST option for catch_discover_tests from cmake-integration.md#customization (italics added):

Make the list of tests available in the variable var, rather than the default <target>_TESTS. This can be useful when the same test executable is being used in multiple calls to catch_discover_tests(). Note that this variable is only available in CTest.

I would like to be able to use this variable in CMake to register "dependencies" between tests. See this article by Craig Scott for more information

Additional context

The motivation for my usage of CMake's test fixture mechanism as described in Craig's article is that I have a library that has layers of abstraction that build upon each other, where tests for the the higher level abstractions are expensive to run, while the lower levels are comparatively much cheaper to run, so I want to test the lower layers first and short-circuit the rest of the higher layer tests if they fail. There are other good reasons to use CMake's test fixture feature. Mine is only one of them.

david-fong avatar Aug 03 '22 04:08 david-fong

I have realized two things:

  1. This probably wouldn't be as simple to implement as I naively thought. I thought it would be as simple as doing a set(... PARENT_SCOPE), but the value of TEST_LIST is generated by invoking cmake as a subprocess.

  2. I actually don't need this change. I can set up the FIXTURE properties in the call to catch_discover_tests.

Sorry for the false alarm and thanks for your work on this project! Closing this issue now.

david-fong avatar Aug 16 '22 19:08 david-fong