Skip to content

Conversation

maxaudron
Copy link
Contributor

The format wants an absolute path for the SF key as specified here under
the FILES section: http://ltp.sourceforge.net/coverage/lcov/geninfo.1.php
(and as I've just seen you have that in your README too)

Some programs will accept and work with relative paths with or without
./ but there's also a good chance to fail. Thus abiding by the spec is
the best idea.

@jandelgado
Copy link
Owner

Hi, thanks for the PR. While I think it's always good to go with the specification, i think we should make the behaviour of using the full-path opt-in, since it will be an incompatible change, leading to different lcov files.

So could you please make it optional by adding a -use-absolute-source-path flag to main ? The new/old bevhaviour can be easily controlled by passing a pathResolverFunc that is identity when using absolute paths, otherwise it will be getCoverallsSourceFileName. This approach also simplifies unit testing.

@@ -213,7 +191,6 @@ func parseCoverage(coverage io.Reader) (map[string][]*block, error) {
log.Printf("warn: %v", err)
continue
}
f = getCoverallsSourceFileName(f)
Copy link
Owner

@jandelgado jandelgado Apr 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pass this function as a parameter. Default is to pass getCoverallsSourceFileName, if -use-absolute-source-path is set, just pass identify, which keeps the original, absolute path, e.g. func identity(f) string {return f;}

@maxaudron maxaudron force-pushed the fix/sf-absolute-path branch 2 times, most recently from 632e4a9 to afa09ec Compare April 26, 2021 07:19
@jandelgado
Copy link
Owner

Looks good thank you. I'll check why the CI fails later today ...

@jandelgado
Copy link
Owner

Please rebase to master and let's see if the inttest passes now without problems

The lcov spec wants the SF attribute to contain an absolute path to the
source file, thus far a relative one has been used which breaks some
tools that use the lcov file.

When using the -use-absolute-source-path argument the lcov output will
contain the full absolute path.
@maxaudron maxaudron force-pushed the fix/sf-absolute-path branch from afa09ec to 26b01e0 Compare April 28, 2021 07:50
@jandelgado jandelgado merged commit bd844a3 into jandelgado:master Apr 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants