diff --git a/cmake/coveralls.cmake b/cmake/coveralls.cmake index aad02d24be15535d65f4ac0d0db58fa3cd85c3bf..36a56044fbfcfb2b6572dd4aef58b80bedfb185d 100644 --- a/cmake/coveralls.cmake +++ b/cmake/coveralls.cmake @@ -62,7 +62,15 @@ function(code_coverage _COVERAGE_SRCS _COVERALLS_UPLOAD _CMAKE_SCRIPT_PATH) endfunction() if(WITH_COVERAGE) - if (NOT ("$ENV{PADDLE_GIT_DIFF_H_FILE}" STREQUAL "")) + if (WITH_INCREMENTAL_COVERAGE) + # if *.h changed, generate coverage report totaly. + # if pybind.cc changed, generate coverage report totaly. + # Because if pybind.cc add '-g -O0 -fprofile-arcs -ftest-coverage' only, some testcase will fail. + if ( (NOT ("$ENV{PADDLE_GIT_DIFF_H_FILE}" STREQUAL "")) OR ("$ENV{PADDLE_GIT_DIFF_CC_FILE}" MATCHES "pybind.cc") ) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage") + endif() + else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage") endif() diff --git a/cmake/generic.cmake b/cmake/generic.cmake index 51cbc534e46a3423f0c4f3f51c5dd25d08b42644..8e1e2f460f4960ec8d4265a06cd57b5aa43017d8 100644 --- a/cmake/generic.cmake +++ b/cmake/generic.cmake @@ -267,8 +267,9 @@ function(merge_static_libs TARGET_NAME) endfunction(merge_static_libs) function(check_coverage_opt TARGET_NAME SRCS) - if(WITH_COVERAGE) - if ("$ENV{PADDLE_GIT_DIFF_H_FILE}" STREQUAL "") + if(WITH_COVERAGE AND WITH_INCREMENTAL_COVERAGE) + # if pybind.cc add '-g -O0 -fprofile-arcs -ftest-coverage' only, some testcase will fail. + if ("$ENV{PADDLE_GIT_DIFF_H_FILE}" STREQUAL "" AND (NOT ("$ENV{PADDLE_GIT_DIFF_CC_FILE}" MATCHES "pybind.cc"))) if (NOT ("$ENV{PADDLE_GIT_DIFF_CC_FILE}" STREQUAL "")) string(REPLACE "," ";" CC_FILE_LIST $ENV{PADDLE_GIT_DIFF_CC_FILE}) set(use_coverage_opt FALSE)