Skip to content

Commit 9f17b16

Browse files
committedAug 14, 2022
implement Merge
0 parents  commit 9f17b16

32 files changed

+2012
-0
lines changed
 

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.DS_Store

‎README.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Introduction
2+
This library handles go-coverage files.
3+
It provides semantic coverage profile merging function.
4+
Check [merge/merge.go](merge/merge.go) for more details.
5+
6+
Example:
7+
```bash
8+
go test -run TestMergeProfile -v ./merge
9+
```
10+
11+
Old Coverage:
12+
![old](./img/go-coverage-old.jpg)
13+
14+
New Coverage:
15+
![new](./img/go-coverage-new.jpg)
16+
17+
Merged Coverage:
18+
![merged](./img/go-coverage-merged.jpg)
19+
20+
# Algorithm
21+
The algorithm implementation is at [merge/merge.go](merge/merge.go).
22+
23+
First, traverse the old and new AST tree to get each basic block's [cleaned code](./code/clean.go). Simply put, cleaned code is code that gets compiled into assembly, excluding any space and comments.
24+
25+
Then, use [myers diff](./diff/myers/diff.go) to find unchanged blocks, see [ComputeBlockMapping](./diff/myers/map.go).In this step we map all blocks in new AST to their unchanged counterpart in old AST.
26+
27+
Finally, use the new-to-old mapping to merge counters, for unchanged blocks, counters are added together.
28+
29+
The algorithm effectively provides incrimental testing coverage across muiltpe changes(e.g. multiple git commits).

0 commit comments

Comments
 (0)