Enable Kcov on macOS builds.
I agree to license my contributions to each file under the terms given at the top of each file I changed.
This commit is contained in:
parent
88d3279cba
commit
8f8b74e2c8
13
.travis.yml
13
.travis.yml
@ -1,8 +1,7 @@
|
||||
language: rust
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/kcov-i686-unknown-linux-gnu
|
||||
- $HOME/kcov-x86_64-unknown-linux-gnu
|
||||
- $HOME/kcov
|
||||
- $HOME/android/android-sdk-linux
|
||||
- $HOME/android/armv7a-linux-androideabi26
|
||||
matrix:
|
||||
@ -17,10 +16,18 @@ matrix:
|
||||
#
|
||||
# BEGIN GENERATED
|
||||
|
||||
- env: TARGET_X=x86_64-apple-darwin FEATURES_X= MODE_X=DEBUG KCOV=0
|
||||
- env: TARGET_X=x86_64-apple-darwin FEATURES_X= MODE_X=DEBUG KCOV=1
|
||||
rust: stable
|
||||
os: osx
|
||||
osx_image: xcode10.1
|
||||
addons:
|
||||
homebrew:
|
||||
packages:
|
||||
- bash
|
||||
- cmake
|
||||
- findutils
|
||||
- pkgconfig
|
||||
- zlib
|
||||
|
||||
- env: TARGET_X=x86_64-apple-darwin FEATURES_X= MODE_X=RELWITHDEBINFO KCOV=0
|
||||
rust: stable
|
||||
|
@ -24,9 +24,10 @@ set -ex
|
||||
|
||||
# kcov 26 or newer is needed when getting coverage information for Rust.
|
||||
# kcov 31 is needed so `kcov --version` doesn't exit with status 1.
|
||||
# kcov 36 is needed for accurate coverage on macOS.
|
||||
KCOV_VERSION=${KCOV_VERSION:-36}
|
||||
|
||||
KCOV_INSTALL_PREFIX="${HOME}/kcov-${TARGET_X}"
|
||||
KCOV_INSTALL_PREFIX="${HOME}/kcov"
|
||||
|
||||
# Check if kcov has been cached on travis.
|
||||
if [[ -f "$KCOV_INSTALL_PREFIX/bin/kcov" ]]; then
|
||||
|
11
mk/travis.sh
11
mk/travis.sh
@ -153,8 +153,17 @@ if [[ "$KCOV" == "1" ]]; then
|
||||
RUSTFLAGS="-C link-dead-code" \
|
||||
cargo test -vv --no-run -j2 ${mode-} ${FEATURES_X-} --target=$TARGET_X
|
||||
mk/travis-install-kcov.sh
|
||||
|
||||
if [[ "$TARGET_X" =~ "apple" ]]; then
|
||||
# Add `/usr/bin` to the front of PATH to use the system python.
|
||||
PATH="/usr/bin:$PATH"
|
||||
|
||||
# Add GNU find(1) from homebrew to PATH.
|
||||
PATH="/usr/local/opt/findutils/libexec/gnubin:$PATH"
|
||||
fi
|
||||
|
||||
for test_exe in `find target/$TARGET_X/debug -maxdepth 1 -executable -type f`; do
|
||||
${HOME}/kcov-${TARGET_X}/bin/kcov \
|
||||
${HOME}/kcov/bin/kcov \
|
||||
--verify \
|
||||
--coveralls-id=$TRAVIS_JOB_ID \
|
||||
--exclude-path=/usr/include \
|
||||
|
@ -100,12 +100,18 @@ entry_template = """
|
||||
|
||||
entry_indent = " "
|
||||
|
||||
entry_packages_template = """
|
||||
entry_linux_packages_template = """
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
%(packages)s"""
|
||||
|
||||
entry_macos_packages_template = """
|
||||
addons:
|
||||
homebrew:
|
||||
packages:
|
||||
%(packages)s"""
|
||||
|
||||
entry_sources_template = """
|
||||
sources:
|
||||
%(sources)s"""
|
||||
@ -116,15 +122,15 @@ def format_entry(os, target, compiler, rust, mode, features):
|
||||
vendor = target_words[1]
|
||||
sys = target_words[2]
|
||||
|
||||
# Currently kcov only runs on Linux.
|
||||
# Currently kcov only runs on Linux and macOS.
|
||||
#
|
||||
# GCC 7 was picked arbitrarily to restrict coverage report to one build for
|
||||
# efficiency reasons.
|
||||
#
|
||||
# DEBUG mode is needed because debug symbols are needed for coverage
|
||||
# tracking.
|
||||
kcov = (os == "linux" and compiler == gcc and rust == "stable" and
|
||||
mode == "DEBUG")
|
||||
kcov = (((os == "linux" and compiler == gcc) or os == "osx")
|
||||
and rust == "stable" and mode == "DEBUG")
|
||||
|
||||
if sys == "darwin":
|
||||
abi = sys
|
||||
@ -139,28 +145,26 @@ def format_entry(os, target, compiler, rust, mode, features):
|
||||
return [prefix + x for x in xs]
|
||||
|
||||
template = entry_template
|
||||
packages = []
|
||||
sources = []
|
||||
|
||||
if sys == "linux":
|
||||
template += """
|
||||
dist: trusty"""
|
||||
packages = sorted(get_linux_packages_to_install(target, compiler, arch, kcov))
|
||||
sources_with_dups = sum([get_sources_for_package(p) for p in packages],[])
|
||||
sources = sorted(list(set(sources_with_dups)))
|
||||
template += """
|
||||
dist: trusty"""
|
||||
|
||||
if sys == "linux":
|
||||
if packages:
|
||||
template += entry_packages_template
|
||||
template += entry_linux_packages_template
|
||||
if sources:
|
||||
template += entry_sources_template
|
||||
else:
|
||||
packages = []
|
||||
sources = []
|
||||
elif sys == "macos":
|
||||
os += "\n" + entry_indent + "osx_image: xcode10.1"
|
||||
packages = sorted(get_macos_packages_to_install(target, compiler, arch, kcov))
|
||||
if packages:
|
||||
template += entry_macos_packages_template
|
||||
|
||||
cc = compiler
|
||||
|
||||
if os == "osx":
|
||||
os += "\n" + entry_indent + "osx_image: xcode10.1"
|
||||
|
||||
compilers = []
|
||||
if cc != "":
|
||||
compilers += ["CC_X=" + cc]
|
||||
@ -178,6 +182,17 @@ def format_entry(os, target, compiler, rust, mode, features):
|
||||
"os" : os,
|
||||
}
|
||||
|
||||
def get_macos_packages_to_install(target, compiler, arch, kcov):
|
||||
packages = []
|
||||
|
||||
if kcov == True:
|
||||
packages = ["bash",
|
||||
"cmake",
|
||||
"findutils",
|
||||
"pkgconfig",
|
||||
"zlib"]
|
||||
return packages
|
||||
|
||||
def get_linux_packages_to_install(target, compiler, arch, kcov):
|
||||
if compiler.startswith("clang-") or compiler.startswith("gcc-"):
|
||||
packages = [compiler]
|
||||
|
Loading…
x
Reference in New Issue
Block a user