Giter Club home page Giter Club logo

Comments (16)

nsf avatar nsf commented on July 19, 2024

gocov annotate cov.json $(gocov report cov.json | grep -v "100.00%" | awk '{ print $2 }' | xargs)
Power of unix tools.

from gocov.

JohanSamyn avatar JohanSamyn commented on July 19, 2024

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.

nsf avatar nsf commented on July 19, 2024

Ok, ok, just saying :)

from gocov.

axw avatar axw commented on July 19, 2024

No worries, I will have a think about how best to do this. Thanks for filing the issue.

from gocov.

axw avatar axw commented on July 19, 2024

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.

JohanSamyn avatar JohanSamyn commented on July 19, 2024

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.

axw avatar axw commented on July 19, 2024

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.

JohanSamyn avatar JohanSamyn commented on July 19, 2024

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.

cznic avatar cznic commented on July 19, 2024

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.

JohanSamyn avatar JohanSamyn commented on July 19, 2024

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.

cznic avatar cznic commented on July 19, 2024

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.

JohanSamyn avatar JohanSamyn commented on July 19, 2024

Coudl that be caused by the commands gocov accepts, as they are not implemented as flags ?

from gocov.

axw avatar axw commented on July 19, 2024

@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.

axw avatar axw commented on July 19, 2024

@JohanSamyn It works on my Windows laptop.

First, I gocov tested 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 above
  • gocov 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.

JohanSamyn avatar JohanSamyn commented on July 19, 2024

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.

axw avatar axw commented on July 19, 2024

No problems! Glad it's working now.

from gocov.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.