SKIP_REGULAR_EXPRESSION.rst 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. SKIP_REGULAR_EXPRESSION
  2. -----------------------
  3. .. versionadded:: 3.16
  4. If the test output (stderr or stdout) matches this regular expression the test
  5. will be marked as skipped, regardless of the process exit code. Tests that
  6. exceed the timeout specified by :prop_test:`TIMEOUT` still fail regardless of
  7. ``SKIP_REGULAR_EXPRESSION``. System-level test failures including segmentation
  8. faults, signal abort, or heap errors may fail the test even if the regular
  9. expression matches.
  10. Example:
  11. .. code-block:: cmake
  12. add_test(NAME mytest COMMAND ${CMAKE_COMMAND} -E echo "Skipped this test")
  13. set_property(TEST mytest PROPERTY
  14. SKIP_REGULAR_EXPRESSION "[^a-z]Skip" "SKIP" "Skipped"
  15. )
  16. ``SKIP_REGULAR_EXPRESSION`` expects a list of regular expressions.
  17. To run a test that may have a system-level failure, but still skip if
  18. ``SKIP_REGULAR_EXPRESSION`` matches, use a CMake command to wrap the
  19. executable run. Note that this will prevent automatic handling of the
  20. :prop_tgt:`CROSSCOMPILING_EMULATOR` and :prop_tgt:`TEST_LAUNCHER`
  21. target property.
  22. .. code-block:: cmake
  23. add_executable(main main.c)
  24. add_test(NAME sigabrt COMMAND ${CMAKE_COMMAND} -E env $<TARGET_FILE:main>)
  25. set_property(TEST sigabrt PROPERTY SKIP_REGULAR_EXPRESSION "SIGABRT;[aA]bort")
  26. .. code-block:: c
  27. #include <signal.h>
  28. int main(void){ raise(SIGABRT); return 0; }
  29. See also the :prop_test:`SKIP_RETURN_CODE`,
  30. :prop_test:`PASS_REGULAR_EXPRESSION`, and :prop_test:`FAIL_REGULAR_EXPRESSION`
  31. test properties.