mirror of https://github.com/golang/go.git
cover: add function to parse profiles from an io.Reader
Fixes golang/go#19404 Change-Id: I893fbb999bb8d0a6c62ab8752790fce75912be0c GitHub-Last-Rev: 101a2f5bd6e2c2e278deafc8238fa4319a697541 GitHub-Pull-Request: golang/tools#331 Reviewed-on: https://go-review.googlesource.com/c/tools/+/336329 Reviewed-by: Bryan C. Mills <bcmills@google.com> Trust: Bryan C. Mills <bcmills@google.com> Trust: Michael Knyszek <mknyszek@google.com>
This commit is contained in:
parent
36e7bf96e1
commit
81efdbcac4
|
|
@ -10,6 +10,7 @@ import (
|
|||
"bufio"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"math"
|
||||
"os"
|
||||
"sort"
|
||||
|
|
@ -45,14 +46,18 @@ func ParseProfiles(fileName string) ([]*Profile, error) {
|
|||
return nil, err
|
||||
}
|
||||
defer pf.Close()
|
||||
return ParseProfilesFromReader(pf)
|
||||
}
|
||||
|
||||
files := make(map[string]*Profile)
|
||||
buf := bufio.NewReader(pf)
|
||||
// ParseProfilesFromReader parses profile data from the Reader and
|
||||
// returns a Profile for each source file described therein.
|
||||
func ParseProfilesFromReader(rd io.Reader) ([]*Profile, error) {
|
||||
// First line is "mode: foo", where foo is "set", "count", or "atomic".
|
||||
// Rest of file is in the format
|
||||
// encoding/base64/base64.go:34.44,37.40 3 1
|
||||
// where the fields are: name.go:line.column,line.column numberOfStatements count
|
||||
s := bufio.NewScanner(buf)
|
||||
files := make(map[string]*Profile)
|
||||
s := bufio.NewScanner(rd)
|
||||
mode := ""
|
||||
for s.Scan() {
|
||||
line := s.Text()
|
||||
|
|
|
|||
Loading…
Reference in New Issue