-
Notifications
You must be signed in to change notification settings - Fork 39
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
Add parser for GoCov coverage #160
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what to do with this PR. It is hardly reviewable. The problem seems to be so simple, but the implementation is so complex and non-standard.
For my perspective we have a stream of lines that contains the information which lines of a given file are covered, and which are not. This information will be updated continuously. The the result could be a map of files to covered and missed lines.
Maybe we should consider to create this from scratch?
// Commenting out the following lines to avoid throwing an exception when merging coverage information | ||
// from Jacoco. This is a temporary solution until we have a better way to handle this. | ||
// else { | ||
// throw new IllegalArgumentException( | ||
// String.format("Cannot merge coverage information for line %d in %s", | ||
// line, this)); | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is that required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually not part of this PR. I will remove it.
* @return fileNode | ||
*/ | ||
@CanIgnoreReturnValue | ||
public FileNode addCounterIncremental(final int lineNumber, final int covered, final int missed) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand the motivation for this method. As far as I understand the coverage format we only have the information covered or not for each line. I.e., we do not evaluate branch coverage, just line coverage. Line coverage is stored here in these counters with either 1, 0 or 0,1. There is no value > 1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly, we have converted the coverage format generated by GoCov to if a line is coverage or not by using 1 or 0. We are not using any value greater than 1.
throw new InvalidGoCoverageFormatException("Expected the coverage mode specification, but got: [" + line + "]"); | ||
} | ||
//coverage mode | ||
CoverMode coverMode; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cover mode is not used at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. I can review this and update it.
Thank you for the review comments.
yes..This is correct. But we wanted to calculate coverage by packages and finally by the project/module. So, we tried to reuse existing implementation for that. github.com/dev/crd/pkg/aws/services.go:72.81,76.16 3 3 In here, github.com is assumed as the project/module and the rest dev, crd, pks, aws are packages. services.go is the class file. Since all these in the flat structure, we are initializing module, package and file while reading the same line.
This parser works as expected by giving right coverage details for GOCOV. Please share your thoughts around if anything needs to be changed still. |
I'm in holidays for one week, I will come back to your PR after that. |
This GoCov parser has been implemented in order to parse the unit tests coverage generated by the go underlying coverage tool(GoCov) with the command as below:
go test ./... -race -coverprofile=coverage.txt -covermode=atomic
Output from above command would be:
Where every line would have the coverage details as below:
So, the execution-count would say how many times the statements-count executed while running the tests. If the execution-count is above 1, then the statements-count has been executed at least once. So, we mark the start-line to end-line as covered. Otherwise, it will go into coverage miss.
Testing done
Submitter checklist