diff options
author | Jeff Quast <contact@jeffquast.com> | 2014-11-24 17:08:54 -0800 |
---|---|---|
committer | Jeff Quast <contact@jeffquast.com> | 2014-11-24 17:10:12 -0800 |
commit | 70cc564c8fb7213cd928ccc1d75b50225d55d202 (patch) | |
tree | c89f0eec8a713a16aae1a03de7eb6f742f849e53 /tools | |
parent | 3484b93d7a4df75eb501105e6ac66f69995e7bdf (diff) | |
download | pexpect-git-70cc564c8fb7213cd928ccc1d75b50225d55d202.tar.gz |
Allow teamcity to track coverage for builds
We'll still use coveralls.io, though! This
just makes it so that TeamCity is aware of
change of code coverage when viewing build
results.
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/teamcity-coverage-report.sh | 27 | ||||
-rwxr-xr-x | tools/teamcity-runtests.sh | 7 |
2 files changed, 31 insertions, 3 deletions
diff --git a/tools/teamcity-coverage-report.sh b/tools/teamcity-coverage-report.sh new file mode 100755 index 0000000..5610202 --- /dev/null +++ b/tools/teamcity-coverage-report.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# This is to be executed by each individual OS test. It only +# combines coverage files and reports locally to the given +# TeamCity build configuration. +set -e +set -o pipefail +[ -z ${TEMP} ] && TEMP=/tmp + +# combine all .coverage* files, +coverage combine + +# create ascii report, +report_file=$(mktemp $TEMP/coverage.XXXXX) +coverage report --rcfile=`dirname $0`/../.coveragerc > "${report_file}" 2>/dev/null + +# Report Code Coverage for TeamCity, using 'Service Messages', +# https://confluence.jetbrains.com/display/TCD8/How+To...#HowTo...-ImportcoverageresultsinTeamCity +# https://confluence.jetbrains.com/display/TCD8/Custom+Chart#CustomChart-DefaultStatisticsValuesProvidedbyTeamCity +total_no_lines=$(awk '/TOTAL/{print $2}') +total_no_misses=$(awk '/TOTAL/{print $3}') +total_no_covered=$((${total_no_lines} - ${total_no_misses})) +echo "##teamcity[buildStatisticValue key='<CodeCoverageAbsLTotal>' value='<${total_no_lines}>']" +echo "##teamcity[buildStatisticValue key='<CodeCoverageAbsLCovered>' value='<${total_no_covered}>']" + +# Display for human consumption and remove ascii file. +cat "${report_file}" +rm "${report_file}" diff --git a/tools/teamcity-runtests.sh b/tools/teamcity-runtests.sh index 48d3db9..a61d979 100755 --- a/tools/teamcity-runtests.sh +++ b/tools/teamcity-runtests.sh @@ -49,8 +49,9 @@ if [ $ret -ne 0 ]; then echo "the build should detect and report these failing tests." >&2 fi -# combine all coverage to single file, publish as build -# artifact in {pexpect_projdir}/build-output +# combine all coverage to single file, report for this build, +# then move into ./build-output/ as a unique artifact to allow +# the final "Full build" step to combine and report to coveralls.io +`dirname $0`/teamcity-coverage-report.sh mkdir -p build-output -coverage combine mv .coverage build-output/.coverage.${osrel}.py{$pyversion}.$RANDOM.$$ |