Skip to content

Commit

Permalink
initial work on llvm cov support
Browse files Browse the repository at this point in the history
  • Loading branch information
sagiegurari committed Jul 22, 2017
1 parent 36b712d commit e64be5f
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cargo-make"
version = "0.3.35"
version = "0.3.36"
authors = ["Sagie Gur-Ari <sagiegurari@gmail.com>"]
description = "Rust task runner and build tool."
license = "Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ See [contributing guide](.github/CONTRIBUTING.md)

| Date | Version | Description |
| ----------- | ------- | ----------- |
| 2017-07-21 | v0.3.35 | Maintenance |
| 2017-07-22 | v0.3.36 | Added coverage-lcov task (not fully tested) |
| 2017-07-21 | v0.3.34 | Added coverage-tarpaulin task |
| 2017-07-21 | v0.3.33 | Added more environment variables for workspace support |
| 2017-07-20 | v0.3.32 | Added --list-all-steps cli option |
Expand Down
2 changes: 1 addition & 1 deletion docs/_includes/content.md
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ See [contributing guide](https://github.com/sagiegurari/cargo-make/blob/master/.

| Date | Version | Description |
| ----------- | ------- | ----------- |
| 2017-07-21 | v0.3.35 | Maintenance |
| 2017-07-22 | v0.3.36 | Added coverage-lcov task (not fully tested) |
| 2017-07-21 | v0.3.34 | Added coverage-tarpaulin task |
| 2017-07-21 | v0.3.33 | Added more environment variables for workspace support |
| 2017-07-20 | v0.3.32 | Added --list-all-steps cli option |
Expand Down
42 changes: 37 additions & 5 deletions src/default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -376,14 +376,15 @@ done
]

[tasks.coverage-lcov]
description = "WARNING, ONLY INSTALLS LCOV. ACTUAL COVERAGE IS CURRENTLY NOT IMPLEMENTED!!!"
windows_alias = "empty"
description = "WARNING, THIS TASK IS UNTESTED!!!! Installs (if missing) and runs coverage using llvm-cov (not supported on windows/mac)"

[tasks.coverage-lcov.linux]
install_script = [
'''
command -v lcov >/dev/null 2>&1 || {
if [ "$(grep -Ei 'debian|buntu|mint' /etc/*release)" ]; then
sudo apt-get update || true
sudo apt-get install -y clang
sudo apt-get install -y clang llvm-3.9 lcov
git clone https://github.com/linux-test-project/lcov.git
cd lcov
Expand All @@ -396,8 +397,39 @@ command -v lcov >/dev/null 2>&1 || {
]
script = [
'''
echo "Not Implemented."
exit 1
#based on https://users.rust-lang.org/t/howto-generating-a-branch-coverage-report/8524
if [ -n "$LLVM_VERSION" ]; then
rm -f *.gcda *.gcno
cargo rustc -- --test -Ccodegen-units=1 -Clink-dead-code -Cpasses=insert-gcov-profiling -Zno-landing-pads "-L/usr/lib/llvm-$LLVM_VERSION/lib/clang/$LLVM_VERSION/lib/linux/" "-lclang_rt.profile-${CARGO_MAKE_RUST_TARGET_ARCH}"
ls *.gcno
echo "Running unit tests"
for file in target/debug/deps/${CARGO_MAKE_CRATE_FS_NAME}*
do
"$file" || true
done
echo "Running integration tests"
for file in target/debug/deps/test_*
do
"$file" || true
done
ls *.gcda
echo "#!/bin/sh -e\nllvm-cov gcov $*" >> ./target/llvm-gcov
chmod 777 ./target/llvm-gcov
PATH=$PATH:./target:"/usr/lib/llvm-$LLVM_VERSION/bin"
LCOVOPTS="--gcov-tool llvm-gcov --rc lcov_branch_coverage=1"
LCOVOPTS="${LCOVOPTS} --rc lcov_excl_line=assert"
lcov ${LCOVOPTS} --capture --directory . --base-directory . -o coverage.lcov
lcov ${LCOVOPTS} --extract coverage.info "$(pwd)/*" -o "${CARGO_MAKE_CRATE_FS_NAME}.lcov"
genhtml --branch-coverage --demangle-cpp --legend "${CARGO_MAKE_CRATE_FS_NAME}.info" -o target/coverage/
fi
'''
]

Expand Down

0 comments on commit e64be5f

Please sign in to comment.