Skip to content

Commit

Permalink
Restrict coverage reporting to only pbench (#3036)
Browse files Browse the repository at this point in the history
* Restrict coverage reporting to only `pbench`

We also change to move a few options to the coverage config file.

We are now able to drop the coverage report symlink by updating the
generated XML directly.
  • Loading branch information
portante authored Oct 12, 2022
1 parent 84c2030 commit b8c68c4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 18 deletions.
5 changes: 4 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[run]
parallel = True
branch = True
cover_pylib = False
data_file = ${_PBENCH_COV_DIR}/coverage.db
parallel = True
relative_files = True
10 changes: 7 additions & 3 deletions exec-unittests
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,11 @@ if [[ -z "${subtst}" || "${subtst}" == "python" ]]; then
done

printf -- "\n\n\nRunning %s python3-based unit tests via pytest\n\n" "${major_list// /,}"
_pbench_sources=$(python3 -c 'import inspect, pathlib, pbench; print(pathlib.Path(inspect.getsourcefile(pbench)).parent.parent)')
_pbench_sources=$(python3 -c 'import inspect, pathlib, pbench; print(pathlib.Path(inspect.getsourcefile(pbench)).parent)')
_PBENCH_COV_DIR="${_toxenvdir}/cov" _time pytest \
${pytest_jobs_arg} \
--basetemp="${_toxenvdir}/tmp" \
--cov=${_pbench_sources} \
--cov-branch \
--cov-append \
--cov-report ${_cov_report} \
${posargs} \
--pyargs ${_pytest_majors}
Expand All @@ -155,6 +153,12 @@ if [[ -z "${subtst}" || "${subtst}" == "python" ]]; then
else
printf -- "\n%s pytest command succeeded\n\n" "${_major^}"
fi

if [[ "${_cov_report_kind}" == "xml" && -n "${WORKSPACE}" ]]; then
# For the Jenkins CI we need to adjust the generated XML report to
# use WORKSPACE relative file name paths in the report.
sed -i "s;${_pbench_sources};${WORKSPACE}/lib/pbench;" ${_cov_report_name}
fi
fi

_subtst_list="tool-scripts/datalog tool-scripts/postprocess tool-scripts util-scripts bench-scripts"
Expand Down
15 changes: 1 addition & 14 deletions jenkins/Pipeline.gy
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ pipeline {
sh 'if [[ ! -e agent/rpm/seqno ]] ; then echo "1" > agent/rpm/seqno ; fi'
sh 'if [[ ! -e server/rpm/seqno ]] ; then echo "1" > server/rpm/seqno ; fi'

// If there is somehow a symlink left over from a previous run's
// Cobertura processing, remove it, because it seems to confuse
// the coverage data collection.
sh 'rm -fv pbench'

// Run the "build" (lint, unit tests, etc.) in a container.
sh 'jenkins/run ./build.sh'
}
Expand All @@ -46,14 +41,6 @@ pipeline {
}
post {
success {
// This symlink somehow allows the Cobertura plug-in to find the
// sources referenced in the coverage report. However, the presence
// of this link inside the container seems to confuse the coverage
// data collection, so we create it here and then remove it after
// generating the report. (We use the -f option just in case there's
// an old one hanging around.)
sh 'ln -sTf lib/pbench pbench'

// Note that jenkins/run-pytests is executed inside the container
// while the Cobertura plug-in is executed natively, so this poses
// a challenge in terms of finding the coverage report file; we
Expand All @@ -70,7 +57,7 @@ pipeline {
onlyStable: false,
sourceEncoding: 'ASCII',
zoomCoverageChart: false])
sh 'rm cov/report.xml pbench'
sh 'rm cov/report.xml'
}
}
}
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ passenv =
USER
PBENCH_UNITTEST_PARALLEL
COV_REPORT_XML
WORKSPACE
setenv =
VIRTUAL_ENV = {envdir}
XDG_CACHE_HOME = {envdir}
Expand Down

0 comments on commit b8c68c4

Please sign in to comment.