rillig / gobco

Measure branch coverage of golang tests
62 stars 12 forks source link

How to use the "gobco" to measure the branch coverage of any test.go file #16

Closed BattleBird closed 4 years ago

BattleBird commented 4 years ago

Dear developer,

I have a requirement. I want to use the following runtime_test.go file to measure the branch coverage of this test unit. The runtime_test.go is put in the go/src/github.com/ethereum/go-ethereum/core/v.m/runtime path, this is the go-ethereum project. I just can use the "go tool cover" to measure the statements coverage. I don't know how to use the "gobco" tool to measure the branch coverage. Screenshot from 2020-03-31 18-52-14

BTW, I just can run "gobco sample/foo.go" in the Golang it can generate the result. I use the similar way to run "gobco runtime/runtime.go" it generate the following error information: /home/xuhang/go/src/github.com/ethereum/go-ethereum/trie/database.go:27:2: cannot find package "github.com/VictoriaMetrics/fastcache" in any of: /usr/local/go/src/github.com/VictoriaMetrics/fastcache (from $GOROOT) /tmp/gobco-c142a8d7-7221-42da-b54c-6fc43070c024/src/github.com/VictoriaMetrics/fastcache (from $GOPATH) /home/xuhang/go/src/github.com/VictoriaMetrics/fastcache /home/xuhang/go/src/github.com/ethereum/go-ethereum/common/mclock/mclock.go:23:2: cannot find package "github.com/aristanetworks/goarista/monotime" in any of: /usr/local/go/src/github.com/aristanetworks/goarista/monotime (from $GOROOT) /tmp/gobco-c142a8d7-7221-42da-b54c-6fc43070c024/src/github.com/aristanetworks/goarista/monotime (from $GOPATH) /home/xuhang/go/src/github.com/aristanetworks/goarista/monotime

Thanks for your reply in advance!:)

rillig commented 4 years ago

I don't know what is causing this failure.

Please run gobco -verbose to get more details.

I'm not going to try this on github.com/ethereum/go-ethereum since I don't want to download that much data. If you want me to fix anything, please provide a small project that shows the same behavior.

rillig commented 4 years ago

Feedback timeout.