-
Notifications
You must be signed in to change notification settings - Fork 75
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
New command "show-coverage" #424
Conversation
…ts the coverage information in a readable way
Hi @caiosba - thanks for the PR. I've just put this in the queue for our engineers to review. 👌 |
cmd/show-coverage.go
Outdated
json.Unmarshal([]byte(string(dat)), &result) | ||
line_counts := result["line_counts"].(map[string]interface{}) | ||
header := "Coverage: %.2f%% (%d/%d lines covered, %d missing)" | ||
fmt.Println(fmt.Sprintf(header, result["covered_percent"], int(line_counts["covered"].(float64)), int(line_counts["total"].(float64)), int(line_counts["missed"].(float64)))) |
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 body of this function is a bit dense. Do you mind extracting a few new functions to smooth out the read?
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.
Done
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 like the idea.
Gotta see whats going on with the CI, but this seems good.
cmd/show-coverage.go
Outdated
if getLineCount(result, "missed") > 0 { | ||
|
||
fmt.Println("Uncovered lines by file:") | ||
files := result["source_files"].([]interface{}) | ||
|
||
for _, file_obj := range files { | ||
file := file_obj.(map[string]interface{}) | ||
if file["covered_percent"].(float64) < 100 { | ||
printUncoveredLinesFromFile(file) | ||
} | ||
} | ||
} |
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.
What about another one here? 😁
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.
Another one what? 😁
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.
function!
I would say something like printUncoveredLines
?
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.
Ah yes, makes sense... done! :)
I'll try to run the tests locally to see. |
I was able to reproduce the test failure by running them in the |
@caiosba thanks for looking into it, wasn't finding the time to dig. |
We wanted to show the coverage results easily in our Travis job output log, and we had two parallel jobs, one with the unit tests and the other one with the functional tests. We use the
sum-coverage
command to combine those two into a single coverage file.This PR adds a new command
show-coverage
which parses that single coverage file and outputs the coverage information, for example, coverage percentage, number of covered lines, total number of lines, number of missing lines and which lines from which files are not covered. Example output: