If you need more flexibility, you can use the test properties PASS_REGULAR_EXPRESSION and FAIL_REGULAR_EXPRESSION in combination with set_tests_properties. If these are set, the test output will be checked against a list of regular expressions given as arguments, and, if at least one of the regular expressions matches, the test either passes or fails, respectively. Many other properties can be set on tests. A full list of available properties can be found at https://cmake.org/cmake/help/v3.5/manual/cmake-properties.7.html#properties-on-tests.