From dbbfbccd1a33be09517eb208f092af6154ff230d Mon Sep 17 00:00:00 2001 From: wanghuancoder Date: Tue, 19 Jan 2021 21:31:22 +0800 Subject: [PATCH] [cherry pick]if pybind.cc changed, generate total report (#30557) * if pybind.cc changed, generate total report --- cmake/coveralls.cmake | 10 +++++++++- cmake/generic.cmake | 5 +++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/cmake/coveralls.cmake b/cmake/coveralls.cmake index aad02d24be..36a56044fb 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 51cbc534e4..8e1e2f460f 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) -- GitLab