Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hit ~80% code coverage on all packages in this repo #3053

Open
whyrusleeping opened this issue Aug 7, 2016 · 16 comments
Open

Hit ~80% code coverage on all packages in this repo #3053

whyrusleeping opened this issue Aug 7, 2016 · 16 comments
Labels
exp/novice Someone with a little familiarity can pick up help wanted Seeking public contribution on this issue kind/test Testing work status/deferred Conscious decision to pause or backlog

Comments

@whyrusleeping
Copy link
Member

whyrusleeping commented Aug 7, 2016

In order to make releases more painless, and the code more stable and dependable in general I would like to try and hit a goal of at least 80% coverage (line based) on all packages.

Coverage data for master branch is at: https://codecov.io/gh/ipfs/go-ipfs/tree/master/cmd/ipfs

@whyrusleeping whyrusleeping added this to the Ipfs 0.4.4 milestone Aug 7, 2016
@whyrusleeping whyrusleeping added kind/test Testing work help wanted Seeking public contribution on this issue exp/novice Someone with a little familiarity can pick up labels Aug 7, 2016
@whyrusleeping
Copy link
Member Author

To check the code coverage on a given package, for example, unixfs/mod, run:

$ go test -v -cover ./unixfs/mod
=== RUN   TestDagModifierBasic
--- PASS: TestDagModifierBasic (0.01s)
        dagmodifier_test.go:131: Testing mod within zero block
        dagmodifier_test.go:137: Testing mod within bounds of existing multiblock file.
        dagmodifier_test.go:144: Testing mod that extends file.
        dagmodifier_test.go:150: Testing pure append
=== RUN   TestMultiWrite
--- PASS: TestMultiWrite (0.00s)
=== RUN   TestMultiWriteAndFlush
--- PASS: TestMultiWriteAndFlush (0.00s)
=== RUN   TestWriteNewFile
--- PASS: TestWriteNewFile (0.00s)
=== RUN   TestMultiWriteCoal
--- PASS: TestMultiWriteCoal (0.00s)
=== RUN   TestLargeWriteChunks
--- PASS: TestLargeWriteChunks (0.47s)
=== RUN   TestDagTruncate
--- PASS: TestDagTruncate (0.00s)
=== RUN   TestSparseWrite
--- PASS: TestSparseWrite (0.00s)
=== RUN   TestSeekPastEndWrite
--- PASS: TestSeekPastEndWrite (0.00s)
PASS
coverage: 75.2% of statements
ok      github.com/ipfs/go-ipfs/unixfs/mod      0.483s

That will show you all the tests that run, and at the end, a percentage of coverage for that package. To get more detailed info, you can generate a coverage profile like so:

$ go test -v -coverprofile=cover.out ./unixfs/mod

This will produce the same output as the last command, but it will also create a file called cover.out which you can use to generate a nice html coverage report:

$ go tool cover -html=cover.out

For more information, read through: https://blog.golang.org/cover

@jbenet
Copy link
Member

jbenet commented Aug 11, 2016

Would be nice to write a script to output code coverage of a package and
it's deps. Like the list you made but with the percentage next to it or
something.

I'm sure there's some CI service that does it. Does project-repos.ipfs.io
already incorporate go code coverage? cc @RichardLitt
On Tue, Aug 9, 2016 at 15:45 Jeromy Johnson [email protected]
wrote:

To check the code coverage on a given package, for example, unixfs/mod,
run:

$ go test -v -cover ./unixfs/mod
=== RUN TestDagModifierBasic
--- PASS: TestDagModifierBasic (0.01s)
dagmodifier_test.go:131: Testing mod within zero block
dagmodifier_test.go:137: Testing mod within bounds of existing multiblock file.
dagmodifier_test.go:144: Testing mod that extends file.
dagmodifier_test.go:150: Testing pure append
=== RUN TestMultiWrite
--- PASS: TestMultiWrite (0.00s)
=== RUN TestMultiWriteAndFlush
--- PASS: TestMultiWriteAndFlush (0.00s)
=== RUN TestWriteNewFile
--- PASS: TestWriteNewFile (0.00s)
=== RUN TestMultiWriteCoal
--- PASS: TestMultiWriteCoal (0.00s)
=== RUN TestLargeWriteChunks
--- PASS: TestLargeWriteChunks (0.47s)
=== RUN TestDagTruncate
--- PASS: TestDagTruncate (0.00s)
=== RUN TestSparseWrite
--- PASS: TestSparseWrite (0.00s)
=== RUN TestSeekPastEndWrite
--- PASS: TestSeekPastEndWrite (0.00s)
PASS
coverage: 75.2% of statements
ok github.com/ipfs/go-ipfs/unixfs/mod 0.483s

That will show you all the tests that run, and at the end, a percentage of
coverage for that package. To get more detailed info, you can generate a
coverage profile like so:

$ go test -v -coverprofile=cover.out ./unixfs/mod

This will produce the same output as the last command, but it will also
create a file called cover.out which you can use to generate a nice html
coverage report:

$ go tool cover -html=cover.out

For more information, read through: https://blog.golang.org/cover


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#3053 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAIcoQi1NlTIBRokThi-syQdWEmsSmoYks5qeNi3gaJpZM4Jekn_
.

@RichardLitt
Copy link
Member

It doesn't, unless that is counted by CI. We should include it!

@whyrusleeping
Copy link
Member Author

We can use coveralls for the go projects

On Wed, Aug 10, 2016 at 8:13 PM Richard Littauer [email protected]
wrote:

It doesn't, unless that is counted by CI. We should include it!


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#3053 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/ABL4HE96U2lM5unbwddoABxmYa9YU86kks5qepNfgaJpZM4Jekn_
.

Kubuxu added a commit that referenced this issue Aug 11, 2016
Kubuxu added a commit that referenced this issue Aug 15, 2016
Kubuxu added a commit that referenced this issue Aug 15, 2016
Kubuxu added a commit that referenced this issue Aug 15, 2016
@Kubuxu
Copy link
Member

Kubuxu commented Aug 16, 2016

I made a script for go-ipfs: https://gist.github.com/Kubuxu/989ab1b51a9f3a0b71479a71abe35427#file-makereprot-sh it should be easily modifiable for other packages, but we should use CoverAlls (or something similar either way).

Someone just needs to go through all go repos and set it up.

@RichardLitt
Copy link
Member

I'm happy to help with that?

@Kubuxu
Copy link
Member

Kubuxu commented Aug 16, 2016

Sure, let's try it first on go-ipfs and we will see how it goes.

@whyrusleeping whyrusleeping added the status/ready Ready to be worked label Nov 28, 2016
@Kubuxu Kubuxu self-assigned this Dec 5, 2016
@Kubuxu Kubuxu added status/in-progress In progress and removed status/ready Ready to be worked labels Dec 5, 2016
@Kubuxu Kubuxu added status/ready Ready to be worked and removed status/in-progress In progress labels Dec 12, 2016
@Kubuxu Kubuxu modified the milestones: ipfs 0.4.6, ipfs 0.4.5 Dec 19, 2016
@Kubuxu
Copy link
Member

Kubuxu commented Feb 13, 2017

Sharness test coverage is done, all of your coverage is at: https://codecov.io/gh/ipfs/go-ipfs/tree/master/

There are lots of places to improve there, if you want to get to know the project structure better, it is great place to start.

@whyrusleeping
Copy link
Member Author

@Kubuxu this is fantastic :)

Going to bump this issue to 0.4.7, but i'd say significant progress has been made

@whyrusleeping whyrusleeping modified the milestones: Ipfs 0.4.7, ipfs 0.4.6 Feb 14, 2017
@wigy-opensource-developer

Here are my 2 cents that you might safely ignore: Improving coverage in cmd will come best from pushing code duplicated all around that package into testable methods and functions. Also, some of that functionality should be moved behind the core api to improve reusability in other applications. End-to-end tests are much slower and harder to maintain, because they might break for quite many reasons not related to the goal of that given test.

@RichardLitt
Copy link
Member

Here are my 2 cents that you might safely ignore:

All advice is listened to. :) Thanks for adding your 2 cents.

@whyrusleeping
Copy link
Member Author

@wigy-opensource-developer Yeah, youre right. Code in the commands lib needs to be purely 'interface' code that translates user input into function arguments, and turns the codes responses into output.

@whyrusleeping
Copy link
Member Author

Since the 0.4.6 we've seen a very small increase in overall code coverage

https://codecov.io/gh/ipfs/go-ipfs/compare/release...master

Lets aim for a higher target next release

@whyrusleeping whyrusleeping modified the milestones: Ipfs 0.4.8, Ipfs 0.4.7 Mar 11, 2017
@whyrusleeping
Copy link
Member Author

Since 0.4.7, we've seen a 0.5% increase in overall code coverage:

https://codecov.io/gh/ipfs/go-ipfs/compare/c21c85f...1d59331

Thats better than the previous increase, but still pretty small. I'd love to see a 5% increase on the next release.

@whyrusleeping whyrusleeping modified the milestones: Ipfs 0.4.9, Ipfs 0.4.8 Mar 24, 2017
@whyrusleeping
Copy link
Member Author

@whyrusleeping whyrusleeping modified the milestones: Ipfs 0.4.10, Ipfs 0.4.9 May 8, 2017
@magik6k magik6k modified the milestones: Ipfs 0.4.10, Ipfs 0.4.11 Jul 28, 2017
@Kubuxu Kubuxu modified the milestones: Ipfs 0.4.12, go-ipfs 0.4.13 Nov 6, 2017
@whyrusleeping whyrusleeping removed this from the go-ipfs 0.4.14 milestone Feb 10, 2018
@Stebalien Stebalien added status/deferred Conscious decision to pause or backlog and removed status/ready Ready to be worked labels Dec 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exp/novice Someone with a little familiarity can pick up help wanted Seeking public contribution on this issue kind/test Testing work status/deferred Conscious decision to pause or backlog
Projects
None yet
Development

No branches or pull requests

7 participants