-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
RFC: changing code idiom for more accurate coverage information #11792
Comments
This would likely end up being a large PR that would be highly likely to go conflict-stale quickly, but I do think now that we have regular coverage measurements it would be a good idea to make it easier to see which error paths are or are not currently tested throughout base. Would be nice to have better coverage tools that can be more sophisticated than line-based ones, but that's a harder problem than doing a mass aesthetics-only refactoring. My preference is for the |
Maybe we need another push for the On Sat, Jun 20, 2015 at 9:18 PM, Tony Kelman notifications@github.com
|
So far, 3 votes for if - end form, @kshyatt, you, and myself, none for a 2-line && or || form. |
@quinnj |
(I don't have anything against it, just wouldn't use it until there were a basic block coverage tool) |
Just because it would touch a large number of lines of code (in a trivial way sure, but git doesn't care about that), and because of the
It should still be looked over manually just to be absolutely sure your automated refactoring worked correctly. Maybe better as separate small chunks instead of massively all at once. Definitely split it into a few separate commits at least, even if you put them in the same PR. |
Yes, I was thinking of doing it as a bunch of separate commits, or even PRs... right now, I just want to know which idiom people would prefer. |
Well, it seems a bit strange to me to butcher the codebase because coverage tools had this dumb idea that line numbers are a decent approximation of program control flow. I mean, I'm all for being practical and make this change where needed, but let's not make all the code ugly just because the tooling sucks. It would seem better to me to put this effort into making a better coverage tool, e.g., based on expressions evaluated instead of lines. Again, in the meantime, if it helps people make tests better I'm fine with it being applied sparsely, I just don't want for it to be a systematic change. It strikes me as strange to have constructs in the language that are "considered bad". Either you have it and it's great, or you don't. |
As an aside, I've learnt that not all coverage reporting tools have this line-equals-meaning problem. So Coveralls, the one we are using essentially just because it was relatively popular and I was the first one to bother to create the interface to link our coverage results to it, doesn't support it AFAIK. However https://codecov.io/ does support partial line coverage, which suggests its achievable with tooling on our end. Of course, we don't really need any of these services anyway - they just provide a nice way to automatically process the raw output in a more easy-to-read form. I'm in Camp @carnaval, don't think there should be a systematic change for this right now but doing it as other changes happen seem reasonable, and work on partial line coverage reporting would be even better. |
Here's the problem: The current |
@IainNZ I don't think Coveralls has anything to do with it... it's not producing the .cov files. |
The point still stands. We currently use Coveralls to visualize (and quantify) the results, and it's limited to lines. But if there are services that are more flexible, then the main bottleneck is on our side and therefore something we could fix. It would be interesting to hear what @Keno and others think of the feasibility of doing something like this---does any of the newer LLVM goodness make this easier? Here's a chunk of relevant code: Lines 1138 to 1158 in cb77503
|
As I said, when this change is practically useful (i.e., when you actually add the tests that go with it, and probably not tests just for this case unless the function is well covered already), I'm all for it. Hell, if @kshyatt said that a single character per line makes writing tests easier I'd be fine with it (although I hope it won't come to this :-)). However, it does not mean we cannot admit that this is a failure of the tooling and not the language construct itself. Changing the whole base without even adding the tests that go with it seems like going overboard (and declaring defeat) to me. My nightmare scenario goes something likes this : we change the whole base, when random contributor 133 comes in with this construct in the PR, someone (rightfully) says "please don't use this to stay consistent with the rest of the code", and this happens for a few PR. Then, someone, (rightfully again), being bored of repeating this puts it in the documentation somewhere "the && style of control flow should not be used because random coverage mumbling". There you go, you now have a perfectly valid language construct that is second-class and "you should not use it because best practice" although it's only really a failure of implementation. The problem is that those things have a tendency to be long lived, and I'd bet you a beer of your choice that a year later you'd still have people somewhere not using && for errors because they read somewhere it was "bad". Ok, aside from my day dreaming, what is really needed here is to use coverage at the lowered level of the code : regular (= non exceptional) control flow is linearized so at least you have this level of precision because you are closer to the actual program semantic, not this text lines things we petty humans use to input code :-) There would still be some issues where I don't know how our coverage stuff works so maybe it's already operating at that level and there is a bug, or the output is just not taking it into account fully. |
@timholy I had raised the issue earlier, and had been told that line coverage was all that could be done. |
Ok so looking at the code ( Line 4752 in cb77503
I think experimenting in that direction is a much better use of energy that going around changing all the base error checking at once :-) |
@carnaval That was precisely my point on when I commented on @kshyatt's #11518.
and
|
|
Also, I agree totally with you that this shouldn't ever be put in the documentation as the recommended way to do things... if the question comes up (before the coverage tools are improved), I'd just say clearly, |
|
OK, but you had said this:
|
+1 for not doing this systematically, and instead doing it on a case by case basis driven by active work in improving coverage. There's hope that coverage tooling may improve in the future so let's not churn the waters unnecessarily. |
Sounds pretty good to me. I'd much rather do this than start picking bits of language syntax to effectively ban. |
I've run into issues with the way the coverage tools only work on lines, and not basic blocks,
so that the very common idioms in Julia code of
condition && action
orcondition || action
mean that you won't be able to tell if the action part is covered.Inspired by the tireless work of @kshyatt, which will help make Julia more reliable, I was thinking of
going through the code in Base (with a simple file-query-regex-replace) and changing all occurrences of:
to either
or
I think we need to talk about what the best idiom for use in Julia code is, taking into account the issues of coverage accuracy, conciseness, and ease of understanding the code (esp. for newcomers).
See #11782, and #11735
The text was updated successfully, but these errors were encountered: