~shabbyrobe/gocovmerge

b5bfa59ec0adc420475f97f89b58045c721d761c — Wade Simmons 8 years ago c01c923
merge Count based on the covermode

The cover modes are described as:
From [The Go Blog: The cover story](https://blog.golang.org/cover):

         The go test command accepts a -covermode flag to set the coverage
         mode to one of three settings:

         - set: did each statement run?
         - count: how many times did each statement run?
         - atomic: like count, but counts precisely in parallel programs

Previously, we were always merging like it was "set" mode. This change
instead handles the Count correctly for each `-covermode` type.
1 files changed, 8 insertions(+), 1 deletions(-)

M gocovmerge.go
M gocovmerge.go => gocovmerge.go +8 -1
@@ 40,7 40,14 @@ func mergeProfileBlock(p *cover.Profile, pb cover.ProfileBlock, startIndex int) 
		if p.Blocks[i].EndLine != pb.EndLine || p.Blocks[i].EndCol != pb.EndCol {
			log.Fatalf("OVERLAP MERGE: %v %v %v", p.FileName, p.Blocks[i], pb)
		}
		p.Blocks[i].Count |= pb.Count
		switch p.Mode {
		case "set":
			p.Blocks[i].Count |= pb.Count
		case "count", "atomic":
			p.Blocks[i].Count += pb.Count
		default:
			log.Fatalf("unsupported covermode: '%s'", p.Mode)
		}
	} else {
		if i > 0 {
			pa := p.Blocks[i-1]