Skip to content

Commit

Permalink
add workaround and test for workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
haya14busa committed Sep 11, 2016
1 parent f1807a9 commit e0905da
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cover.out
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.PHONY: deps workaround

deps:
go get github.com/wadey/gocovmerge

workaround: deps
@echo Running tests
$(eval PKGS := $(shell go list ./... | grep -v /vendor/))
$(eval PKGS_DELIM := $(shell echo $(PKGS) | sed -e 's/ /,/g'))
go list -f '{{if or (len .TestGoFiles) (len .XTestGoFiles)}}go test -test.v -covermode=count -coverprofile={{.Name}}_{{len .Imports}}_{{len .Deps}}.coverprofile -coverpkg $(PKGS_DELIM) {{.ImportPath}}{{end}}' $(PKGS) | xargs -I {} bash -c {}
gocovmerge `ls *.coverprofile` > cover.out
rm *.coverprofile

testworkaround: workaround
diff -u cover.out cover.ok
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,13 @@ of cource, we can produce html, and can confirm 100% lines are coverd.
```sh
$ go tool cover -html=coverage.out
```

### workaround using gocovmerge

- https://github.com/wadey/gocovmerge
- https://github.com/golang/go/issues/6909#issuecomment-233493644

```
make workaround
make testworkaround
```
6 changes: 6 additions & 0 deletions cover.ok
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
mode: count
github.com/haya14busa/go-cover-multi-pkgs-example/root.go:5.24,7.2 1 1
github.com/haya14busa/go-cover-multi-pkgs-example/root.go:9.17,12.2 2 1
github.com/haya14busa/go-cover-multi-pkgs-example/sub/sub.go:3.23,5.2 1 1
github.com/haya14busa/go-cover-multi-pkgs-example/sub/sub.go:7.24,9.2 1 1
github.com/haya14busa/go-cover-multi-pkgs-example/sub/sub.go:11.30,13.2 1 2

0 comments on commit e0905da

Please sign in to comment.