-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
cmd/cover: should support -coverprofile unifying tests from multiple packages #6909
Comments
It is not an urgent issue. The workaround is simple, please check the shell script: https://gist.github.com/hailiang/0f22736320abe6be71ce |
CL https://golang.org/cl/159910044 mentions this issue. |
Can this be included in 1.5. I don't see any technical reason for it to not be. Thank you. |
As long as someone wants to work on this issue to solve it properly.....
The mentioned CL is not the way to go (overwriting the cover profiles
instead of combining them).
|
I am interested in getting total test coverage across a DAG of packages. All the solutions online do naive merges of cover profiles via concatenation (including comment 6 here), but this does not take into account lines covered across package boundaries. +1 for anyone who can work on this. Edited My original phrasing was bad. |
I wouldn't say there's "no interest" but rather nobody with time to work on it. |
With regard to the solution I can see two approaches:
|
I personally want However, this would require a bit of thought. Right now, all tests and benchmarks are implicitly namespaced by the package. Take for example This is not to say it can't/shouldn't be done, just that there are some careful decisions to be made. |
@josharian Tests also can define their own command-line flag parsing. I don't see how you could make that work right. |
I would think that you would deal with that the same way you do now when combining packages that define their own command-line flag parsing in a non-test program—by manually fixing those collisions when they occur. |
@josharian wrt name spacing, The full package path could be part of the test name, or there could be a seperate flag -runpkg that works in conjunction with -run. |
Another challenge (just writing them down here as I think of them) -- tests are supposed to be executed from the directory in which they are written. This lets them find fixtures easily. However, if multiple tests are bundled into a single executable, there is no single correct working directory. Again, not a showstopper, just something to be thought through. |
@josharian Please don't rely on that. |
In the mean time, I made another tool: https://github.com/AlekSi/gocoverutil. Unlike some bash scripts mentioned there, it sets exit status correctly if tests fail, it sets |
@rsc now that the build cache is in, are we closer to fix this bug? I think people are waiting here for some guidance on how to fix it. I can attempt something myself, but it would be great if you could provide some guidance. Thanks! |
Maybe a different way to see the problem is that we should have a different For example, running |
Of course, this could also be done in a more complex way, by storing which test hit which line and then, on a per-line basis, and then offer for each line of code touched by tests a slice of test names. It would then be up to the tools to read that information and display it to the users, in the most simplistic way doing this as described above with a simple yes / no mode. Sorry for the double message. |
The first suggestions is a great way to get this started. But the more powerful and resourceful |
Change https://golang.org/cl/76875 mentions this issue: |
with multiple packages has been supported since Go 1.10 - golang/go#6909
The text was updated successfully, but these errors were encountered: