3 ms·
The branch coverage thing is a weird, artificial-seeming requirement that all the branches in the compiled code --- not the code as written, but the code ultima
by tptacek 5y ago
The branch coverage thing is a weird, artificial-seeming requirement that all the branches in the compiled code --- not the code as written, but the code ultimately produced by the compiler --- be testable. In other words: if the compiler generates a bounds check anywhere, it should be possible to test what happens when that specific bounds check fails. The problem is that sane Rust code doesn't give you all the tools you'd need to deliberately trip all the checks the compiler generates, because that is part of the point of being a safe language.
- masklinn 5y agoRight so really more of an expressivity issue: the compiler is not smart enough to remove all branches which can not happen in a given program, so some of those branches will be completely untestable despite being in the final object code e.g. have a vec![_;4], structurally use it such that the index can only be in-bounds, the compiler may not be able to elide the OOB checks because it might not understand they're unnecessary for real-world code.
- tptacek 5y agoFrankly, I think it's a pretty silly concern.
- cormacrelf 5y agoIt's substantially less silly than a small-time JavaScript component library adding 100% branch coverage testing requirements as a blocker to accepting a PR. But they do it for the same reason, to be able to advertise it and demonstrate reliability. This is how the sqlite project makes money. I guess someone's got to build the instrumentation tools that let them keep doing this, sounds like it won't be them. (Edit: not sure who else would have the motivation, to be honest. If they had to pioneer one thing, it should be that.)
- infogulch 5y ago> The branch coverage thing is a weird, artificial-seeming requirement Yes that's because it's a requirement designed by a standards body. I found a paper "Is 100% Test Coverage a Reasonable Requirement? Lessons Learned from a Space Software Project" (2017) that mentions that 100% branch coverage is a requirement in European Cooperation for Space Standardization (ECSS) for Class A software (where failure could result in loss of life, etc). The paper concluded: > Our findings include that there seems to be a break-even point between 80% and 95%, and everything beyond this points is increasingly costly and could introduce new project risks—which confirms findings reported so far in literature (Section 5). However, the interview revealed that, still, 100% coverage can be a reasonable quality requirement; even though a 100% requirement is not a good indicator for the software quality as such. https://www.researchgate.net/publication/319141355_Is_100_Test_Coverage_a_Reasonable_Requirement_Lessons_Learned_from_a_Space_Software_Project https://www.researchgate.net/publication/319141355_Is_100_Te... It doesn't follow that because rust is a safe language that it cannot expose test harnesses that would enable 100% branch coverage. Personally I'm ambivalent on this, maybe it's not useful, but it doesn't seem bad either. But your reaction to this requirement seems weird, like the "fox and the grapes" fable... You can't get 100%-branch coverage, so you give up and claim that 100% branch coverage is dumb, why would anyone want that anyway? Do you really think that 100% branch coverage testing should be unavailable to rust programmers if that's what they need (for whatever reason, including meeting some admittedly arbitrary standard)?
- tptacek 5y agoA couple of people have brought this up here, and it's an argument that makes sense. I'll just note that the sqlite page, which is what I'm critiquing, isn't written this way; the project doesn't say "we use C because ECSS requires us to build software in an 100%-branch-coverage language", but rather speaks to the important benefit of literal 100% branch coverage. It's that important benefit I question, not the logistics problems they face, which I concede.
- infogulch 5y agoThat might just be me twice, I added a new reference this time at least ^_^ I agree that 100% branch coverage as a goal in and of itself is generally dubious. I seem to recall an interview where the SQLite creator, Richard Hipp, described the reasons behind the branch coverage testing in a bit more detail and mentioned that it was a requirement from one of their customers, which is where I got that idea. Sorry I don't have a specific reference.