diff options
| author | Arne Mertz | 2023-04-04 16:48:39 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2023-04-05 10:12:50 +0200 |
| commit | 50bf00e266b32531385c9098f2676875c0aa8ac2 (patch) | |
| tree | bd89bfcaf025db5a035a5a6055acade40180e888 | |
| parent | 9f08097f55eb29a61efcdb4af41952a67e155215 (diff) | |
| download | catch3-50bf00e266b32531385c9098f2676875c0aa8ac2.tar.gz | |
Fix reporter detection in catch_discover_tests
Closes #2668
Instead of grepping for the reporter, use it in the process and check for the error code
| -rw-r--r-- | extras/Catch.cmake | 2 | ||||
| -rw-r--r-- | extras/CatchAddTests.cmake | 42 |
2 files changed, 22 insertions, 22 deletions
diff --git a/extras/Catch.cmake b/extras/Catch.cmake index bc553591..8e712b77 100644 --- a/extras/Catch.cmake +++ b/extras/Catch.cmake @@ -35,7 +35,7 @@ same as the Catch name; see also ``TEST_PREFIX`` and ``TEST_SUFFIX``. [TEST_LIST var] [REPORTER reporter] [OUTPUT_DIR dir] - [OUTPUT_PREFIX prefix} + [OUTPUT_PREFIX prefix] [OUTPUT_SUFFIX suffix] ) diff --git a/extras/CatchAddTests.cmake b/extras/CatchAddTests.cmake index beec3aed..2df663dc 100644 --- a/extras/CatchAddTests.cmake +++ b/extras/CatchAddTests.cmake @@ -66,30 +66,30 @@ endif() string(REPLACE "\n" ";" output "${output}") -# Run test executable to get list of available reporters -execute_process( - COMMAND ${TEST_EXECUTOR} "${TEST_EXECUTABLE}" ${spec} --list-reporters - OUTPUT_VARIABLE reporters_output - RESULT_VARIABLE reporters_result - WORKING_DIRECTORY "${TEST_WORKING_DIR}" -) -if(NOT ${reporters_result} EQUAL 0) - message(FATAL_ERROR - "Error running test executable '${TEST_EXECUTABLE}':\n" - " Result: ${reporters_result}\n" - " Output: ${reporters_output}\n" - ) -endif() -string(FIND "${reporters_output}" "${reporter}" reporter_is_valid) -if(reporter AND ${reporter_is_valid} EQUAL -1) - message(FATAL_ERROR - "\"${reporter}\" is not a valid reporter!\n" - ) -endif() - # Prepare reporter if(reporter) set(reporter_arg "--reporter ${reporter}") + + # Run test executable to check whether reporter is available + # note that the use of --list-reporters is not the important part, + # we only want to check whether the execution succeeds with ${reporter_arg} + execute_process( + COMMAND ${TEST_EXECUTOR} "${TEST_EXECUTABLE}" ${spec} ${reporter_arg} --list-reporters + OUTPUT_VARIABLE reporter_check_output + RESULT_VARIABLE reporter_check_result + WORKING_DIRECTORY "${TEST_WORKING_DIR}" + ) + if(${reporter_check_result} EQUAL 255) + message(FATAL_ERROR + "\"${reporter}\" is not a valid reporter!\n" + ) + elseif(NOT ${reporter_check_result} EQUAL 0) + message(FATAL_ERROR + "Error running test executable '${TEST_EXECUTABLE}':\n" + " Result: ${reporter_check_result}\n" + " Output: ${reporter_check_output}\n" + ) + endif() endif() # Prepare output dir |