Skip to content

xhd2015/go-coverage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

This library handles go-coverage files. It provides semantic coverage profile merging function. Check merge/merge.go for more details.

Example:

go test -run TestMergeProfile -v ./merge

Old Coverage: old

New Coverage: new

Merged Coverage: merged

Algorithm

The algorithm implementation is at merge/merge.go.

First, traverse the old and new AST tree to get each basic block's cleaned code. Simply put, cleaned code is code that gets compiled into assembly, excluding any space and comments.

Then, use myers diff to find unchanged blocks, see ComputeBlockMapping.In this step we map all blocks in new AST to their unchanged counterpart in old AST.

Finally, use the new-to-old mapping to merge counters, for unchanged blocks, counters are added together.

The algorithm effectively provides incrimental testing coverage across muiltpe changes(e.g. multiple git commits).

Diff

go generate ./...

Required go version: 1.16

When build with go1.14:

$ with-go1.14 go build ./...
# github.com/dop251/goja/parser
../../gopath/pkg/mod/github.com/dop251/goja@v0.0.0-20221229151140-b95230a9dbad/parser/parser.go:150:9: undefined: os.ReadFile
../../gopath/pkg/mod/github.com/dop251/goja@v0.0.0-20221229151140-b95230a9dbad/parser/statement.go:901:19: undefined: os.ReadFile
note: module requires Go 1.16

About

merge go test coverage profiles

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages