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
[Bug]: Uncovered lines are shown as covered when there are annotations #42605
Comments
This issue can be mitigated by removing the position information of the annotation desugered functions from the line number table. This will ignore the lines related to annotations from the code coverage. If we do so, annotation related (annotation desugared functions) lines will be excluded from the stack traces as well. 1 annotation ZeroDiffAnnot zeroDivAnnot on function;
2
3 function zeroDiv(int n) returns boolean {
4 return n / 0 == 0;
5 }
6
7 @zeroDivAnnot {
8 value: "ZeroDiv",
9 out: zeroDiv(10)
10 }
11 function foo(int n) returns int {
12 return n;
13 }
If we remove the line numbers of annotation desugared functions from the line number table, the stack trace will not contain the line |
It seems without removing the positions related to the annotations from the line number table, we can't avoid the annotations from the code coverage. Anyway the code coverage of actual code lines which are need to be covered by the user's test cases are depend on the availability of the tests. |
How do we decide if it is covered? For example, with the original example, a |
Agree. But the following case also panics without the function foo() is being called inside the main. 1 annotation ZeroDiffAnnot zeroDivAnnot on function;
2
3 function zeroDiv(int n) returns boolean {
4 return n / 0 == 0;
5 }
6
7 @zeroDivAnnot {
8 value: "ZeroDiv",
9 out: zeroDiv(10)
10 }
11 function foo(int n) returns int {
12 return n;
13 } This is happening due to the annotation desugared are getting called during the initialization phase. It may not necessary to consider annotations for code coverage, since they usually provide structured metadata about a particular construct. So we can omit annotation related lines from code coverage. |
Spec says, Since the annotations related lines of module-level declarations are evaluated at module initialization, the bytecode instructions related those lines are executed during the test run, even there are no added tests. So jacoco marks those annotation related lines are covered. |
Description
$title. May be related to annotation closures.
Steps to Reproduce
Tests
Affected Version(s)
2201.9.0-rc1
The text was updated successfully, but these errors were encountered: