FIXTURES_CLEANUP.rst 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. FIXTURES_CLEANUP
  2. ----------------
  3. Specifies a list of fixtures for which the test is to be treated as a cleanup
  4. test.
  5. Fixture cleanup tests are ordinary tests with all of the usual test
  6. functionality. Setting the ``FIXTURES_CLEANUP`` property for a test has two
  7. primary effects:
  8. - CTest will ensure the test executes after all other tests which list any of
  9. the fixtures in its :prop_test:`FIXTURES_REQUIRED` property.
  10. - If CTest is asked to run only a subset of tests (e.g. using regular
  11. expressions or the ``--rerun-failed`` option) and the cleanup test is not in
  12. the set of tests to run, it will automatically be added if any tests in the
  13. set require any fixture listed in ``FIXTURES_CLEANUP``.
  14. A cleanup test can have multiple fixtures listed in its ``FIXTURES_CLEANUP``
  15. property. It will execute only once for the whole CTest run, not once for each
  16. fixture. A fixture can also have more than one cleanup test defined. If there
  17. are multiple cleanup tests for a fixture, projects can control their order with
  18. the usual :prop_test:`DEPENDS` test property if necessary.
  19. A cleanup test is allowed to require other fixtures, but not any fixture listed
  20. in its ``FIXTURES_CLEANUP`` property. For example:
  21. .. code-block:: cmake
  22. # Ok: Dependent fixture is different to cleanup
  23. set_tests_properties(cleanupFoo PROPERTIES
  24. FIXTURES_CLEANUP Foo
  25. FIXTURES_REQUIRED Bar
  26. )
  27. # Error: cannot require same fixture as cleanup
  28. set_tests_properties(cleanupFoo PROPERTIES
  29. FIXTURES_CLEANUP Foo
  30. FIXTURES_REQUIRED Foo
  31. )
  32. Cleanup tests will execute even if setup or regular tests for that fixture fail
  33. or are skipped.
  34. See :prop_test:`FIXTURES_REQUIRED` for a more complete discussion of how to use
  35. test fixtures.