WILL_FAIL.rst 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. WILL_FAIL
  2. ---------
  3. If ``true``, inverts the pass / fail test criteria. Tests for which
  4. ``WILL_FAIL`` is ``true`` fail with return code 0 and pass with non-zero
  5. return code. Tests that exceed the timeout specified by :prop_test:`TIMEOUT`
  6. still fail regardless of ``WILL_FAIL``.
  7. System-level test failures including segmentation faults,
  8. signal abort, or heap errors may fail the test even if ``WILL_FAIL`` is true.
  9. Example of a test that would ordinarily pass, but fails because ``WILL_FAIL``
  10. is ``true``:
  11. .. code-block:: cmake
  12. add_test(NAME failed COMMAND ${CMAKE_COMMAND} -E true)
  13. set_property(TEST failed PROPERTY WILL_FAIL true)
  14. To run a test that may have a system-level failure, but still pass if
  15. ``WILL_FAIL`` is set, use a CMake command to wrap the executable run.
  16. Note that this will prevent automatic handling of the
  17. :prop_tgt:`CROSSCOMPILING_EMULATOR` and :prop_tgt:`TEST_LAUNCHER`
  18. target property.
  19. .. code-block:: cmake
  20. add_executable(main main.c)
  21. add_test(NAME sigabrt COMMAND ${CMAKE_COMMAND} -E env $<TARGET_FILE:main>)
  22. set_property(TEST sigabrt PROPERTY WILL_FAIL TRUE)
  23. .. code-block:: c
  24. #include <signal.h>
  25. int main(void){ raise(SIGABRT); return 0; }