Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parse and present/visualize Code Coverage result #7497

Open
Sajjon opened this issue Apr 25, 2024 · 0 comments
Open

parse and present/visualize Code Coverage result #7497

Sajjon opened this issue Apr 25, 2024 · 0 comments
Labels
enhancement swift test Changes impacting `swift test` tool

Comments

@Sajjon
Copy link

Sajjon commented Apr 25, 2024

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

With an overview and total coverage report.

Details

./test.sh

(my default)

which produces this:
Screenshot 2024-04-25 at 09 50 22

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
@grynspan grynspan added the swift test Changes impacting `swift test` tool label Apr 25, 2024
@MaxDesiatov MaxDesiatov changed the title SPM to: parse and present/visualize Code Coverage result parse and present/visualize Code Coverage result Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement swift test Changes impacting `swift test` tool
Projects
None yet
Development

No branches or pull requests

2 participants