Commit 3e9f3408 authored by Stefan Behnel's avatar Stefan Behnel

Enable coverage reporting in travis runs. Merge C/C++ jobs into one to...

Enable coverage reporting in travis runs. Merge C/C++ jobs into one to simplify that (we have enough jobs to keep travis busy).
parent 24f6cd4f
[run]
branch = True
parallel = True
concurrency = multiprocessing,thread
include = Cython/*
source = Cython
omit = Test*
...@@ -33,11 +33,12 @@ env: ...@@ -33,11 +33,12 @@ env:
- USE_CCACHE=1 - USE_CCACHE=1
- CCACHE_SLOPPINESS=pch_defines,time_macros - CCACHE_SLOPPINESS=pch_defines,time_macros
- CCACHE_COMPRESS=1 - CCACHE_COMPRESS=1
- CCACHE_MAXSIZE=150M - CCACHE_MAXSIZE=250M
- PATH="/usr/lib/ccache:$HOME/miniconda/bin:$PATH" - PATH="/usr/lib/ccache:$HOME/miniconda/bin:$PATH"
matrix: - BACKEND=c,cpp
- BACKEND=c #matrix:
- BACKEND=cpp # - BACKEND=c
# - BACKEND=cpp
matrix: matrix:
include: include:
...@@ -48,47 +49,53 @@ matrix: ...@@ -48,47 +49,53 @@ matrix:
- python: 3.7 - python: 3.7
dist: xenial # Required for Python 3.7 dist: xenial # Required for Python 3.7
sudo: required # travis-ci/travis-ci#9069 sudo: required # travis-ci/travis-ci#9069
env: BACKEND=c env: COVERAGE=1
- python: 3.7 - python: 3.7
dist: xenial # Required for Python 3.7 dist: xenial # Required for Python 3.7
sudo: required # travis-ci/travis-ci#9069 sudo: required # travis-ci/travis-ci#9069
env: BACKEND=cpp # env: BACKEND=c
# - python: 3.7
# dist: xenial # Required for Python 3.7
# sudo: required # travis-ci/travis-ci#9069
# env: BACKEND=cpp
- python: 3.8-dev - python: 3.8-dev
dist: xenial # Required for Python 3.7 dist: xenial # Required for Python 3.7
sudo: required # travis-ci/travis-ci#9069 sudo: required # travis-ci/travis-ci#9069
env: BACKEND=c # env: BACKEND=c
- python: 3.8-dev # - python: 3.8-dev
dist: xenial # Required for Python 3.7 # dist: xenial # Required for Python 3.7
sudo: required # travis-ci/travis-ci#9069 # sudo: required # travis-ci/travis-ci#9069
env: BACKEND=cpp # env: BACKEND=cpp
- os: osx - os: osx
osx_image: xcode6.4 osx_image: xcode6.4
env: BACKEND=c PY=2 # env: BACKEND=c PY=2
env: PY=2
python: 2 python: 2
language: c language: c
compiler: clang compiler: clang
cache: false cache: false
# - os: osx
# osx_image: xcode6.4
# env: BACKEND=cpp PY=2
# python: 2
# language: cpp
# compiler: clang
# cache: false
- os: osx - os: osx
osx_image: xcode6.4 osx_image: xcode6.4
env: BACKEND=cpp PY=2 # env: BACKEND=c PY=3
python: 2 env: PY=3
language: cpp
compiler: clang
cache: false
- os: osx
osx_image: xcode6.4
env: BACKEND=c PY=3
python: 3 python: 3
language: c language: c
compiler: clang compiler: clang
cache: false cache: false
- os: osx # - os: osx
osx_image: xcode6.4 # osx_image: xcode6.4
env: BACKEND=cpp PY=3 # env: BACKEND=cpp PY=3
python: 3 # python: 3
language: cpp # language: cpp
compiler: clang # compiler: clang
cache: false # cache: false
- env: STACKLESS=true BACKEND=c PY=2 - env: STACKLESS=true BACKEND=c PY=2
python: 2.7 python: 2.7
- env: STACKLESS=true BACKEND=c PY=3 - env: STACKLESS=true BACKEND=c PY=3
...@@ -99,11 +106,11 @@ matrix: ...@@ -99,11 +106,11 @@ matrix:
- python: 3.8-dev - python: 3.8-dev
- env: STACKLESS=true BACKEND=c PY=2 - env: STACKLESS=true BACKEND=c PY=2
- env: STACKLESS=true BACKEND=c PY=3 - env: STACKLESS=true BACKEND=c PY=3
exclude: # exclude:
- python: pypy # - python: pypy
env: BACKEND=cpp # env: BACKEND=cpp
- python: pypy3 # - python: pypy3
env: BACKEND=cpp # env: BACKEND=cpp
branches: branches:
only: only:
...@@ -115,11 +122,11 @@ before_install: ...@@ -115,11 +122,11 @@ before_install:
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
# adding apt repos in travis is really fragile => retry a couple of times. # adding apt repos in travis is really fragile => retry a couple of times.
for i in {1..10}; do travis_retry sudo apt-add-repository --yes 'ppa:ubuntu-toolchain-r/test' && break; sleep 2; done for i in {1..10}; do travis_retry sudo apt-add-repository --yes 'ppa:ubuntu-toolchain-r/test' && break; sleep 2; done
for i in {1..10}; do travis_retry sudo apt-get update && travis_retry sudo apt-get install --yes gcc-8 $(if [ "$BACKEND" = cpp ]; then echo -n "g++-8"; fi ) && break; sleep 2; done for i in {1..10}; do travis_retry sudo apt-get update && travis_retry sudo apt-get install --yes gcc-8 $(if [ -z "${BACKEND##*cpp*}" ]; then echo -n "g++-8"; fi ) && break; sleep 2; done
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 60 $(if [ "$BACKEND" = cpp ]; then echo " --slave /usr/bin/g++ g++ /usr/bin/g++-8"; fi) sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 60 $(if [ -z "${BACKEND##*cpp*" ]; then echo " --slave /usr/bin/g++ g++ /usr/bin/g++-8"; fi)
sudo update-alternatives --set gcc /usr/bin/gcc-8 sudo update-alternatives --set gcc /usr/bin/gcc-8
export CC=gcc export CC=gcc
if [ "$BACKEND" = cpp ]; then sudo update-alternatives --set g++ /usr/bin/g++-8; export CXX=g++; fi if [ -z "${BACKEND##*cpp*" ]; then sudo update-alternatives --set g++ /usr/bin/g++-8; export CXX=g++; fi
fi fi
- | - |
...@@ -145,19 +152,19 @@ before_install: ...@@ -145,19 +152,19 @@ before_install:
install: install:
- python -c 'import sys; print("Python %s" % (sys.version,))' - python -c 'import sys; print("Python %s" % (sys.version,))'
- if [ -n "${TRAVIS_PYTHON_VERSION##*-dev}" -a -n "${TRAVIS_PYTHON_VERSION##2.6*}" ]; then pip install -r test-requirements.txt $( [ -z "${TRAVIS_PYTHON_VERSION##pypy*}" -o -z "${TRAVIS_PYTHON_VERSION##3.7*}" ] || echo " -r test-requirements-cpython.txt" ) ; fi - if [ -n "${TRAVIS_PYTHON_VERSION##*-dev}" -a -n "${TRAVIS_PYTHON_VERSION##2.6*}" ]; then pip install -r test-requirements.txt $( [ -z "${TRAVIS_PYTHON_VERSION##pypy*}" -o -z "${TRAVIS_PYTHON_VERSION##3.7*}" ] || echo " -r test-requirements-cpython.txt" ) ; fi
- CFLAGS="-O2 -ggdb -Wall -Wextra $(python -c 'import sys; print("-fno-strict-aliasing" if sys.version_info[0] == 2 else "")')" python setup.py build # - CFLAGS="-O2 -ggdb -Wall -Wextra $(python -c 'import sys; print("-fno-strict-aliasing" if sys.version_info[0] == 2 else "")')" python setup.py build
before_script: ccache -s || true before_script: ccache -s || true
script: script:
- PYTHON_DBG="python$( python -c 'import sys; print("%d.%d" % sys.version_info[:2])' )-dbg"
- if [ "$TEST_CODE_STYLE" = "1" ]; then - if [ "$TEST_CODE_STYLE" = "1" ]; then
STYLE_ARGS="--no-unit --no-doctest --no-file --no-pyregr --no-examples"; STYLE_ARGS="--no-unit --no-doctest --no-file --no-pyregr --no-examples";
else else
STYLE_ARGS=--no-code-style; STYLE_ARGS=--no-code-style;
if $PYTHON_DBG -V >&2; then CFLAGS="-O0 -ggdb" $PYTHON_DBG runtests.py -vv --no-code-style Debugger --backends=$BACKEND; fi
if [ -z "${BACKEND##*cpp*}" -a -n "${TRAVIS_PYTHON_VERSION##2.6*}" ]; then pip install pythran; fi
if [ "$BACKEND" != "cpp" -a -n "${TRAVIS_PYTHON_VERSION##2*}" ]; then pip install mypy; fi
fi fi
- PYTHON_DBG="python$( python -c 'import sys; print("%d.%d" % sys.version_info[:2])' )-dbg" - if [ "$COVERAGE" != "1" ]; then CFLAGS="-O2 -ggdb -Wall -Wextra $(python -c 'import sys; print("-fno-strict-aliasing" if sys.version_info[0] == 2 else "")')" python setup.py build_ext -i; fi
- if $PYTHON_DBG -V >&2; then CFLAGS="-O0 -ggdb" $PYTHON_DBG runtests.py -vv $STYLE_ARGS Debugger --backends=$BACKEND; fi - CFLAGS="-O0 -ggdb -Wall -Wextra" python runtests.py -vv $STYLE_ARGS -x Debugger --backends=$BACKEND $(if [ "$COVERAGE" == "1" ]; then echo " --coverage"; fi) $(if [ -z "$TEST_CODE_STYLE" ]; then echo " -j7 "; fi)
- if [ "$BACKEND" = "cpp" -a -n "${TRAVIS_PYTHON_VERSION##2.6*}" ]; then pip install pythran; fi
- if [ "$BACKEND" = "c" -a -n "${TRAVIS_PYTHON_VERSION##2*}" ]; then pip install mypy; fi
- CFLAGS="-O2 -ggdb -Wall -Wextra $(python -c 'import sys; print("-fno-strict-aliasing" if sys.version_info[0] == 2 else "")')" python setup.py build_ext -i
- CFLAGS="-O0 -ggdb -Wall -Wextra" python runtests.py -vv $STYLE_ARGS -x Debugger --backends=$BACKEND $(if [ -z "$TEST_CODE_STYLE" ]; then echo " -j7 "; fi)
...@@ -2068,13 +2068,12 @@ def main(): ...@@ -2068,13 +2068,12 @@ def main():
coverage = None coverage = None
if options.coverage or options.coverage_xml or options.coverage_html: if options.coverage or options.coverage_xml or options.coverage_html:
if options.shard_count <= 1 and options.shard_num < 0:
if not WITH_CYTHON: if not WITH_CYTHON:
options.coverage = options.coverage_xml = options.coverage_html = False options.coverage = options.coverage_xml = options.coverage_html = False
else: elif options.shard_num == -1:
print("Enabling coverage analysis") print("Enabling coverage analysis")
from coverage import coverage as _coverage from coverage import coverage as _coverage
coverage = _coverage(branch=True, omit=['Test*']) coverage = _coverage()
coverage.erase() coverage.erase()
coverage.start() coverage.start()
...@@ -2106,9 +2105,18 @@ def main(): ...@@ -2106,9 +2105,18 @@ def main():
else: else:
with time_stamper_thread(): with time_stamper_thread():
_, return_code = runtests(options, cmd_args, coverage) _, return_code = runtests(options, cmd_args, coverage)
if coverage:
if options.shard_count > 1 and options.shard_num == -1:
coverage.combine()
coverage.stop()
sys.stderr.write("ALL DONE\n") sys.stderr.write("ALL DONE\n")
sys.stderr.flush() sys.stderr.flush()
if coverage:
save_coverage(coverage, options)
try: try:
check_thread_termination(ignore_seen=False) check_thread_termination(ignore_seen=False)
except PendingThreadsError: except PendingThreadsError:
...@@ -2174,6 +2182,15 @@ def configure_cython(options): ...@@ -2174,6 +2182,15 @@ def configure_cython(options):
Cython.Compiler.Version.watermark = options.watermark Cython.Compiler.Version.watermark = options.watermark
def save_coverage(coverage, options):
if options.coverage:
coverage.report(show_missing=0)
if options.coverage_xml:
coverage.xml_report(outfile="coverage-report.xml")
if options.coverage_html:
coverage.html_report(directory="coverage-report-html")
def runtests_callback(args): def runtests_callback(args):
options, cmd_args, shard_num = args options, cmd_args, shard_num = args
options.shard_num = shard_num options.shard_num = shard_num
...@@ -2413,29 +2430,6 @@ def runtests(options, cmd_args, coverage=None): ...@@ -2413,29 +2430,6 @@ def runtests(options, cmd_args, coverage=None):
if common_utility_dir and options.shard_num < 0 and options.cleanup_workdir: if common_utility_dir and options.shard_num < 0 and options.cleanup_workdir:
shutil.rmtree(common_utility_dir) shutil.rmtree(common_utility_dir)
if coverage is not None:
coverage.stop()
ignored_modules = set(
'Cython.Compiler.' + name
for name in ('Version', 'DebugFlags', 'CmdLine')) | set(
'Cython.' + name
for name in ('Debugging',))
ignored_packages = ['Cython.Runtime', 'Cython.Tempita']
modules = [
module for name, module in sys.modules.items()
if module is not None and
name.startswith('Cython.') and
'.Tests' not in name and
name not in ignored_modules and
not any(name.startswith(package) for package in ignored_packages)
]
if options.coverage:
coverage.report(modules, show_missing=0)
if options.coverage_xml:
coverage.xml_report(modules, outfile="coverage-report.xml")
if options.coverage_html:
coverage.html_report(modules, directory="coverage-report-html")
stats.print_stats() stats.print_stats()
if missing_dep_excluder.tests_missing_deps: if missing_dep_excluder.tests_missing_deps:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment