I cannot find how to specify labels. It should be something like
ADD_TEST( FirstTest RunSomeProgram "withArguments" )
SET_TESTS_PROPERTIES( FirstTest PROPERTIES LABEL "TESTLABEL" )
Can someone tell me how I can set one of these labels, that I can access using the
ctest -S someScript -L TESTLABEL
Run the tests in parallel using the given number of jobs. This option tells CTest to run the tests in parallel using given number of jobs. This option can also be set by setting the CTEST_PARALLEL_LEVEL environment variable. This option can be used with the PROCESSORS test property.
CTest is an executable that comes with CMake; it handles running the tests for the project. While CTest works well with CMake, you do not have to use CMake in order to use CTest.
enable_testing() Enables testing for this directory and below. This command should be in the source directory root because ctest expects to find a test file in the build directory root. This command is automatically invoked when the CTest module is included, except if the BUILD_TESTING option is turned off.
Options To add_test(...) COMMAND specifies the command to run for the test. Essentially, this can be any command that would normally run in your terminal. You can also pass the name of an executable target, and CMake will replace it with the full location of the executable.
You're close - the test property is named LABELS
, not LABEL
.
There are a couple of ways of setting labels; the one you've chosen (using set_tests_properties
) has a slight gotcha. The signature is:
set_tests_properties(test1 [test2...] PROPERTIES prop1 value1 prop2 value2)
This means that each property can only have a single value applied. So if you want to apply multiple labels to tests this way, you need to "trick" CMake by passing the list of labels as a single string comprising a semi-colon-separated list:
set_tests_properties(FirstTest PROPERTIES LABELS "TESTLABEL;UnitTest;FooModule")
or
set(Labels TESTLABEL UnitTest FooModule)
set_tests_properties(FirstTest PROPERTIES LABELS "${Labels}") # Quotes essential
On the other hand, you can pass a proper list of labels using the more general set_property
command:
set_property(TEST FirstTest PROPERTY LABELS TESTLABEL UnitTest FooModule)
or
set_property(TEST FirstTest PROPERTY LABELS ${Labels}) # No quotes needed
The slight downside of this command is that you can only apply one property per call.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With