Someone moved this thread into the "Using Swift" category. I put it where I did because I was gathering information on my way to a proposal/question. Hopefully, the developers of SwiftPM will still see it here. I digress.
Obviously as @SDGGiesbrecht has shown for the specific use case I have, filtering code coverage, a simple JSON parser might be the shortest distance between here and there.
However, I did want to point out that llvm-cov
does have a filter feature (among others) that might also be useful to expose. I think I would like to propose making some of the internals of swift package manager available to the swift test
tool.
Expose testBinary: AbsolutePath
as a flag on swift test
Introduce a new flag, e.g., --show-test-binary-path
(can bike shed later), that prints the path to the test binary. This would be the same path that is currently provided to exportCodeCovAsJSON
.
Note: It is entirely possible that this flag, or something similar to it already exists and if so, oops.
With the path to the test binary easily accessible developers can build their own interactions with llvm-cov
directly. Thus preventing the package manager from having to provide all the different methods/interfaces/formats developers might want to manipulate/visualize coverage data.
For instance, to use llvm-cov
to filter dependencies and tests:
xcrun llvm-cov export \
--ignore-filename-regex='(.build|Tests)[/\\].*' \
-instr-profile $(swift test --show-codecov-path | xargs dirname)/default.profdata \
$(swift test --show-test-binary-path)
Or to generate lcov data instead of JSON:
xcrun llvm-cov export \
--format=lcov \
-instr-profile $(swift test --show-codecov-path | xargs dirname)/default.profdata \
$(swift test --show-test-binary-path)
Or just get a tabular ASCII report:
xcrun llvm-cov report \
-instr-profile $(swift test --show-codecov-path | xargs dirname)/default.profdata \
$(swift test --show-test-binary-path)