Apache DataFusion SQL Query Engine
ARROW-2574: [Python] Add Cython and Python code coverage
Antoine Pitrou681bd4bc4a23
diff --git a/ci/travis_env_common.sh b/ci/travis_env_common.shindex a4ae5bd271..568070e043 100755--- a/ci/travis_env_common.sh+++ b/ci/travis_env_common.sh@@ -31,6 +31,7 @@ export ARROW_RUST_DIR=${TRAVIS_BUILD_DIR}/rustif [ $ARROW_TRAVIS_COVERAGE == "1" ]; thenexport ARROW_CPP_COVERAGE_FILE=${TRAVIS_BUILD_DIR}/coverage.info+ export ARROW_PYTHON_COVERAGE_FILE=${TRAVIS_BUILD_DIR}/.coveragefiexport CPP_BUILD_DIR=$TRAVIS_BUILD_DIR/cpp-builddiff --git a/ci/travis_script_cpp.sh b/ci/travis_script_cpp.shindex 02e58cd72c..eedca98b5c 100755--- a/ci/travis_script_cpp.sh+++ b/ci/travis_script_cpp.sh@@ -28,7 +28,7 @@ ctest -j2 --output-on-failure -L unittestpopd# Capture C++ coverage info (we wipe the build dir in travis_script_python.sh)-if [ $ARROW_TRAVIS_COVERAGE == "1" ]; then+if [ "$ARROW_TRAVIS_COVERAGE" == "1" ]; thenpushd $TRAVIS_BUILD_DIRlcov --quiet --directory . --capture --no-external --output-file $ARROW_CPP_COVERAGE_FILEpopddiff --git a/ci/travis_script_python.sh b/ci/travis_script_python.shindex aaca3fdba6..3c0ea6d7c8 100755--- a/ci/travis_script_python.sh+++ b/ci/travis_script_python.sh@@ -85,25 +85,31 @@ 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 installpushd $ARROW_PYTHON_DIR+# Other stuff pip install+pip install -q -r requirements.txtif [ "$PYTHON_VERSION" == "2.7" ]; thenpip install -q futuresfi+if [ "$ARROW_TRAVIS_COVERAGE" == "1" ]; then+ export PYARROW_GENERATE_COVERAGE=1+ pip install -q coverage+fiexport PYARROW_BUILD_TYPE=$ARROW_BUILD_TYPE+export PYARROW_WITH_PARQUET=1+export PYARROW_WITH_PLASMA=1+export PYARROW_WITH_ORC=1-pip install -q -r requirements.txt-python setup.py build_ext -q --with-parquet --with-plasma --with-orc\- install -q --single-version-externally-managed --record=record.text-popd+python setup.py build_ext -q --inplace+# Basic sanity checkspython -c "import pyarrow.parquet"python -c "import pyarrow.plasma"python -c "import pyarrow.orc"-if [ $ARROW_TRAVIS_VALGRIND == "1" ]; then+if [ "$ARROW_TRAVIS_VALGRIND" == "1" ]; thenexport PLASMA_VALGRIND=1fi@@ -115,20 +121,35 @@ if [ $TRAVIS_OS_NAME == "linux" ]; thensudo bash -c "echo 20000 > /proc/sys/vm/nr_hugepages"fi-PYARROW_PATH=$CONDA_PREFIX/lib/python$PYTHON_VERSION/site-packages/pyarrow-python -m pytest -r sxX --durations=15 $PYARROW_PATH --parquet+# Need to run tests from the source tree for Cython coverage and conftest.py+if [ "$ARROW_TRAVIS_COVERAGE" == "1" ]; then+ # Output Python coverage data in a persistent place+ export COVERAGE_FILE=$ARROW_PYTHON_COVERAGE_FILE+ coverage run --append -m pytest -r sxX --durations=15 --parquet pyarrow/tests+else+ python -m pytest -r sxX --durations=15 --parquet pyarrow/tests+fi-# Capture C++ coverage info and combine with previous coverage file-if [ $ARROW_TRAVIS_COVERAGE == "1" ]; then+if [ "$ARROW_TRAVIS_COVERAGE" == "1" ]; then+ # Check Cython coverage was correctly captured in $COVERAGE_FILE+ coverage report -i --include="*/lib.pyx"+ coverage report -i --include="*/memory.pxi"+ coverage report -i --include="*/_parquet.pyx"+ # Generate XML file for CodeCov+ coverage xml -i -o $TRAVIS_BUILD_DIR/coverage.xml+ # Capture C++ coverage info and combine with previous coverage filepushd $TRAVIS_BUILD_DIRlcov --quiet --directory . --capture --no-external --output-file coverage-python-tests.infolcov --add-tracefile coverage-python-tests.info \--add-tracefile $ARROW_CPP_COVERAGE_FILE \--output-file $ARROW_CPP_COVERAGE_FILErm coverage-python-tests.info- popd+ popd # $TRAVIS_BUILD_DIRfi+popd # $ARROW_PYTHON_DIR++if [ "$ARROW_TRAVIS_PYTHON_DOCS" == "1" ] && [ "$PYTHON_VERSION" == "3.6" ]; then# Build documentation onceconda install -y -q \@@ -138,9 +159,12 @@ if [ "$ARROW_TRAVIS_PYTHON_DOCS" == "1" ] && [ "$PYTHON_VERSION" == "3.6" ]; thesphinx \sphinx_bootstrap_theme- pushd $ARROW_PYTHON_DIR/doc+ pushd $ARROW_PYTHON_DIR+ # For autodoc, make sure PyArrow is installed+ python setup.py install -q --single-version-externally-managed --record=record.text+ cd docsphinx-build -q -b html -d _build/doctrees -W source _build/html- popd+ popd # $ARROW_PYTHON_DIRfiif [ "$ARROW_TRAVIS_PYTHON_BENCHMARKS" == "1" ] && [ "$PYTHON_VERSION" == "3.6" ]; then@@ -152,12 +176,16 @@ if [ "$ARROW_TRAVIS_PYTHON_BENCHMARKS" == "1" ] && [ "$PYTHON_VERSION" == "3.6"source activate pyarrow_asvpip install -q git+https://github.com/pitrou/asv.git@customize_commands- pushd $TRAVIS_BUILD_DIR/python+ export PYARROW_WITH_PARQUET=0+ export PYARROW_WITH_PLASMA=1+ export PYARROW_WITH_ORC=0++ pushd $ARROW_PYTHON_DIR# Workaround for https://github.com/airspeed-velocity/asv/issues/631git fetch --depth=100 origin master:master# Generate machine information (mandatory)asv machine --yes# Run benchmarks on the changeset being testedasv run --no-pull --show-stderr --quick HEAD^!- popd+ popd # $ARROW_PYTHON_DIRfidiff --git a/ci/travis_upload_cpp_coverage.sh b/ci/travis_upload_cpp_coverage.shindex 20b7e1bdd0..2b11c5eb85 100755--- a/ci/travis_upload_cpp_coverage.sh+++ b/ci/travis_upload_cpp_coverage.sh@@ -23,7 +23,7 @@ source $TRAVIS_BUILD_DIR/ci/travis_env_common.shpushd $TRAVIS_BUILD_DIR-# Display summary+# Display C++ coverage summarylcov --list $ARROW_CPP_COVERAGE_FILE# Upload report to CodeCovbash <(curl -s https://codecov.io/bash) || echo "Codecov did not collect coverage reports"