mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
add option to print debug messages
This commit is contained in:
parent
a49fa0edbe
commit
aac594aae3
@ -25,10 +25,24 @@
|
|||||||
# #
|
# #
|
||||||
# include(ParseAndAddCatchTests) #
|
# include(ParseAndAddCatchTests) #
|
||||||
# ParseAndAddCatchTests(${PROJECT_NAME}) #
|
# ParseAndAddCatchTests(${PROJECT_NAME}) #
|
||||||
|
# #
|
||||||
|
# The following variables affect the behavior of the script: #
|
||||||
|
# #
|
||||||
|
# PARSE_CATCH_TESTS_VERBOSE (Default OFF) #
|
||||||
|
# -- enabels debug messages #
|
||||||
|
# #
|
||||||
#==================================================================================================#
|
#==================================================================================================#
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 2.8.8)
|
cmake_minimum_required(VERSION 2.8.8)
|
||||||
|
|
||||||
|
option(PARSE_CATCH_TESTS_VERBOSE "Print Catch to CTest parser debug messages" OFF)
|
||||||
|
|
||||||
|
function(PrintDebugMessage)
|
||||||
|
if(PARSE_CATCH_TESTS_VERBOSE)
|
||||||
|
message(STATUS "ParseAndAddCatchTests: ${ARGV}")
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
# This removes the contents between
|
# This removes the contents between
|
||||||
# - block comments (i.e. /* ... */)
|
# - block comments (i.e. /* ... */)
|
||||||
# - full line comments (i.e. // ... )
|
# - full line comments (i.e. // ... )
|
||||||
@ -53,6 +67,7 @@ function(ParseFile SourceFile TestTarget)
|
|||||||
message(WARNING "Cannot find source file: ${SourceFile}")
|
message(WARNING "Cannot find source file: ${SourceFile}")
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
PrintDebugMessage("parsing ${SourceFile}")
|
||||||
file(STRINGS ${SourceFile} Contents NEWLINE_CONSUME)
|
file(STRINGS ${SourceFile} Contents NEWLINE_CONSUME)
|
||||||
|
|
||||||
# Remove block and fullline comments
|
# Remove block and fullline comments
|
||||||
@ -100,6 +115,8 @@ function(ParseFile SourceFile TestTarget)
|
|||||||
string(REPLACE "[" "" Tags "${Tags}")
|
string(REPLACE "[" "" Tags "${Tags}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
PrintDebugMessage("Adding test \"${CTestName}\"")
|
||||||
|
|
||||||
# Add the test and set its properties
|
# Add the test and set its properties
|
||||||
add_test(NAME "\"${CTestName}\"" COMMAND ${TestTarget} ${Name} ${AdditionalCatchParameters})
|
add_test(NAME "\"${CTestName}\"" COMMAND ${TestTarget} ${Name} ${AdditionalCatchParameters})
|
||||||
set_tests_properties("\"${CTestName}\"" PROPERTIES FAIL_REGULAR_EXPRESSION "No tests ran"
|
set_tests_properties("\"${CTestName}\"" PROPERTIES FAIL_REGULAR_EXPRESSION "No tests ran"
|
||||||
@ -110,8 +127,11 @@ endfunction()
|
|||||||
|
|
||||||
# entry point
|
# entry point
|
||||||
function(ParseAndAddCatchTests TestTarget)
|
function(ParseAndAddCatchTests TestTarget)
|
||||||
|
PrintDebugMessage("Started parsing ${TestTarget}")
|
||||||
get_target_property(SourceFiles ${TestTarget} SOURCES)
|
get_target_property(SourceFiles ${TestTarget} SOURCES)
|
||||||
|
PrintDebugMessage("Found the following sources: ${SourceFiles}")
|
||||||
foreach(SourceFile ${SourceFiles})
|
foreach(SourceFile ${SourceFiles})
|
||||||
ParseFile(${SourceFile} ${TestTarget})
|
ParseFile(${SourceFile} ${TestTarget})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
PrintDebugMessage("Finished parsing ${TestTarget}")
|
||||||
endfunction()
|
endfunction()
|
||||||
|
Loading…
Reference in New Issue
Block a user