summaryrefslogtreecommitdiff
path: root/contrib/CatchAddTests.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/CatchAddTests.cmake')
-rw-r--r--contrib/CatchAddTests.cmake69
1 files changed, 22 insertions, 47 deletions
diff --git a/contrib/CatchAddTests.cmake b/contrib/CatchAddTests.cmake
index ca5ebc17..156d55ff 100644
--- a/contrib/CatchAddTests.cmake
+++ b/contrib/CatchAddTests.cmake
@@ -22,39 +22,6 @@ function(add_command NAME)
set(script "${script}${NAME}(${_args})\n" PARENT_SCOPE)
endfunction()
-macro(_add_catch_test_labels LINE)
- # convert to list of tags
- string(REPLACE "][" "]\\;[" tags ${line})
-
- add_command(
- set_tests_properties "${prefix}${test}${suffix}"
- PROPERTIES
- LABELS "${tags}"
- )
-endmacro()
-
-macro(_add_catch_test LINE)
- set(test ${line})
- # use escape commas to handle properly test cases with commans inside the name
- string(REPLACE "," "\\," test_name ${test})
- # ...and add to script
- add_command(
- add_test "${prefix}${test}${suffix}"
- ${TEST_EXECUTOR}
- "${TEST_EXECUTABLE}"
- "${test_name}"
- ${extra_args}
- )
-
- add_command(
- set_tests_properties "${prefix}${test}${suffix}"
- PROPERTIES
- WORKING_DIRECTORY "${TEST_WORKING_DIR}"
- ${properties}
- )
- list(APPEND tests "${prefix}${test}${suffix}")
-endmacro()
-
# Run test executable to get list of available tests
if(NOT EXISTS "${TEST_EXECUTABLE}")
message(FATAL_ERROR
@@ -62,7 +29,7 @@ if(NOT EXISTS "${TEST_EXECUTABLE}")
)
endif()
execute_process(
- COMMAND ${TEST_EXECUTOR} "${TEST_EXECUTABLE}" ${spec} --list-tests
+ COMMAND ${TEST_EXECUTOR} "${TEST_EXECUTABLE}" ${spec} --list-test-names-only
OUTPUT_VARIABLE output
RESULT_VARIABLE result
)
@@ -80,22 +47,30 @@ elseif(${result} LESS 0)
endif()
string(REPLACE "\n" ";" output "${output}")
-set(test)
-set(tags_regex "(\\[([^\\[]*)\\])+$")
# Parse output
foreach(line ${output})
- # lines without leading whitespaces are catch output not tests
- if(${line} MATCHES "^[ \t]+")
- # strip leading spaces and tabs
- string(REGEX REPLACE "^[ \t]+" "" line ${line})
-
- if(${line} MATCHES "${tags_regex}")
- _add_catch_test_labels(${line})
- else()
- _add_catch_test(${line})
- endif()
- endif()
+ set(test ${line})
+ # Escape characters in test case names that would be parsed by Catch2
+ set(test_name ${test})
+ foreach(char , [ ])
+ string(REPLACE ${char} "\\${char}" test_name ${test_name})
+ endforeach(char)
+ # ...and add to script
+ add_command(add_test
+ "${prefix}${test}${suffix}"
+ ${TEST_EXECUTOR}
+ "${TEST_EXECUTABLE}"
+ "${test_name}"
+ ${extra_args}
+ )
+ add_command(set_tests_properties
+ "${prefix}${test}${suffix}"
+ PROPERTIES
+ WORKING_DIRECTORY "${TEST_WORKING_DIR}"
+ ${properties}
+ )
+ list(APPEND tests "${prefix}${test}${suffix}")
endforeach()
# Create a list of all discovered tests, which users may use to e.g. set