|
|
@@ -6,6 +6,8 @@ set(suffix "${TEST_SUFFIX}")
|
|
|
set(spec ${TEST_SPEC})
|
|
|
set(extra_args ${TEST_EXTRA_ARGS})
|
|
|
set(properties ${TEST_PROPERTIES})
|
|
|
+set(add_labels ${TEST_ADD_LABELS})
|
|
|
+set(junit_output_dir "${TEST_JUNIT_OUTPUT_DIR}")
|
|
|
set(script)
|
|
|
set(suite)
|
|
|
set(tests)
|
|
|
@@ -37,6 +39,7 @@ execute_process(
|
|
|
COMMAND ${TEST_EXECUTOR} "${TEST_EXECUTABLE}" ${spec} --list-test-cases
|
|
|
OUTPUT_VARIABLE output
|
|
|
RESULT_VARIABLE result
|
|
|
+ WORKING_DIRECTORY "${TEST_WORKING_DIR}"
|
|
|
)
|
|
|
if(NOT ${result} EQUAL 0)
|
|
|
message(FATAL_ERROR
|
|
|
@@ -54,6 +57,39 @@ foreach(line ${output})
|
|
|
continue()
|
|
|
endif()
|
|
|
set(test ${line})
|
|
|
+ set(labels "")
|
|
|
+ if(${add_labels})
|
|
|
+ # get test suite that test belongs to
|
|
|
+ execute_process(
|
|
|
+ COMMAND ${TEST_EXECUTOR} "${TEST_EXECUTABLE}" --test-case=${test} --list-test-suites
|
|
|
+ OUTPUT_VARIABLE labeloutput
|
|
|
+ RESULT_VARIABLE labelresult
|
|
|
+ WORKING_DIRECTORY "${TEST_WORKING_DIR}"
|
|
|
+ )
|
|
|
+ if(NOT ${labelresult} EQUAL 0)
|
|
|
+ message(FATAL_ERROR
|
|
|
+ "Error running test executable '${TEST_EXECUTABLE}':\n"
|
|
|
+ " Result: ${labelresult}\n"
|
|
|
+ " Output: ${labeloutput}\n"
|
|
|
+ )
|
|
|
+ endif()
|
|
|
+
|
|
|
+ string(REPLACE "\n" ";" labeloutput "${labeloutput}")
|
|
|
+ foreach(labelline ${labeloutput})
|
|
|
+ if("${labelline}" STREQUAL "===============================================================================" OR "${labelline}" MATCHES [==[^\[doctest\] ]==])
|
|
|
+ continue()
|
|
|
+ endif()
|
|
|
+ list(APPEND labels ${labelline})
|
|
|
+ endforeach()
|
|
|
+ endif()
|
|
|
+
|
|
|
+ if(NOT "${junit_output_dir}" STREQUAL "")
|
|
|
+ # turn testname into a valid filename by replacing all special characters with "-"
|
|
|
+ string(REGEX REPLACE "[/\\:\"|<>]" "-" test_filename "${test}")
|
|
|
+ set(TEST_JUNIT_OUTPUT_PARAM "--reporters=junit" "--out=${junit_output_dir}/${prefix}${test_filename}${suffix}.xml")
|
|
|
+ else()
|
|
|
+ unset(TEST_JUNIT_OUTPUT_PARAM)
|
|
|
+ endif()
|
|
|
# use escape commas to handle properly test cases with commas inside the name
|
|
|
string(REPLACE "," "\\," test_name ${test})
|
|
|
# ...and add to script
|
|
|
@@ -62,6 +98,7 @@ foreach(line ${output})
|
|
|
${TEST_EXECUTOR}
|
|
|
"${TEST_EXECUTABLE}"
|
|
|
"--test-case=${test_name}"
|
|
|
+ "${TEST_JUNIT_OUTPUT_PARAM}"
|
|
|
${extra_args}
|
|
|
)
|
|
|
add_command(set_tests_properties
|
|
|
@@ -69,7 +106,9 @@ foreach(line ${output})
|
|
|
PROPERTIES
|
|
|
WORKING_DIRECTORY "${TEST_WORKING_DIR}"
|
|
|
${properties}
|
|
|
+ LABELS ${labels}
|
|
|
)
|
|
|
+ unset(labels)
|
|
|
list(APPEND tests "${prefix}${test}${suffix}")
|
|
|
endforeach()
|
|
|
|