From efc7af466fbf6bc7e8f3dd1aa849b0344ffffd76 Mon Sep 17 00:00:00 2001 From: Andreas Fertig Date: Sat, 23 Jun 2018 14:32:11 +0200 Subject: [PATCH] Fixed collecting code coverage info. --- .travis.yml | 36 +++++++++++++++++++++++++++++++++--- CMakeLists.txt | 8 +++++++- scripts/travis_coverage.sh | 11 ----------- scripts/travis_install.sh | 20 -------------------- scripts/travis_tests.sh | 5 ----- tests/runTest.py | 7 ++----- 6 files changed, 42 insertions(+), 45 deletions(-) delete mode 100755 scripts/travis_coverage.sh delete mode 100755 scripts/travis_install.sh delete mode 100755 scripts/travis_tests.sh diff --git a/.travis.yml b/.travis.yml index 364f2e3c..963ca501 100644 --- a/.travis.yml +++ b/.travis.yml @@ -96,7 +96,25 @@ matrix: env: COMPILER='clang++-6.0' COMPILER_CC='clang-6.0' LLVM_CONFIG='/usr/bin/llvm-config-6.0' COVERAGE='No' DEPLOY='Yes' STATIC='Yes' DEBUG='No' UPLOAD='Yes' install: - - ${TRAVIS_BUILD_DIR}/scripts/travis_install.sh +- | + if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then + export HOMEBREW_NO_AUTO_UPDATE=1 + brew update > /dev/null + brew install cmake || brew upgrade cmake + brew install xz || brew upgrade xz + + brew install ccache + export PATH="/usr/local/opt/ccache/libexec:$PATH" + + mkdir ${TRAVIS_BUILD_DIR}/clang + cd ${TRAVIS_BUILD_DIR}/clang + wget -q --continue --directory-prefix=$HOME/Library/Caches/Homebrew https://releases.llvm.org/6.0.0/clang+llvm-6.0.0-x86_64-apple-darwin.tar.xz + cp $HOME/Library/Caches/Homebrew/clang+llvm-6.0.0-x86_64-apple-darwin.tar.xz clang+llvm-6.0.0-x86_64-apple-darwin.tar.xz + + xz -d clang+llvm-6.0.0-x86_64-apple-darwin.tar.xz + tar -xf clang+llvm-6.0.0-x86_64-apple-darwin.tar + mv clang+llvm-6.0.0-x86_64-apple-darwin current + fi before_script: - | @@ -111,7 +129,10 @@ before_script: - cmake -DINSIGHTS_LLVM_CONFIG=${LLVM_CONFIG} -DINSIGHTS_COVERAGE=${COVERAGE} -DINSIGHTS_STATIC=${STATIC} -DDEBUG=${DEBUG} .. script: - make -j 2 -- "${TRAVIS_BUILD_DIR}/scripts/travis_tests.sh" +- | + if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then + make tests + fi - | if [[ "${TRAVIS_OS_NAME}" == "osx" ]] && [[ "${TRAVIS_BRANCH}" = "master" ]]; then export GZ_FILE_NAME=${TRAVIS_BUILD_DIR}/insights-macos.tar.gz @@ -122,7 +143,16 @@ script: fi after_success: -- "${TRAVIS_BUILD_DIR}/scripts/travis_coverage.sh" +- | + if [[ "${COVERAGE}" == "Yes" ]]; then + # Creating report + cd ${TRAVIS_BUILD_DIR}/build + + make coverage -j 2 + + # Uploading report to CodeCov + bash <(curl -s https://codecov.io/bash) -f ${TRAVIS_BUILD_DIR}/build/filtered.info || echo "Codecov did not collect coverage reports" + fi - | if [[ "${TRAVIS_BRANCH}" = "master" ]] && [[ "${UPLOAD}" = "Yes" ]]; then cd ${TRAVIS_BUILD_DIR}/build/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a49fce6..d26b603c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -381,9 +381,15 @@ if(DOXYGEN_FOUND) ) endif(DOXYGEN_FOUND) +# XXX: hack to allow coverage build to run tests which fail +set(TEST_FAILURE_IS_OK "") +if(INSIGHTS_COVERAGE) + set(TEST_FAILURE_IS_OK "--failure-is-ok") +endif() + # add a target to generate run tests add_custom_target(tests - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tests/runTest.py --insights ${CMAKE_CURRENT_BINARY_DIR}/insights --cxx ${CMAKE_CXX_COMPILER} + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tests/runTest.py --insights ${CMAKE_CURRENT_BINARY_DIR}/insights --cxx ${CMAKE_CXX_COMPILER} ${TEST_FAILURE_IS_OK} COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tests/testSTDIN.sh ${CMAKE_CURRENT_BINARY_DIR}/insights DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/insights ${CMAKE_CURRENT_SOURCE_DIR}/tests/runTest.py WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tests diff --git a/scripts/travis_coverage.sh b/scripts/travis_coverage.sh deleted file mode 100755 index 71f51d95..00000000 --- a/scripts/travis_coverage.sh +++ /dev/null @@ -1,11 +0,0 @@ -#! /bin/bash - -if [[ "${COVERAGE}" == "Yes" ]]; then - # Creating report - cd ${TRAVIS_BUILD_DIR}/build - - make coverage -j 2 FAILURE_IS_OK=1 - - # Uploading report to CodeCov - bash <(curl -s https://codecov.io/bash) -f ${TRAVIS_BUILD_DIR}/build/filtered.info || echo "Codecov did not collect coverage reports" -fi diff --git a/scripts/travis_install.sh b/scripts/travis_install.sh deleted file mode 100755 index 9c6da013..00000000 --- a/scripts/travis_install.sh +++ /dev/null @@ -1,20 +0,0 @@ -#! /bin/sh - -if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then - export HOMEBREW_NO_AUTO_UPDATE=1 - brew update > /dev/null - brew install cmake || brew upgrade cmake - brew install xz || brew upgrade xz - - brew install ccache - export PATH="/usr/local/opt/ccache/libexec:$PATH" - - mkdir ${TRAVIS_BUILD_DIR}/clang - cd ${TRAVIS_BUILD_DIR}/clang - wget -q --continue --directory-prefix=$HOME/Library/Caches/Homebrew https://releases.llvm.org/6.0.0/clang+llvm-6.0.0-x86_64-apple-darwin.tar.xz - cp $HOME/Library/Caches/Homebrew/clang+llvm-6.0.0-x86_64-apple-darwin.tar.xz clang+llvm-6.0.0-x86_64-apple-darwin.tar.xz - - xz -d clang+llvm-6.0.0-x86_64-apple-darwin.tar.xz - tar -xf clang+llvm-6.0.0-x86_64-apple-darwin.tar - mv clang+llvm-6.0.0-x86_64-apple-darwin current -fi diff --git a/scripts/travis_tests.sh b/scripts/travis_tests.sh deleted file mode 100755 index 67411fee..00000000 --- a/scripts/travis_tests.sh +++ /dev/null @@ -1,5 +0,0 @@ -#! /bin/bash - -if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then - make tests -fi diff --git a/tests/runTest.py b/tests/runTest.py index ac78c624..4a1d3e7a 100755 --- a/tests/runTest.py +++ b/tests/runTest.py @@ -96,16 +96,13 @@ def main(): parser.add_argument('--cxx', help='C++ compiler to used', default='/usr/local/clang-current/bin/clang++') parser.add_argument('--docker', help='Run tests in docker container', action='store_true') parser.add_argument('--docker-image', help='Docker image name', default='cppinsights-runtime') + parser.add_argument('--failure-is-ok', help='Failing tests are ok', default=False, action='store_true') parser.add_argument('args', nargs=argparse.REMAINDER) args = vars(parser.parse_args()) - bFailureIsOk = False - - if os.environ.has_key('FAILURE_IS_OK'): - bFailureIsOk = (os.environ['FAILURE_IS_OK'] == 1) - insightsPath = args['insights'] remainingArgs = args['args'] + bFailureIsOk = args['failure_is_ok'] if 0 == len(remainingArgs): cppFiles = [f for f in os.listdir(mypath) if (os.path.isfile(os.path.join(mypath, f)) and f.endswith('.cpp'))]