parse and present/visualize Code Coverage result
Opened this issue · 0 comments
Description
It is good that we can enable code coverage with spm with the swift test --enable-code-coverage
flag. But reviewing the coverage is extremely painful and "unswifty", we have to write a shell script to do it, something like this:
swift test --enable-code-coverage
BIN_PATH="$(swift build --show-bin-path)"
XCTEST_PATH="$(find ${BIN_PATH} -name '*.xctest')"
COV_BUILD_FOLDER=$XCTEST_PATH
if [[ "$OSTYPE" == "darwin"* ]]; then
f="$(basename $XCTEST_PATH .xctest)"
COV_BUILD_FOLDER="${COV_BUILD_FOLDER}/Contents/MacOS/$f"
fi
COV_DATA_PATH=".build/debug/codecov/default.profdata"
xcrun llvm-cov show $COV_BUILD_FOLDER -instr-profile=$COV_DATA_PATH -region-coverage-lt=99 -use-color
(might contain some copy paste errors)
This introduces a barrier/friction to using the code coverage.
I brought this up in Swift Forums and @grynspan suggested that I add an issue in this repo...
So what would be amazing is if SPM could do this for us, and enable three different options:
- summary
- details
- exported report (choosing format)
You (maintainers of SPM) most likely have much deeper knowledge about llvm-cov than me, but for other readers I will include link to the script I use, I can call it with:
Summary
./test.sh --summary
which produces this:
![Screenshot 2024-04-25 at 09 51 18](https://private-user-images.githubusercontent.com/864410/325521213-2aa84801-511f-4ad5-9315-f9e59bb92238.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk4ODAzNTEsIm5iZiI6MTcxOTg4MDA1MSwicGF0aCI6Ii84NjQ0MTAvMzI1NTIxMjEzLTJhYTg0ODAxLTUxMWYtNGFkNS05MzE1LWY5ZTU5YmI5MjIzOC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNzAyJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDcwMlQwMDI3MzFaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1hMTE4M2VkZWE2YjAyNjk1MDA3MjFkODFjNGM3ZGJmYTFkMGExZmEyZWYxYTZjNjI2MzdkM2I0OTFlYWQ0ZjM2JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.HcjUZ6TPX-77aVPX19y5UpqJkV8K0YxXktwJ_nh3_T4)
With an overview and total coverage report.
Details
./test.sh
(my default)
Which displays every line where I've missed coverage ("exit tests" will help me test the assertionFailure
missed lines 🥳).
Possible?
So my first question is, is it even possible to let SPM do this?
Wanted?
And second question is, do you agree that it would be indeed good to include this functionality (being able to display coverage using SPM - remove need to write a script...)?
Expected behavior
Would be nice if SPM cannot only produce the coverage, but also display it.
Actual behavior
SPM cannot display coverage it has produced.
Steps to reproduce
See description,
Swift Package Manager version/commit hash
Swift Package Manager - Swift 5.10.0-dev
Swift & OS version (output of swift --version && uname -a
)
swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Target: arm64-apple-macosx14.0
Darwin Alexanders-MacBook-Pro.local 23.4.0 Darwin Kernel Version 23.4.0: Fri Mar 15 00:12:49 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6020 arm64