SKIP_REGULAR_EXPRESSION — CMake 3.30.5 Documentation

# SKIP_REGULAR_EXPRESSION

New in version 3.16.

If the test output (stderr or stdout) matches this regular expression the test will be marked as skipped, regardless of the process exit code. Tests that exceed the timeout specified by `TIMEOUT` still fail regardless of `SKIP_REGULAR_EXPRESSION`. System-level test failures including segmentation faults, signal abort, or heap errors may fail the test even if the regular expression matches.

Example:

    add_test(NAME mytest COMMAND ${CMAKE_COMMAND} -E echo "Skipped this test")

    set_property(TEST mytest PROPERTY
      SKIP_REGULAR_EXPRESSION "[^a-z]Skip" "SKIP" "Skipped"
    )

`SKIP_REGULAR_EXPRESSION` expects a list of regular expressions.

To run a test that may have a system-level failure, but still skip if `SKIP_REGULAR_EXPRESSION` matches, use a CMake command to wrap the executable run. Note that this will prevent automatic handling of the `CROSSCOMPILING_EMULATOR` and `TEST_LAUNCHER` target property.

    add_executable(main main.c)

    add_test(NAME sigabrt COMMAND ${CMAKE_COMMAND} -E env $<TARGET_FILE:main>)

    set_property(TEST sigabrt PROPERTY SKIP_REGULAR_EXPRESSION "SIGABRT;[aA]bort")

    #include <signal.h>

    int main(void){ raise(SIGABRT); return 0; }

See also the `SKIP_RETURN_CODE`, `PASS_REGULAR_EXPRESSION`, and `FAIL_REGULAR_EXPRESSION` test properties.