diff --git a/.travis.yml b/.travis.yml index b4ec6ff1aaae..e91d7b166a90 100644 --- a/.travis.yml +++ b/.travis.yml @@ -52,6 +52,7 @@ matrix: - ARROW_TRAVIS_PLASMA=1 - ARROW_TRAVIS_ORC=1 - ARROW_TRAVIS_CLANG_FORMAT=1 + - ARROW_TRAVIS_COVERAGE=1 - ARROW_TRAVIS_PYTHON_BENCHMARKS=1 - ARROW_TRAVIS_PYTHON_DOCS=1 - ARROW_BUILD_WARNING_LEVEL=CHECKIN @@ -68,10 +69,12 @@ matrix: # If either C++ or Python changed, we must install the C++ libraries - $TRAVIS_BUILD_DIR/ci/travis_before_script_cpp.sh script: - - if [ $ARROW_CI_CPP_AFFECTED == "1" ]; then $TRAVIS_BUILD_DIR/ci/travis_script_cpp.sh; fi + # All test steps are required for accurate C++ coverage info + - $TRAVIS_BUILD_DIR/ci/travis_script_cpp.sh - $TRAVIS_BUILD_DIR/ci/travis_build_parquet_cpp.sh - $TRAVIS_BUILD_DIR/ci/travis_script_python.sh 2.7 - $TRAVIS_BUILD_DIR/ci/travis_script_python.sh 3.6 + - $TRAVIS_BUILD_DIR/ci/travis_upload_cpp_coverage.sh # [OS X] C++ & Python w/ XCode 6.4 - compiler: clang language: cpp @@ -178,6 +181,7 @@ matrix: - $TRAVIS_BUILD_DIR/ci/travis_before_script_c_glib.sh script: - $TRAVIS_BUILD_DIR/ci/travis_script_c_glib.sh + # Rust - language: rust cache: cargo rust: stable @@ -197,7 +201,11 @@ matrix: - $TRAVIS_BUILD_DIR/ci/travis_script_rust.sh after_success: - pushd ${TRAVIS_BUILD_DIR}/rust - - cargo coveralls --verbose + # Run coverage for codecov.io + - RUST_BACKTRACE=1 cargo coverage --verbose + - bash <(curl -s https://codecov.io/bash) || echo "Codecov did not collect coverage reports" + # Run coverage for coveralls.io + #- cargo coveralls --verbose after_failure: - COREFILE=$(find . -maxdepth 2 -name "core*" | head -n 1) diff --git a/ci/travis_before_script_cpp.sh b/ci/travis_before_script_cpp.sh index b9afbee7863f..379007d5bf07 100755 --- a/ci/travis_before_script_cpp.sh +++ b/ci/travis_before_script_cpp.sh @@ -17,7 +17,6 @@ # specific language governing permissions and limitations # under the License. - set -ex source $TRAVIS_BUILD_DIR/ci/travis_env_common.sh @@ -83,6 +82,10 @@ if [ $ARROW_TRAVIS_VALGRIND == "1" ]; then CMAKE_COMMON_FLAGS="$CMAKE_COMMON_FLAGS -DARROW_TEST_MEMCHECK=ON" fi +if [ $ARROW_TRAVIS_COVERAGE == "1" ]; then + CMAKE_COMMON_FLAGS="$CMAKE_COMMON_FLAGS -DARROW_GENERATE_COVERAGE=ON" +fi + if [ $TRAVIS_OS_NAME == "linux" ]; then cmake $CMAKE_COMMON_FLAGS \ $CMAKE_LINUX_FLAGS \ diff --git a/ci/travis_env_common.sh b/ci/travis_env_common.sh index c8c19ed5b61d..a4ae5bd271a9 100755 --- a/ci/travis_env_common.sh +++ b/ci/travis_env_common.sh @@ -29,6 +29,10 @@ export ARROW_JS_DIR=${TRAVIS_BUILD_DIR}/js export ARROW_INTEGRATION_DIR=$TRAVIS_BUILD_DIR/integration export ARROW_RUST_DIR=${TRAVIS_BUILD_DIR}/rust +if [ $ARROW_TRAVIS_COVERAGE == "1" ]; then + export ARROW_CPP_COVERAGE_FILE=${TRAVIS_BUILD_DIR}/coverage.info +fi + export CPP_BUILD_DIR=$TRAVIS_BUILD_DIR/cpp-build export ARROW_CPP_INSTALL=$TRAVIS_BUILD_DIR/cpp-install diff --git a/ci/travis_install_linux.sh b/ci/travis_install_linux.sh index 74fde277413b..b1e21ea8d668 100755 --- a/ci/travis_install_linux.sh +++ b/ci/travis_install_linux.sh @@ -24,3 +24,7 @@ sudo apt-get install -y -q \ if [ "$ARROW_TRAVIS_VALGRIND" == "1" ]; then sudo apt-get install -y -q valgrind fi + +if [ $ARROW_TRAVIS_COVERAGE == "1" ]; then + sudo apt-get install -y -q lcov +fi diff --git a/ci/travis_install_toolchain.sh b/ci/travis_install_toolchain.sh index 31076b2e736f..a153d893dd82 100755 --- a/ci/travis_install_toolchain.sh +++ b/ci/travis_install_toolchain.sh @@ -23,7 +23,7 @@ source $TRAVIS_BUILD_DIR/ci/travis_install_conda.sh if [ ! -e $CPP_TOOLCHAIN ]; then # Set up C++ toolchain from conda-forge packages for faster builds - conda create -y -q -p $CPP_TOOLCHAIN python=2.7 \ + conda create -y -q -p $CPP_TOOLCHAIN python=3.6 \ nomkl \ boost-cpp \ libprotobuf \ diff --git a/ci/travis_script_cpp.sh b/ci/travis_script_cpp.sh index 455a6766f935..02e58cd72c01 100755 --- a/ci/travis_script_cpp.sh +++ b/ci/travis_script_cpp.sh @@ -26,3 +26,10 @@ pushd $CPP_BUILD_DIR ctest -j2 --output-on-failure -L unittest popd + +# Capture C++ coverage info (we wipe the build dir in travis_script_python.sh) +if [ $ARROW_TRAVIS_COVERAGE == "1" ]; then + pushd $TRAVIS_BUILD_DIR + lcov --quiet --directory . --capture --no-external --output-file $ARROW_CPP_COVERAGE_FILE + popd +fi diff --git a/ci/travis_script_python.sh b/ci/travis_script_python.sh index 5177a6c62289..aaca3fdba643 100755 --- a/ci/travis_script_python.sh +++ b/ci/travis_script_python.sh @@ -52,15 +52,23 @@ conda install -y -q pip \ # conda install -y -q pytorch torchvision -c soumith # fi -# Build C++ libraries +# Re-build C++ libraries with the right Python setup mkdir -p $ARROW_CPP_BUILD_DIR pushd $ARROW_CPP_BUILD_DIR # Clear out prior build files rm -rf * +# XXX Can we simply reuse CMAKE_COMMON_FLAGS from travis_before_script_cpp.sh? +CMAKE_COMMON_FLAGS="-DARROW_EXTRA_ERROR_CONTEXT=ON" + +if [ $ARROW_TRAVIS_COVERAGE == "1" ]; then + CMAKE_COMMON_FLAGS="$CMAKE_COMMON_FLAGS -DARROW_GENERATE_COVERAGE=ON" +fi + cmake -GNinja \ - -DARROW_BUILD_TESTS=off \ + $CMAKE_COMMON_FLAGS \ + -DARROW_BUILD_TESTS=on \ -DARROW_BUILD_UTILITIES=off \ -DARROW_PLASMA=on \ -DARROW_PYTHON=on \ @@ -74,6 +82,9 @@ ninja install popd +# python-test isn't run by travis_script_cpp.sh, exercise it here +$ARROW_CPP_BUILD_DIR/$ARROW_BUILD_TYPE/python-test + # Other stuff pip install pushd $ARROW_PYTHON_DIR @@ -107,6 +118,17 @@ fi PYARROW_PATH=$CONDA_PREFIX/lib/python$PYTHON_VERSION/site-packages/pyarrow python -m pytest -r sxX --durations=15 $PYARROW_PATH --parquet +# Capture C++ coverage info and combine with previous coverage file +if [ $ARROW_TRAVIS_COVERAGE == "1" ]; then + pushd $TRAVIS_BUILD_DIR + lcov --quiet --directory . --capture --no-external --output-file coverage-python-tests.info + lcov --add-tracefile coverage-python-tests.info \ + --add-tracefile $ARROW_CPP_COVERAGE_FILE \ + --output-file $ARROW_CPP_COVERAGE_FILE + rm coverage-python-tests.info + popd +fi + if [ "$ARROW_TRAVIS_PYTHON_DOCS" == "1" ] && [ "$PYTHON_VERSION" == "3.6" ]; then # Build documentation once conda install -y -q \ diff --git a/ci/travis_upload_cpp_coverage.sh b/ci/travis_upload_cpp_coverage.sh new file mode 100755 index 000000000000..20b7e1bdd047 --- /dev/null +++ b/ci/travis_upload_cpp_coverage.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +set -e + +source $TRAVIS_BUILD_DIR/ci/travis_env_common.sh + +pushd $TRAVIS_BUILD_DIR + +# Display summary +lcov --list $ARROW_CPP_COVERAGE_FILE +# Upload report to CodeCov +bash <(curl -s https://codecov.io/bash) || echo "Codecov did not collect coverage reports" + +popd diff --git a/cpp/src/plasma/test/client_tests.cc b/cpp/src/plasma/test/client_tests.cc index 53743cad2d6e..547a7495568c 100644 --- a/cpp/src/plasma/test/client_tests.cc +++ b/cpp/src/plasma/test/client_tests.cc @@ -22,7 +22,9 @@ #include #include +#include #include +#include #include "arrow/test-util.h" @@ -67,7 +69,13 @@ class TestPlasmaStore : public ::testing::Test { ARROW_CHECK_OK(client2_.Disconnect()); // Kill all plasma_store processes // TODO should only kill the processes we launched - system("killall -9 plasma_store"); +#ifdef COVERAGE_BUILD + // Ask plasma_store to exit gracefully and give it time to write out + // coverage files + system("killall -TERM plasma_store"); + std::this_thread::sleep_for(std::chrono::milliseconds(200)); +#endif + system("killall -KILL plasma_store"); } void CreateObject(PlasmaClient& client, const ObjectID& object_id, diff --git a/python/pyarrow/tests/test_plasma.py b/python/pyarrow/tests/test_plasma.py index 1589c1bb3043..de11eb6e5fa5 100644 --- a/python/pyarrow/tests/test_plasma.py +++ b/python/pyarrow/tests/test_plasma.py @@ -25,6 +25,7 @@ import random import shutil import signal +import sys import subprocess import tempfile import time @@ -196,11 +197,13 @@ def teardown_method(self, test_method): try: # Check that the Plasma store is still alive. assert self.p.poll() is None - # Ensure Valgrind detected no issues - if USE_VALGRIND: - self.p.send_signal(signal.SIGTERM) + # Ensure Valgrind and/or coverage have a clean exit + self.p.send_signal(signal.SIGTERM) + if sys.version_info >= (3, 3): + self.p.wait(timeout=5) + else: self.p.wait() - assert self.p.returncode == 0 + assert self.p.returncode == 0 finally: self.plasma_store_ctx.__exit__(None, None, None)