Skip to content

Commit

Permalink
Refs #11832. Use python to generate json file.
Browse files Browse the repository at this point in the history
  • Loading branch information
quantumsteve committed May 27, 2015
1 parent c9d027b commit e679768
Show file tree
Hide file tree
Showing 4 changed files with 164 additions and 484 deletions.
38 changes: 14 additions & 24 deletions Code/Mantid/Build/CMake/Coveralls.cmake
Expand Up @@ -38,24 +38,13 @@ function(coveralls_setup _COVERAGE_SRCS _COVERALLS_UPLOAD)
message(FATAL_ERROR "Coveralls: Missing ${_CMAKE_SCRIPT_PATH}/CoverallsClear.cmake")
endif()

if (NOT EXISTS "${_CMAKE_SCRIPT_PATH}/CoverallsGenerateGcov.cmake")
message(FATAL_ERROR "Coveralls: Missing ${_CMAKE_SCRIPT_PATH}/CoverallsGenerateGcov.cmake")
if (NOT EXISTS "${_CMAKE_SCRIPT_PATH}/CoverallsGenerateGcov.py")
message(FATAL_ERROR "Coveralls: Missing ${_CMAKE_SCRIPT_PATH}/CoverallsGenerateGcov.py")
endif()

# When passing a CMake list to an external process, the list
# will be converted from the format "1;2;3" to "1 2 3".
# This means the script we're calling won't see it as a list
# of sources, but rather just one long path. We remedy this
# by replacing ";" with "*" and then reversing that in the script
# that we're calling.
# http://cmake.3232098.n2.nabble.com/Passing-a-CMake-list-quot-as-is-quot-to-a-custom-target-td6505681.html
set(COVERAGE_SRCS_TMP ${_COVERAGE_SRCS})
set(COVERAGE_SRCS "")
foreach (COVERAGE_SRC ${COVERAGE_SRCS_TMP})
set(COVERAGE_SRCS "${COVERAGE_SRCS}*${COVERAGE_SRC}")
endforeach()

#message("Coverage sources: ${COVERAGE_SRCS}")
#pass name to a file instead of a list of every source.
set(COVERAGE_SRCS ${_COVERAGE_SRCS})

set(COVERALLS_FILE ${PROJECT_BINARY_DIR}/coveralls.json)

find_package(Git)
Expand All @@ -66,24 +55,25 @@ function(coveralls_setup _COVERAGE_SRCS _COVERALLS_UPLOAD)
OUTPUT_STRIP_TRAILING_WHITESPACE
)

INCLUDE(FindPythonInterp)
add_custom_target(coveralls_generate

# Zero the coverage counters.
COMMAND ${CMAKE_COMMAND}
-P "${_CMAKE_SCRIPT_PATH}/CoverallsClear.cmake"

# Run regress tests.
#COMMAND ${CMAKE_CTEST_COMMAND} -j 4 --output-on-failure || true
# Run regression tests. Continue even if tests fail.
#COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure || true

# Generate Gcov and translate it into coveralls JSON.
# We do this by executing an external CMake script.
# (We don't want this to run at CMake generation time, but after compilation and everything has run).
COMMAND ${CMAKE_COMMAND}
-DCOVERAGE_SRCS="${COVERAGE_SRCS}" # TODO: This is passed like: "a b c", not "a;b;c"
-DCOVERALLS_OUTPUT_FILE="${COVERALLS_FILE}"
-DCOV_PATH="${PROJECT_BINARY_DIR}"
-DPROJECT_ROOT="${PROJECT_ROOT}"
-P "${_CMAKE_SCRIPT_PATH}/CoverallsGenerateGcov.cmake"
COMMAND ${PYTHON_EXECUTABLE}
${_CMAKE_SCRIPT_PATH}/CoverallsGenerateGcov.py
--COVERAGE_SRCS_FILE="${COVERAGE_SRCS}"
--COVERALLS_OUTPUT_FILE="${COVERALLS_FILE}"
--COV_PATH="${PROJECT_BINARY_DIR}"
--PROJECT_ROOT="${PROJECT_ROOT}"

WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
COMMENT "Generating coveralls output..."
Expand Down

0 comments on commit e679768

Please sign in to comment.