TIMEOUT_AFTER_MATCH.rst 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. TIMEOUT_AFTER_MATCH
  2. -------------------
  3. .. versionadded:: 3.6
  4. Change a test's timeout duration after a matching line is encountered
  5. in its output.
  6. Usage
  7. ^^^^^
  8. .. code-block:: cmake
  9. add_test(mytest ...)
  10. set_property(TEST mytest PROPERTY TIMEOUT_AFTER_MATCH "${seconds}" "${regex}")
  11. Description
  12. ^^^^^^^^^^^
  13. Allow a test ``seconds`` to complete after ``regex`` is encountered in
  14. its output.
  15. When the test outputs a line that matches ``regex`` its start time is
  16. reset to the current time and its timeout duration is changed to
  17. ``seconds``. Prior to this, the timeout duration is determined by the
  18. :prop_test:`TIMEOUT` property or the :variable:`CTEST_TEST_TIMEOUT`
  19. variable if either of these are set. Because the test's start time is
  20. reset, its execution time will not include any time that was spent
  21. waiting for the matching output.
  22. ``TIMEOUT_AFTER_MATCH`` is useful for avoiding spurious
  23. timeouts when your test must wait for some system resource to become
  24. available before it can execute. Set :prop_test:`TIMEOUT` to a longer
  25. duration that accounts for resource acquisition and use
  26. ``TIMEOUT_AFTER_MATCH`` to control how long the actual test
  27. is allowed to run.
  28. If the required resource can be controlled by CTest you should use
  29. :prop_test:`RESOURCE_LOCK` instead of ``TIMEOUT_AFTER_MATCH``.
  30. This property should be used when only the test itself can determine
  31. when its required resources are available.