-
-
Notifications
You must be signed in to change notification settings - Fork 44
Description
coverage-model/src/main/java/edu/hm/hafner/coverage/parser/GoCovParser.java
Lines 43 to 52 in 2833a79
| private static final Pattern LINE_PATTERN = Pattern.compile( | |
| "(?:(?<org>[^/\\\\:]+\\.[^/\\\\:]+)[/\\\\])?" | |
| + "(?<project>[^/\\\\:]+)[/\\\\]" | |
| + "(?<module>[^/\\\\:]+)[/\\\\]" | |
| + "(?<package>.*[/\\\\]?.*)[/\\\\]" | |
| + "(?<file>[^/\\\\:]+):" | |
| + "(?<lineStart>\\d+)\\.(?<columnStart>\\d+)," | |
| + "(?<lineEnd>\\d+)\\.(?<columnEnd>\\d+)\\s*" | |
| + "(?<statements>\\d+)\\s*" | |
| + "(?<executions>\\d+)"); |
In coverage profile output the format is "<package>/<filename>:<linestart>". There's no standard structure how modules and orgs are related to package path.
For example having a report for example.com/main.go:1 is entirely plausible. I created a small example here https://github.com/egonelbre/exp/blob/main/coverage_example/coverage.out.
Since reimplementing module path discovery logic inside coverage parser seems rather a huge undertaking. Shelling out to go is probably not a good idea either, maybe there's a way to pass in arguments to the parser on how to convert package names to paths. e.g. passing in prefixes and how they should be replaced with paths:
example.com=./
example.com/submodule=/tmp/submodule
github.com/google/protobuf=./vendor/protobuf
For context, I finally started migrate from corberatura plugin to coverage plugin and I'm getting errors such as:
[Coverage] [-ERROR-] - Source file 'xyz/abc.go' not found