Skip to content

GO_COV issues with resolving paths #263

@egonelbre

Description

@egonelbre

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementEnhancement of existing functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions