mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 13:26:10 +01:00
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
This commit is contained in:
parent
9f08097f55
commit
50bf00e266
@ -35,7 +35,7 @@ same as the Catch name; see also ``TEST_PREFIX`` and ``TEST_SUFFIX``.
|
|||||||
[TEST_LIST var]
|
[TEST_LIST var]
|
||||||
[REPORTER reporter]
|
[REPORTER reporter]
|
||||||
[OUTPUT_DIR dir]
|
[OUTPUT_DIR dir]
|
||||||
[OUTPUT_PREFIX prefix}
|
[OUTPUT_PREFIX prefix]
|
||||||
[OUTPUT_SUFFIX suffix]
|
[OUTPUT_SUFFIX suffix]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -66,30 +66,30 @@ endif()
|
|||||||
|
|
||||||
string(REPLACE "\n" ";" output "${output}")
|
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
|
# Prepare reporter
|
||||||
if(reporter)
|
if(reporter)
|
||||||
set(reporter_arg "--reporter ${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()
|
endif()
|
||||||
|
|
||||||
# Prepare output dir
|
# Prepare output dir
|
||||||
|
Loading…
Reference in New Issue
Block a user