8000 Added a file creation for coverage result by AlbertoHer98 · Pull Request #8 · wadey/gocovmerge · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Added a file creation for coverage result #8

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions gocovmerge.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"log"
"os"
"sort"
"strconv"

"golang.org/x/tools/cover"
)
Expand Down Expand Up @@ -81,12 +82,22 @@ func addProfile(profiles []*cover.Profile, p *cover.Profile) []*cover.Profile {
}

func dumpProfiles(profiles []*cover.Profile, out io.Writer) {
f, err := os.Create("Coverage.cov")
if err != nil {
log.Fatal(err)
}
defer f.Close()
if len(profiles) == 0 {
return
}
mode := "mode: " + profiles[0].Mode + "\n"
f.WriteString(mode)
fmt.Fprintf(out, "mode: %s\n", profiles[0].Mode)
for _, p := range profiles {
for _, b := range p.Blocks {
allCover := ""
allCover = p.FileName + ":" + strconv.Itoa(b.StartLine) + "." + strconv.Itoa(b.StartCol) + "," + strconv.Itoa(b.EndLine) + "." + strconv.Itoa(b.EndCol) + " " + strconv.Itoa(b.NumStmt) + " " + strconv.Itoa(b.Count) + "\n"
f.WriteString(allCover)
fmt.Fprintf(out, "%s:%d.%d,%d.%d %d %d\n", p.FileName, b.StartLine, b.StartCol, b.EndLine, b.EndCol, b.NumStmt, b.Count)
}
}
Expand Down
0