I have a test fixture for starting a database server:
# pg_setup.cmake
add_test(NAME setupPostgres COMMAND /path/to/pg-setup)
add_test(NAME teardownPostgres COMMAND /path/to/pg-teardown)
set_tests_properties(setupPostgres PROPERTIES FIXTURES_SETUP postgresFixture)
set_tests_properties(teardownPostgres PROPERTIES FIXTURES_CLEANUP postgresFixture)
and several other tests that use the fixture, like this:
include(pg_setup)
add_test(NAME foo ...)
set_tests_properties(foo PROPERTIES FIXTURES_REQUIRED postgresFixture)
These tests are in different directories, sprinkled throughout a large source tree, with multiple CMakeLists.txt
files defining tests that depend on postgresFixture
in this way.
When I run ctest
in one of these directories, things work as expected:
-
setupPostgres
runs before all tests that require it -
teardownPostgres
runs after all tests that require it - All tests in between run in parallel when I use
--parallel
However, when I run ctest
at the top level, I see multiple instances of setupPostgres
running in parallel, which is not what I want. How can I avoid this?