Skip to content

Commit

Permalink
Merge pull request #40 from andreasfertig/fixCoverage
Browse files Browse the repository at this point in the history
Fixed collecting code coverage info.
  • Loading branch information
Andreas Fertig authored Jun 23, 2018
2 parents 8ff025c + efc7af4 commit c64c1f2
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 45 deletions.
36 changes: 33 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
- |
Expand All @@ -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
Expand All @@ -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/
Expand Down
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 0 additions & 11 deletions scripts/travis_coverage.sh

This file was deleted.

20 changes: 0 additions & 20 deletions scripts/travis_install.sh

This file was deleted.

5 changes: 0 additions & 5 deletions scripts/travis_tests.sh

This file was deleted.

7 changes: 2 additions & 5 deletions tests/runTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'))]
Expand Down

0 comments on commit c64c1f2

Please sign in to comment.