Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

436
Visualizações
CMake and CTest: automatically run test's dependencies

In my CMakeLists.txt I have something like this:

 set_property(TEST testX APPEND PROPERTY DEPENDS testY)
 set_property(TEST testX APPEND PROPERTY DEPENDS testZ)

And I want some way to run testX and all its dependencies automatically. Something like:

ctest <options> testX

and as a result, CTest will run textY, testZ and testX. Is there any way to do this?

Or, if it is impossible now, is there any way to extract information on the dependencies from the CMake build directory by script?

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

There's no built-in way of doing this as far as I know.

The best way I can think of to achieve your goal is to use the LABELS property on the tests. You can retrieve the list of dependencies using get_property or get_test_property and apply the same label to testX and each of its dependent tests:

get_test_property(testX DEPENDS DependenciesOfTestX)
set_tests_properties(testX ${DependenciesOfTestX} PROPERTIES LABELS LabelX)

Then you can tell CTest to only run tests with that label:

ctest -L LabelX
over 4 years ago · Santiago Trujillo Relatório

0

Support for test fixtures was added in CMake 3.7 and they do exactly what you want. Your particular scenario would be implemented like this:

set_property(TEST testX PROPERTY FIXTURES_REQUIRED Foo)
set_property(TEST testY PROPERTY FIXTURES_SETUP Foo)
set_property(TEST testZ PROPERTY FIXTURES_SETUP Foo)

You can then ask ctest to run just testX and it will automatically add testY and testZ to the set of tests to be executed:

ctest -R testX

It will also ensure that testX will only run after testY and testZ have been passed. If either of testY or testZ fails, testX will be skipped. New options -FS, -FC and -FA were also added to ctest in CMake 3.9 which allow automatic adding fixture setup/cleanup tests to be controlled at the ctest command line. For example, to temporarily skip adding testY to the test set but still automatically add testZ, one could do this:

ctest -R testX -FS testY

The fixtures properties are described in the CMake docs and the following article covers the fixtures feature more comprehensively:

https://crascit.com/2016/10/18/test-fixtures-with-cmake-ctest/

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda