summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtools/teamcity-coverage-report.sh27
-rwxr-xr-xtools/teamcity-runtests.sh7
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.$$