Open ThomWee opened 5 years ago
@ThomWee It should be true if you didn't use 'JenkinsRule' as Test Rule. Because CoverageElements is loaded by Jenkins.
@Rule
JenkinsRule rule = new JenkinsRule();
Also, could you post your stack trace here :P thanks~
@cizezsy sorry for my late response. I was on vacation.
This is the stack trace I get:
Stack trace:
java.lang.NullPointerException
at java.util.TreeMap.getEntry(TreeMap.java:347)
at java.util.TreeMap.containsKey(TreeMap.java:232)
at io.jenkins.plugins.coverage.targets.CoverageResult.updateCoverage(CoverageResult.java:436)
at io.jenkins.plugins.llvm.LLVMCoverageParser.processElement(LLVMCoverageParser.java:57)
at io.jenkins.plugins.coverage.adapter.parser.CoverageParser.parse(CoverageParser.java:65)
at io.jenkins.plugins.coverage.adapter.parser.CoverageParser.parse(CoverageParser.java:69)
at io.jenkins.plugins.coverage.adapter.parser.CoverageParser.parse(CoverageParser.java:69)
at io.jenkins.plugins.coverage.adapter.parser.CoverageParser.parse(CoverageParser.java:49)
at io.jenkins.plugins.llvm.LLVMCovReportAdapter.parseToResult(LLVMCovReportAdapter.java:38)
at io.jenkins.plugins.coverage.adapter.CoverageReportAdapter.getResult(CoverageReportAdapter.java:49)
at io.jenkins.plugins.llvm.LLVMCoverageParserTest.parseCoverageFromLLVMJSONFile(LLVMCoverageParserTest.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at com.microsoft.java.test.runner.junit4.JUnit4TestReference.run(JUnit4TestReference.java:50)
at com.microsoft.java.test.runner.junit4.CustomizedJUnit4CoreRunner.run(CustomizedJUnit4CoreRunner.java:45)
at com.microsoft.java.test.runner.junit4.JUnit4Launcher.execute(JUnit4Launcher.java:30)
at com.microsoft.java.test.runner.Launcher.main(Launcher.java:56)
If I change the switch-case in LLVMCoverageReport.java
line 56 to
CoverageElement functioElement = CoverageElement.get("LLVM Function");
if (functioElement != null) {
result.updateCoverage(functioElement, Ratio.create(Integer.parseInt(coveredFuncStr), Integer.parseInt(totalFuncStr)));
}
than my test passes, but is this the correct way to fix it? I already have issues with the LLVM json data being not same as Xcode present in its coverage overview, so I can't tell by my own right now what is right and what not.
Pretty late to the party, but I am having the same issue. Any updates on this?
Hi,
I work with your latest master version (Commit ID: 844134b) and get a NullPointer exception while processing our llvm-cov.json file. The crash always happens in LLVMCoverageParser.java L57 While debugging it with a test where I use the same JSON file, I figured out that there is no CoverageElement for "LLVM Function" available.
Now I added a check before proceeding with the result of the CoverageElement get call. But is this the right way doing it?
Best Regards, Thomas