11

ラベルの指定方法がわかりません。それは次のようなものでなければなりません

ADD_TEST( FirstTest RunSomeProgram "withArguments" )
SET_TESTS_PROPERTIES( FirstTest PROPERTIES LABEL "TESTLABEL" )

を使用してアクセスできるこれらのラベルの 1 つを設定する方法を教えてください。

ctest -S someScript -L TESTLABEL
4

1 に答える 1

20

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.

于 2014-06-30T23:05:20.467 に答える