Bug 18377 – -cov LOC is inadequate for 1 liner branching; need a metric based on branching

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Mac OS X
Creation time
2018-02-05T19:31:32Z
Last change time
2024-12-13T18:56:45Z
Assigned to
No Owner
Creator
Timothee Cour
Moved to GitHub: dmd#19380 →

Comments

Comment #0 by timothee.cour2 — 2018-02-05T19:31:32Z
`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)
Comment #1 by robert.schadek — 2024-12-13T18:56:45Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19380 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB