Parsing --list-tests is broken, as Catch automatically line wraps the
line when it gets too long, stripping any whitespace in the process.
This means that it's impossible to reproduce the exact name of the
test if the test's name is long enough to line-wrap.
Furthermore, overwriting the LABELS property with the discovered labels
breaks users who manually added custom ctest labels.
Rolling back to using --list-test-names-only for now, as it does not
wrap lines even on very long test names.
We may be able parse the output of --list-tags to produce the ctest labels.
However, the straightforward way of doing this is to use CMake's
get_property(TEST ...) and set_property(TEST ... APPEND ...), which don't
work if the test name has spaces or other special characters. We would
need to mangle the test name to a valid CMake identifier to do it that way.
After the script, the ParseAndAddCatchTests_TESTS property for the
target, and for each source file in the target is set, and contains the
list of the tests extracted from that target, or from that file.
This is useful, for example to add further labels or properties to the
tests.
When PARSE_CATCH_TESTS_ADD_TARGET_IN_TEST_NAME is enabled the cmake helper script fails to extract the testcase name if a whitespace is before the name string. Use regex to consider and remove this whitespace.
fix by Mike-Devel
fixes: https://github.com/catchorg/Catch2/issues/1493
If this option is enabled and PARSE_CATCH_TESTS_NO_HIDDEN_TESTS option is disabled, the test is be added, but the DISABLED property is set, therefore CTest shows it as "Not Run (Disabled)" instead of "Passed"
This variable is set to allow the use of the nice ParseAndAddCatchTests script
in the case where a launcher is needed to execute the script.
This is introduced to allow to launch unit tests using mpi. In this case one can
write for instance
set(OptionalCatchTestLauncher ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${NUMPROC})
before calling the ParseAndAddCatchTests function.
The commands provided have to be executed in the current gdb/lldb session or copied
into the users ~/.gdbinit ~/.lldbinit files to permanently skip debugging Catch code.
Fixes#904
If source files are defined using relative paths, CMake will compile the tests, but this script will (sometimes) fail to find and parse the tests from the source files. I have added an explicit warning when ParseAndAddCatchTests fails to find a source file.
Added cmake script to parse the source files containing Catch's test and generate ctest definitions.
It generates one ctest test per `TEST_CASE` and labels them, using the `TEST_CASE`'s tags.
Closes#719.