[Issue 18377] New: -cov LOC is inadequate for 1 liner branching; need a metric based on branching
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Feb 5 19:31:32 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=18377
Issue ID: 18377
Summary: -cov LOC is inadequate for 1 liner branching; need a
metric based on branching
Product: D
Version: D2
Hardware: x86
OS: Mac OS X
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: timothee.cour2 at gmail.com
`dmd -cov -run main.d` shows 100% coverage; this is misleading since a branch
is not taken:
```
void main(){
int a;
if(false) a+=10;
}
```
how about adding a `-covmode=[loc|branch]` that would allow either reporting
LOC coverage or branch coverage?
branch coverage would report number of branches taken at least once / total
number of branches.
It would not only address the above issue, but it is IMO a much better metric
for coverage, less sensitive to 'overcounting' of large blocks in main code
branches (size of code block in a branch is irrelevant as far as testing is
concerned); eg:
```
int fun(int x){
if(x<0)
return fun2(); // accounts for 1 LOC and 1 branch
// long block of non-branching code here... // accounts for 10 LOC and 1
branch
}
```
NOTE: branches would include anything that allows more than 1 code path (eg:
switch, if)
--
More information about the Digitalmars-d-bugs
mailing list