REQUIRED_FILES.rst 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. REQUIRED_FILES
  2. --------------
  3. List of files required to run the test. The filenames are relative to the
  4. test :prop_test:`WORKING_DIRECTORY` unless an absolute path is specified.
  5. If set to a list of files, the test will not be run unless all of the
  6. files exist.
  7. Examples
  8. ~~~~~~~~
  9. Suppose that ``test.txt`` is created by test ``baseTest`` and ``none.txt``
  10. does not exist:
  11. .. code-block:: cmake
  12. add_test(NAME baseTest ...) # Assumed to create test.txt
  13. add_test(NAME fileTest ...)
  14. # The following ensures that if baseTest is successful, test.txt will
  15. # have been created before fileTest is run
  16. set_tests_properties(fileTest PROPERTIES
  17. DEPENDS baseTest
  18. REQUIRED_FILES test.txt
  19. )
  20. add_test(NAME notRunTest ...)
  21. # The following makes notRunTest depend on two files. Nothing creates
  22. # the none.txt file, so notRunTest will fail with status "Not Run".
  23. set_tests_properties(notRunTest PROPERTIES
  24. REQUIRED_FILES "test.txt;none.txt"
  25. )
  26. The above example demonstrates how ``REQUIRED_FILES`` works, but it is not the
  27. most robust way to implement test ordering with failure detection. For that,
  28. test fixtures are a better alternative (see :prop_test:`FIXTURES_REQUIRED`).