catch_discover_tests doesn't use the same environment to discover tests through TEST_EXECUTABLE
- Dominant language
- C++
- Stars
- 21.5k
- Forks
- 3.5k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 2
Description
**Describe the bug**
Using `cmake` to build my application and `catch_discover_tests` to find all the `catch` tests defined, I came across the following issue.
While it's possible to set `PROPERTIES` in `catch_discover_tests` that will be used to run the tests with, those same properties are not passed to the [`process`](https://github.com/catchorg/Catch2/blob/9a8963133fb7ce9ce31802160d8e351e0ac5527c/contrib/CatchAddTests.cmake#L31) that runs the test executable to parse the various tests defined in the application.
**Expected behavior**
I would expect that the same environment would be used to run the test executable to find out which tests to run and to actually run the tests.
**Reproduction steps**
`catch_discover_tests(${test_name} TEST_PREFIX "${test_name}/" PROPERTIES ENVIRONMENT "TEST_ENV_VAR=MY_VAR")`
**Platform information:**
- OS: **Linux**
- Compiler+version: **GCC v7.4.0,8.2.0/clang 8**
- Catch version: **master brach**
- Cmake version: **3.10.2**
**Supplementary information:**
I would like to be able to set one or more environment variables to a specific value for the tests only, without having to manually set it through the command line before compiling the application to run every invocation of the application executable with the same environment.
Contributor guide
Assessment
This issue has not been assessed yet.