Comments (16)
gocov annotate cov.json $(gocov report cov.json | grep -v "100.00%" | awk '{ print $2 }' | xargs)
Power of unix tools.
from gocov.
Only ... I'm on Windows. So having that possibility in the tool itself would eliminate any capabilities lacking on any platform. After all, if you search for the functions for annotation, you can decide which ones to withhold for output and which not. (I know I can develop cross-platform from Linux, but that is not the point.)
from gocov.
Ok, ok, just saying :)
from gocov.
No worries, I will have a think about how best to do this. Thanks for filing the issue.
from gocov.
Johan, sorry for the delay in implementing this. I have added "-ceiling" to the annotate sub-command; if a function's coverage percentage falls below the ceiling, it will be annotated, otherwise it is ignored. The default ceiling is 101.
(For the interested: I was considering adding a more complex "filter" sub-command, but eventually decided against it. I'll provide some utilities in the future to allow people to write standalone programs for filtering.)
from gocov.
Don't be sorry Andrew, I wasn't in a hurry, but thanks for adding the feature. I tried it, and I think it still reports the 100% functions in the annotate result when passing in a value below 100 for -ceiling.
The command I used looks like:
gocov annotate covdata\coverage.json --ceiling 50 .*addOption > covdata\coverage-annotate.log
I hope that is the right place in the command to add the ceiling option?
There are 9 types having such an addOption function in the package, and 1 of it is covered 100%, the others 0%. However all 9 are reported by annotate.
from gocov.
gocov uses the standard flag
package, which stops parsing flags after the first non-flag argument. The first word after gocov is special, and should not be considered a "non-flag". It should work if you move "--ceiling 50" directly after "annotate". i.e.
gocov annotate --ceiling 50 covdata\coverage.json .*addOption > covdata\coverage-annotate.log
from gocov.
Then I get:
failed to read coverage file: open --ceiling: The system cannot find the file specified.
Apparently the json file has to be the first argument to annotate.
from gocov.
No. The first must be the command (annotate, report..). In gocov annotate --ceiling 50 covdata\coverage.json .*addOption > covdata\coverage-annotate.log
, annotate
is the first non flag arg. Correct is IMO:
gocov -ceiling 50 annotate ...
Also note that the flag package doesn't require --
flag prefixing.
from gocov.
Thanks for another take, cznic, but I still think Andrew will have to do some modifications, cause
gocov -ceiling 50 annotate covdata\coverage.json .*addOption > covdata\coverage-annotate.log
now yields:
flag provided but not defined: -ceiling
Usage:
gocov command [arguments]
The commands are:
annotate
test
report
from gocov.
That's strange. Something is quite unusual with gocov flag parsing. For example, gocov -h
doesn't show which flags are defined/accepted (with their types and help info), which is a basically zero cost, default feature of the package "flag" and the first case I see to not work this way. I have no idea why it was disabled, but I really don't like that user non-friendly approach. Perhaps worth filing a separate issue.
from gocov.
Coudl that be caused by the commands gocov accepts, as they are not implemented as flags ?
from gocov.
@cznic The different sub-commands have different flag sets. If you were to do: gocov annotate -h, then you'd see the flags accepted by annotate.
@JohanSamyn Not sure what's going on; I tested this and it worked. I'll try it on my Windows laptop later and report back.
from gocov.
@JohanSamyn It works on my Windows laptop.
First, I gocov test
ed github.com/axw/gocov
. gocov report
shows:
...
github.com/axw/gocov/io.go write 83.33% (5/6)
github.com/axw/gocov/gocov.go init 18.18% (2/11)
github.com/axw/gocov/io_windows.go fdwriter.Write 0.00% (0/1)
...
So I picked on "write" as a pattern. Here's what I tried:
gocov annotate gocov.json write
: annotated both write and fdwriter.Write.gocov annotate -ceiling=84 gocov.json write
: as abovegocov annotate -ceiling=83 gocov.json write
: only annotates fdwriter.Write
Re-reading your comments, it sounds a bit like you don't have the latest code. Can you please run gocov annotate -h
? You should expect to get a usage message. If not, please run go get -u github.com/axw/gocov/gocov
and try again.
from gocov.
Well now, I'm 100% sure I did a go get -u
at some time. But the gocov annotate -h
did only report a complaint about missing function regex. So I did it again, and now the expected usage msg is shown. And indeed everything works correctly now. Sorry for being a noob, and thank you, Andrew, for the feature and the help.
from gocov.
No problems! Glad it's working now.
from gocov.
Related Issues (20)
- [Question] Can i use gocov to get code coverage report for a go application if my tests are written in another framework using python HOT 3
- Does gocov not support generics in Go version 1.20? HOT 1
- Does gocov currently support generics,expected '(', found '[' (and 5 more errors)
- When the file size of coverage is large (420KB), generating json is very slow, taking several hours
- how to confirm the supported GO version of gocov
- gocov's result is different from go test HOT 1
- If a package has no test files, the lines in that package are not added to the total line count. HOT 10
- Pass arguments to go list HOT 4
- please tag a version, to make go modules usage easier HOT 2
- gocov: gocov report print total coverage NaN% when totalReached and totalStatements are zero
- gocov does not pass -tags parameter HOT 1
- What is the difference to the go standard tools?
- gocov failed when trying on file that has a formatting directive
- 按照指示安装不了,有什么国内的镜像地址吗 HOT 1
- go get doesn't install HOT 2
- the code source default is $GOROOT. whether the code source path can be specified by the user when using gocov convert? HOT 3
- Unable to use go install HOT 2
- gocov with go1.18 generics HOT 3
- [question] Is it possible to exclude a method from code coverage? HOT 1
- gocov with coverprofile raise error, the file path contains duplicate parts HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gocov.