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

How does this tool calculate the branch coverage of the entire project? #28

Closed
byte-jiao opened this issue Jul 10, 2023 · 2 comments
Closed

Comments

@byte-jiao
Copy link

How does this tool calculate the branch coverage of the entire project? When I execute it in the root directory of the project, I encounter the following error:

panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
main.(*instrumenter).writeGobcoFiles(0x1?, {0xc00008c540?, 0x1?}, {0x0?, 0x0?, 0x0?})
        /Users/bytedance/go/pkg/mod/github.com/rillig/[email protected]/instrumenter.go:574 +0x3cf
main.(*instrumenter).instrument(0xc000388000, {0x117bcff, 0x1}, {0x0, 0x0}, {0xc00008c540, 0x5f})
        /Users/bytedance/go/pkg/mod/github.com/rillig/[email protected]/instrumenter.go:79 +0x1b2
main.(*gobco).instrument(0xc0000d2000)
        /Users/bytedance/go/pkg/mod/github.com/rillig/[email protected]/main.go:266 +0x275
main.gobcoMain({0x11b4478?, 0xc0000ac008?}, {0x11b4478?, 0xc0000ac010?}, {0xc00009a180, 0x3, 0x3})
        /Users/bytedance/go/pkg/mod/github.com/rillig/[email protected]/main.go:28 +0x72
main.main()
        /Users/bytedance/go/pkg/mod/github.com/rillig/[email protected]/main.go:21 +0x46

If I add some parameters, for example:

gobco test ./app/... -stats ./b.out

I will encounter the following error:

panic: gobco: checking multiple packages doesn't work yet

goroutine 1 [running]:
main.(*gobco).parseArgs(0xc000114000?, {0xc0000140b0?, 0x5?, 0x5?})
        /Users/bytedance/go/pkg/mod/github.com/rillig/[email protected]/main.go:121 +0x205
main.(*gobco).parseCommandLine(0x11b4478?, {0xc0000140a0?, 0x11b4478?, 0xc000012020?})
        /Users/bytedance/go/pkg/mod/github.com/rillig/[email protected]/main.go:61 +0x38
main.gobcoMain({0x11b4478?, 0xc000012018?}, {0x11b4478?, 0xc000012020?}, {0xc0000140a0, 0x5, 0x5})
        /Users/bytedance/go/pkg/mod/github.com/rillig/[email protected]/main.go:26 +0x5e
main.main()
        /Users/bytedance/go/pkg/mod/github.com/rillig/[email protected]/main.go:21 +0x46
@rillig
Copy link
Owner

rillig commented Jul 10, 2023

How does this tool calculate the branch coverage of the entire project?

Currently, gobco can only calculate the branch coverage of a single Go package, but not of a complete project. That would be a nice addition, though.

panic: runtime error: index out of range [0] with length 0

That's because the root directory of your project doesn't contain any Go package. This is a situation that didn't occur in my testing scenarios. I'll fix it.

panic: gobco: checking multiple packages doesn't work yet

Gobco currently doesn't support the ... argument. I had a look at how the Go tools handle this path specification, but all the related code was quite large and in an internal package, so I decided not to implement it for now.

@rillig
Copy link
Owner

rillig commented Aug 22, 2023

One of the panics is fixed in 1.3.0, the other one is a duplicate of #12.

@rillig rillig closed this as completed Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants