spideruci / tacoco

Integrated Software Analysis Framework
https://github.com/spideruci/tacoco
MIT License
8 stars 7 forks source link

Bug in reader #113

Closed kajdreef closed 4 years ago

kajdreef commented 4 years ago

If sourcefile coverage doesn't contain any lines we shouldn't try to add it to the coverage matrix (it causes a null pointer exception).

I ran tacoco on commons-io using the following commands:

mvn exec:java -Plauncher -Dtacoco.sut=$project -Dtacoco.home=$TACOCO_HOME -Dtacoco.project=$project_name -Danalyzer.opts="configs/tacoco-analyzer.config"

mvn exec:java -Panalyzer -Dtacoco.sut=$project -Dtacoco.exec=tacoco_output/$project_name.exec -Dtacoco.json=tacoco_output/$project_name.json

mvn exec:java -Preader -Dtacoco.json=tacoco_output/$project_name.json

The final step would crash, due to a null pointer exception. It seems the problem lies in a few files being outputted like this by the analyzer:

 {
    "name": "FileAlterationListener.java",
    "packagename": "org/apache/commons/io/monitor",
    "sessionName": "testFileCleanerDirectory().[engine:junit-jupiter]/[class:org.apache.commons.io.FileCleaningTrackerTestCase]/[method:testFileCleanerDirectory()]",
    "format": "LOOSE",
    "firstLine": -1,
    "lastLine": -1
},

As a result, when reading this and trying to output the line coverage for each test case it crashes because when converting the json to object the lines attribute was initialized to null.