Skip to content

Commit

Permalink
Formatting files
Browse files Browse the repository at this point in the history
  • Loading branch information
muratekici committed Sep 15, 2020
1 parent 11ec19e commit 6631b3c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
1 change: 0 additions & 1 deletion go/tools/builders/cover.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ func registerCoverage(coverSrc, varName, srcName, mode string) error {
}

// Append an init function.

if mode == "func" {
fmt.Fprintf(&buf, `
func init() {
Expand Down
6 changes: 2 additions & 4 deletions go/tools/builders/funccover_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func astToByte(fset *token.FileSet, f *ast.File) []byte {
return buf.Bytes()
}

// Writes necessary set instrucions for instrumentation to function definitions
// InsertInstructions writes necessary set instrucions for instrumentation to function definitions
func InsertInstructions(w io.Writer, content []byte, coverVar string) (bool, error) {

fset := token.NewFileSet()
Expand Down Expand Up @@ -108,9 +108,7 @@ func InsertInstructions(w io.Writer, content []byte, coverVar string) (bool, err
// defer LastCallForFunccoverReport()
// ...
// }

eventIndex := 0

for i := 0; i < contentLength; i++ {
if eventIndex < len(events) && i == events[eventIndex] {
fmt.Fprintf(w, "\n\t%s.Flags[%v] = true;", coverVar, eventIndex)
Expand All @@ -125,7 +123,7 @@ func InsertInstructions(w io.Writer, content []byte, coverVar string) (bool, err
return mainLbrace != -1, nil
}

// Writes the declaration of cover variable to the end of the given source file writer using go templates
// declCover writes the declaration of cover variable to the end of the given source file writer using go templates
// If source has a main function, defines LastCallForFunccoverReport function variable and assign an empty
// function to it
// Embedded report libraries can implement an init() function that assigns LastCallForFunccoverReport
Expand Down
6 changes: 3 additions & 3 deletions go/tools/builders/funccover_instrumenter.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"io/ioutil"
)

// Keeps the data necessary for instrumentation
// Instrumentation keeps the data necessary for instrumentation
type Instrumentation struct {
fset *token.FileSet
content []byte
Expand All @@ -31,7 +31,7 @@ type Instrumentation struct {
srcName string
}

// SaveFile, saves given file to instrumentation
// saveFile saves given file to instrumentation
func (h *Instrumentation) saveFile(src string) error {

if h.fset == nil {
Expand All @@ -48,7 +48,7 @@ func (h *Instrumentation) saveFile(src string) error {
return nil
}

// Instrument, instruments the content saved in Instrumentation
// instrument function instruments the content saved in Instrumentation
func (h *Instrumentation) instrument() ([]byte, error) {

var funcCover = []FuncCoverBlock{}
Expand Down
5 changes: 4 additions & 1 deletion go/tools/coverdata/coverdata_func.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,19 @@

package coverdata

// FunctionCover contains the coverage data needed
type FunctionCover struct {
SourcePaths []string
FunctionNames []string
FunctionLines []int32
Flags []*bool
}

// FuncCover keeps the coverage data
// It is exported so that other packages can use it to report coverage
var FuncCover FunctionCover

// Registers functions to FuncCover
// RegisterFileFuncCover eegisters functions to exported variable FuncCover
func RegisterFileFuncCover(SourcePath string, FuncNames []string, FuncLines []int32, Flags []bool) {
for i, funcName := range FuncNames {
FuncCover.SourcePaths = append(FuncCover.SourcePaths, SourcePath)
Expand Down

0 comments on commit 6631b3c

Please sign in to comment.