Commit Graph

30 Commits

Author SHA1 Message Date
Reinhold Gschweicher
69297ceeb6
Consider CMP0110 add_test() policy
CMake 3.19 introduces new add_test() behavior guarded with the policy
CMP0110.

See: https://cmake.org/cmake/help/latest/policy/CMP0110.html

Update the helper script ParseAndAddCatchTests to consider the policy and
handle the test case name accordingly.
2020-10-20 23:25:45 +02:00
Reinhold Gschweicher
2d30df3500 Fix indentation in ParseAndAddCatchTests
Consistently use 4 spaces instead of tabs
2020-10-20 13:48:46 +02:00
Reinhold Gschweicher
77b2a7daea Fix CMake regex to add tests
Fix regex that requires two string arguments in the form of
TEST_CASE("a", "b") resulting in not finding TEST_CASE("a") entries.

See https://regex101.com/r/JygOND/1

Fixes: https://github.com/catchorg/Catch2/issues/2055
2020-10-20 13:48:14 +02:00
Ansel Sermersheim
3e8800beb1 Support template test cases in ParseAndAddCatchTests
* Change regex to allow parentheses inside the test macro for a type list
* Append a wildcard to the CTestName if the test case is a template
* Also change the regular expression so parentheses are allowed in names
  (fixes #1848)
2020-09-24 22:42:32 +02:00
Karthik Nishanth
de3a208e16 Update ParseAndAddCatchTests.cmake 2020-08-01 19:40:29 +02:00
Reinhold Gschweicher
229cc4823c Fix CMake add test helper for CMake 3.18.0
With CMake 3.18.0 the `add_test(NAME)` handling changed. The escaped
double quotes confuse the new call. Work around this upstream change.

fixes: https://github.com/catchorg/Catch2/issues/1984
2020-07-17 23:56:33 +02:00
Invincible
01bdfe3312 Change PARSE_CATCH_TESTS_ADD_FIXTURE_IN_TEST_NAME conditional.
When no TEST_CASE_METHOD function, there is no fixture to get.
2020-03-27 09:55:06 +01:00
Martin Luelf
ac94bd0520 ParseAndAddCatchTests: Ignore cmake object libraries 2019-04-14 19:10:15 +02:00
Daniele E. Domenichelli
1e2270b370 ParseAndAddCatchTests: Do not change CMAKE_MINIMUM_REQUIRED_VERSION when included 2019-04-10 10:50:13 +02:00
Daniele E. Domenichelli
5096e39297 ParseAndAddCatchTests: Add scope to functions in order to avoid name collisions 2019-04-10 10:50:13 +02:00
Daniele E. Domenichelli
15ccced6da ParseAndAddCatchTests: Document AdditionalCatchParameters variable 2019-04-10 10:50:13 +02:00
Daniele E. Domenichelli
682617b5b7 ParseAndAddCatchTests: Fix tests not found
When using an optional launcher the target name is not interpreted as a
target, therefore it is not replaced automatically with its path.
2019-04-10 10:50:13 +02:00
Daniele E. Domenichelli
15150c7b46 ParseAndAddCatchTests: Set the ParseAndAddCatchTests_TESTS property
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.
2019-04-10 10:50:13 +02:00
Stefan Rommel
3079b514d4
IndexOfHideLabel is never used 2019-04-10 08:00:08 +02:00
Martin Hořeňovský
bd667f4d69
Add comma-escaping in test specs to ParseAndAddCatchTests.cmake
Fixes #1527
2019-03-03 13:11:11 +01:00
Martin Hořeňovský
804a2118c2
Merge pull request #1452 from drdanz/ParseAddAndCatchTest_DISABLED
ParseAndAddCatchTests: Add PARSE_CATCH_TESTS_HIDDEN_TESTS_DISABLED option
2019-01-23 15:07:03 +01:00
Martin Hořeňovský
aa1e470058
Merge hidden-test-disabled and hidden-test-hidden 2019-01-23 15:05:33 +01:00
NeroBurner
3ed5441067 fix ctest output with space before name
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
2019-01-10 20:09:00 +01:00
Daniele E. Domenichelli
557e47c3ca ParseAndAddCatchTests: Add PARSE_CATCH_TESTS_HIDDEN_TESTS_DISABLED option
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"
2018-11-21 09:22:17 +01:00
Stephane Del Pino
544c7d7cbf Add the optional variable OptionalCatchTestLauncher
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.
2018-10-25 15:51:15 +02:00
Guillaume Egles
76790604f5 Properly unset tags variable. 2018-07-10 12:48:14 +02:00
dvirtz
664cbf702c added PARSE_CATCH_TESTS_ADD_TO_CONFIGURE_DEPENDS option 2017-10-15 17:58:39 +02:00
Danila Sukharev
ec2074e558 Adding more flexibility into the cmake catch parsing script (#971)
* Adding more flexibility into the cmake catch parsing script
2017-08-01 17:33:53 +02:00
Martin Hořeňovský
377c9a746d Cosmetic fixes (whitespace and spelling) 2017-05-27 14:42:54 +02:00
dvirtz
4b086bd5b5 added target name to test name and labels 2017-05-18 16:00:18 +03:00
dvirtz
aac594aae3 add option to print debug messages 2017-05-18 15:53:35 +03:00
dvirtz
a49fa0edbe use absolute path to test files - accroding to CMake docs EXISTS behavior is well-defined only for full paths. 2017-05-18 15:51:44 +03:00
Benjamin R. Jack
6f012f2d1d Added warning if source file cannot be found
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.
2017-05-01 19:55:17 +02:00
Ernst Maurer
8014bf1124 cmake script to generate ctest definitions from catch tests: fix for test case body bracket 2017-04-24 13:33:04 +02:00
Ernst Maurer
1aa3e4abfa Add CMake script to generate ctest definitions from Catch tests (#879)
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.
2017-04-11 16:51:02 +02:00