Kotlin / kotlinx-kover

Apache License 2.0
1.37k stars 53 forks source link

Inline only function #450

Open clickjamper opened 1 year ago

clickjamper commented 1 year ago

In our project we use @kotlin.internal.InlineOnly functions like sortedBy but kover can't cover this lines. How can we do it?

Vladimir43543 commented 1 year ago

We have the same problem. I think this is a bug.

shanshin commented 1 year ago

Hi, could you clarify the coverage of which functions you would like to measure? Are these custom functions marked as InlineOnly?

clickjamper commented 1 year ago

We have this problem in sortedBy function even it was testing. It reproduce on Kotlin v. 1.7.10

zuevmaxim commented 1 year ago

@clickjamper Could you please share a screenshot of an HTML report, where we can see what lines are uncovered? Also, a call point of the method would be helpful

E3FxGaming commented 5 months ago

I made a minimal reproducible example here with Kotlin 1.9.24 and kover 0.8.0. I hope this is the same problem the issue creator and other reporters experienced.

One thing to note in advance: if the Iterable to be sorted with sortedBy only contains <= 1 elements Kotlin will not call the selector function passed to sortedBy. sortedBy calls sortedWith and sortedWith contains this logic here

Whether or not the selector is called, the table above the code shows 0% method coverage specifically for the inline functions.

image

shanshin commented 5 months ago

Depends on the Compiler task https://youtrack.jetbrains.com/issue/KT-68006/Full-debug-information-for-call-of-InlineOnly

aburmeis commented 2 months ago

I have the same problem using Iterable.maxOf() from _Collections.kt wich is also declared inline and marked @kotlin.internal.InlineOnly - Kover reports only some of the 6 branches are covered and I have no branches in my code