Exclude mock files from coverage reporting

Runner's codebase contains a lot of mock files. They are used only for
tests and not for the production use.

Unfortunately, because the files are not named as *_test.go - to allow
use the mocks in tests outside of the mock source package - they are
counted to the coverage report.

We're using https://github.com/vektra/mockery to automatically generate
mock files basing on interfaces. Mockery is creating mocks, that
accept both scalar values as well as functions that accept mocked method
argumets and returns mocked method result. However, we're mostly not
using this mocking mechanism.

Finally this ends in a lot of mocks code being not covered in test,
which decreases the overall coverage value. While we're totally not
interested in having coverage for mocks!

This commit aims to remove all mocks from the coverage profile file,
which should remove them from both percentage value calculation and the
HTML/jUnit reports.
parent 02d9f103
Pipeline #58342587 passed with stages
in 107 minutes and 58 seconds
......@@ -150,7 +150,7 @@ computeCoverageReport() {
mkdir -p "${reportDirectory}"
echo "mode: ${coverMode}" > ${sourceFile}
grep -h -v -e "^mode:" -e "executors/docker/bindata.go" .cover/*.${coverMode}.cover.txt >> ${sourceFile}
grep -h -v -E -e "^mode:" -e "\/mock_[^\.]+\.go" .cover/*.${coverMode}.cover.txt >> ${sourceFile}
printMessage "Generating HTML coverage report"
go tool cover -o ${htmlReportFile} -html=${sourceFile}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment