-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Enable Code Coverage for Paddle refactor code #3489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
20d9d69
Enable Code Coverage for Paddle refactor code
gangliao 65750d7
add with_coverage in dockerfile
gangliao 0bc7236
add link flags -fprofile-arcs -ftest-coverage for go libs
gangliao 56b1a92
update build.sh
gangliao 070e6fb
Add repo token for uploading coveralls json file
gangliao 378559b
refine json format
gangliao a608d2e
find matched gcov with gcc/clang
gangliao e2f2d14
gcov headcount =====
gangliao 1fa30a6
update
gangliao dd67b24
Add git info into json format
gangliao 643e5a6
format code style
gangliao 621e324
fix JSON_GIT_INFO
gangliao 539c86b
Fix git info json format
gangliao f49fdf2
Add git pull request number to bind coveralls with github
gangliao 8ceee0f
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
gangliao 34b871a
Fix SOURCE NOT AVAILABLE in Coveralls
gangliao ab106ef
Print git info for debug
gangliao 4e99cdc
Disable output info in log for code coverage
gangliao 12178b6
FIX: fetch correct git info to json
gangliao 42651d7
revert git json
gangliao 8892603
refine indent
gangliao 7bbf4c8
git remove optimizer.go
gangliao 3f92fa4
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
gangliao 2563d2b
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
gangliao ca9003e
Generate optimizer.go from optimizer.go.in in Travis CI
gangliao 4db7bf4
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
gangliao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ | |
| # SOFTWARE. | ||
| # | ||
| # Copyright (C) 2014 Joakim Söderberg <[email protected]> | ||
| # Copyright (C) 2017 Gang Liao <[email protected]> | ||
| # | ||
| # This is intended to be run by a custom target in a CMake project like this. | ||
| # 0. Compile program with coverage support. | ||
|
|
@@ -40,14 +41,9 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8) | |
| # CMake list format. | ||
| string(REGEX REPLACE "\\*" ";" COVERAGE_SRCS ${COVERAGE_SRCS}) | ||
|
|
||
| find_program(GCOV_EXECUTABLE gcov) | ||
| if (NOT GCOV_EXECUTABLE) | ||
| message(FATAL_ERROR "gcov not found! Aborting...") | ||
| endif() | ||
|
|
||
| find_package(Git) | ||
|
|
||
| # TODO: Add these git things to the coveralls json. | ||
| if (GIT_FOUND) | ||
| # Branch. | ||
| execute_process( | ||
|
|
@@ -66,20 +62,64 @@ if (GIT_FOUND) | |
| ) | ||
| endmacro() | ||
|
|
||
| git_log_format(an GIT_AUTHOR_EMAIL) | ||
| git_log_format(an GIT_AUTHOR_NAME) | ||
| git_log_format(ae GIT_AUTHOR_EMAIL) | ||
| git_log_format(cn GIT_COMMITTER_NAME) | ||
| git_log_format(ce GIT_COMMITTER_EMAIL) | ||
| git_log_format(B GIT_COMMIT_MESSAGE) | ||
| git_log_format(H GIT_COMMIT_HASH) | ||
| git_log_format(ai GIT_DATE_ISO_8601) | ||
|
|
||
| message("Git exe: ${GIT_EXECUTABLE}") | ||
| message("Git branch: ${GIT_BRANCH}") | ||
| message("Git author: ${GIT_AUTHOR_NAME}") | ||
| message("Git author date: ${GIT_DATE_ISO_8601}") | ||
| message("Git e-mail: ${GIT_AUTHOR_EMAIL}") | ||
| message("Git commiter name: ${GIT_COMMITTER_NAME}") | ||
| message("Git commiter e-mail: ${GIT_COMMITTER_EMAIL}") | ||
| message("Git commit message: ${GIT_COMMIT_MESSAGE}") | ||
| message("Git commit hash: ${GIT_COMMIT_HASH}") | ||
|
|
||
| # | ||
| # Store git commit infomation into coveralls json | ||
| # | ||
| # For example: | ||
| # "git": { | ||
| # "head": { | ||
| # "id": "b31f08d07ae564b08237e5a336e478b24ccc4a65", | ||
| # "author_name": "Nick Merwin", | ||
| # "author_email": "...", | ||
| # "committer_name": "Nick Merwin", | ||
| # "committer_email": "...", | ||
| # "message": "version bump" | ||
| # }, | ||
| # "branch": "master", | ||
| # "remotes": [ | ||
| # { | ||
| # "name": "origin", | ||
| # "url": "[email protected]:lemurheavy/coveralls-ruby.git" | ||
| # } | ||
| # ] | ||
| # }, | ||
| # | ||
|
|
||
| set(JSON_GIT_INFO | ||
| "{ | ||
| \"head\": { | ||
| \"author_name\": \"${GIT_AUTHOR_NAME}\", | ||
| \"author_email\": \"${GIT_AUTHOR_EMAIL}\", | ||
| \"committer_name\": \"${GIT_COMMITTER_NAME}\", | ||
| \"committer_email\": \"${GIT_COMMITTER_EMAIL}\", | ||
| \"message\": \"${GIT_COMMIT_MESSAGE}\" | ||
| }, | ||
| \"branch\": \"${GIT_BRANCH}\", | ||
| \"remotes\": [{ | ||
| \"name\": \"origin\", | ||
| \"url\": \"https://github.com/PaddlePaddle/Paddle.git\" | ||
| }] | ||
| }") | ||
|
|
||
| message("${JSON_GIT_INFO}") | ||
| endif() | ||
|
|
||
| ############################# Macros ######################################### | ||
|
|
@@ -109,9 +149,7 @@ endmacro() | |
| ############################################################################## | ||
|
|
||
| # Get the coverage data. | ||
| file(GLOB_RECURSE GCDA_FILES "${COV_PATH}" "*.gcda") | ||
| message("Process GCDA files:") | ||
| message("===============================") | ||
| file(GLOB_RECURSE GCDA_FILES "${COV_PATH}/*.gcda") | ||
|
|
||
| # Get a list of all the object directories needed by gcov | ||
| # (The directories the .gcda files and .o files are found in) | ||
|
|
@@ -134,13 +172,13 @@ foreach(GCDA ${GCDA_FILES}) | |
| # If -p is not specified then the file is named only "the_file.c.gcov" | ||
| # | ||
| execute_process( | ||
| COMMAND ${GCOV_EXECUTABLE} -p -o ${GCDA_DIR} ${GCDA} >/dev/null | ||
| WORKING_DIRECTORY ${GCDA_DIR} | ||
| COMMAND ${GCOV_EXECUTABLE} -p -o ${GCDA_DIR} ${GCDA} >/dev/null 2>/dev/null | ||
| WORKING_DIRECTORY ${COV_PATH} | ||
| ) | ||
| endforeach() | ||
|
|
||
| # TODO: Make these be absolute path | ||
| file(GLOB_RECURSE ALL_GCOV_FILES "${COV_PATH}" "*.gcov") | ||
| file(GLOB ALL_GCOV_FILES ${COV_PATH}/*.gcov) | ||
|
|
||
| # Get only the filenames to use for filtering. | ||
| #set(COVERAGE_SRCS_NAMES "") | ||
|
|
@@ -189,29 +227,42 @@ foreach (GCOV_FILE ${ALL_GCOV_FILES}) | |
| list(FIND COVERAGE_SRCS ${GCOV_SRC_PATH} WAS_FOUND) | ||
|
|
||
| if (NOT WAS_FOUND EQUAL -1) | ||
| message("YES: ${GCOV_FILE}") | ||
| # message("YES: ${GCOV_FILE}") | ||
| list(APPEND GCOV_FILES ${GCOV_FILE}) | ||
|
|
||
| # We remove it from the list, so we don't bother searching for it again. | ||
| # Also files left in COVERAGE_SRCS_REMAINING after this loop ends should | ||
| # have coverage data generated from them (no lines are covered). | ||
| list(REMOVE_ITEM COVERAGE_SRCS_REMAINING ${GCOV_SRC_PATH}) | ||
| else() | ||
| message("NO: ${GCOV_FILE}") | ||
| # message("NO: ${GCOV_FILE}") | ||
| endif() | ||
| endforeach() | ||
|
|
||
| # TODO: Enable setting these | ||
| set(JSON_SERVICE_NAME "travis-ci") | ||
| set(JSON_SERVICE_JOB_ID $ENV{TRAVIS_JOB_ID}) | ||
|
|
||
| set(JSON_TEMPLATE | ||
| "{ | ||
| \"service_name\": \"\@JSON_SERVICE_NAME\@\", | ||
| \"service_job_id\": \"\@JSON_SERVICE_JOB_ID\@\", | ||
| \"source_files\": \@JSON_GCOV_FILES\@ | ||
| }" | ||
| ) | ||
| if(ON_TRAVIS) | ||
| set(JSON_SERVICE_NAME "travis-ci") | ||
| set(JSON_SERVICE_JOB_ID $ENV{TRAVIS_JOB_ID}) | ||
| set(JSON_TEMPLATE | ||
| "{ | ||
| \"service_name\": \"\@JSON_SERVICE_NAME\@\", | ||
| \"service_job_id\": \"\@JSON_SERVICE_JOB_ID\@\", | ||
| \"git\": ${JSON_GIT_INFO}, | ||
| \"run_at\": \"\@GIT_DATE_ISO_8601\@\", | ||
| \"source_files\": \@JSON_GCOV_FILES\@ | ||
| }") | ||
| else(ON_TRAVIS) | ||
| set(JSON_SERVICE_NAME "teamcity") | ||
| set(JSON_REPO_TOKEN "JSUOs6TF6fD2i30OJ5o2S55V8XWv6euen") | ||
| set(JSON_TEMPLATE | ||
| "{ | ||
| \"repo_token\": \"\@JSON_REPO_TOKEN\@\", | ||
| \"git\": ${JSON_GIT_INFO}, | ||
| \"run_at\": \"\@GIT_DATE_ISO_8601\@\", | ||
| \"service_pull_request\": \"${GIT_PR_ID}\", | ||
| \"service_name\": \"\@JSON_SERVICE_NAME\@\", | ||
| \"source_files\": \@JSON_GCOV_FILES\@ | ||
| }") | ||
| endif(ON_TRAVIS) | ||
|
|
||
| set(SRC_FILE_TEMPLATE | ||
| "{ | ||
|
|
@@ -235,7 +286,7 @@ foreach (GCOV_FILE ${GCOV_FILES}) | |
| # The new coveralls API doesn't need the entire source (Yay!) | ||
| # However, still keeping that part for now. Will cleanup in the future. | ||
| file(MD5 "${GCOV_SRC_PATH}" GCOV_CONTENTS_MD5) | ||
| message("MD5: ${GCOV_SRC_PATH} = ${GCOV_CONTENTS_MD5}") | ||
| # message("MD5: ${GCOV_SRC_PATH} = ${GCOV_CONTENTS_MD5}") | ||
|
|
||
| # Loads the gcov file as a list of lines. | ||
| # (We first open the file and replace all occurences of [] with _ | ||
|
|
@@ -324,6 +375,8 @@ foreach (GCOV_FILE ${GCOV_FILES}) | |
| # Translate the hitcount into valid JSON values. | ||
| if (${HITCOUNT} STREQUAL "#####") | ||
| set(GCOV_FILE_COVERAGE "${GCOV_FILE_COVERAGE}0, ") | ||
| elseif (${HITCOUNT} STREQUAL "=====") | ||
| set(GCOV_FILE_COVERAGE "${GCOV_FILE_COVERAGE}0, ") | ||
| elseif (${HITCOUNT} STREQUAL "-") | ||
| set(GCOV_FILE_COVERAGE "${GCOV_FILE_COVERAGE}null, ") | ||
| else() | ||
|
|
@@ -341,7 +394,7 @@ foreach (GCOV_FILE ${GCOV_FILES}) | |
| math(EXPR GCOV_LINE_COUNT "${GCOV_LINE_COUNT}+1") | ||
| endforeach() | ||
|
|
||
| message("${GCOV_LINE_COUNT} of ${LINE_COUNT} lines read!") | ||
| # message("${GCOV_LINE_COUNT} of ${LINE_COUNT} lines read!") | ||
|
|
||
| # Advanced way of removing the trailing comma in the JSON array. | ||
| # "[1, 2, 3, " -> "[1, 2, 3" | ||
|
|
@@ -351,7 +404,7 @@ foreach (GCOV_FILE ${GCOV_FILES}) | |
| set(GCOV_FILE_COVERAGE "${GCOV_FILE_COVERAGE}]") | ||
|
|
||
| # Generate the final JSON for this file. | ||
| message("Generate JSON for file: ${GCOV_SRC_REL_PATH}...") | ||
| # message("Generate JSON for file: ${GCOV_SRC_REL_PATH}...") | ||
| string(CONFIGURE ${SRC_FILE_TEMPLATE} FILE_JSON) | ||
|
|
||
| set(JSON_GCOV_FILES "${JSON_GCOV_FILES}${FILE_JSON}, ") | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| optimizer.go |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renaming
optimizer.gotooptimizer.go.inwill break building from Go without cmake. Do we really need this?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can find another way to suppress this later.