Skip to content

Commit

Permalink
12.1 profiler parser - Handle callee in module name
Browse files Browse the repository at this point in the history
  • Loading branch information
gquerret committed Nov 6, 2019
1 parent e4670a6 commit d5352f7
Show file tree
Hide file tree
Showing 4 changed files with 1,112 additions and 2 deletions.
10 changes: 8 additions & 2 deletions profiler-parser/src/main/java/eu/rssw/antlr/profiler/Module.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,18 @@ public Set<LineData> getLineData() {
* sous-répertoire et extension
*/
public String getModuleObject() {
// Up to 12.0 : name contains either file name or (internal procedure + file name)
// Starting from 12.1: third entry (optional), callee name when using super:xxx() or methods not overidden in child
// class
if (name.indexOf(' ') > -1) {
return name.substring(name.indexOf(' ') + 1);
String tmp = name.substring(name.indexOf(' ') + 1);
if (tmp.indexOf(' ') > -1)
return tmp.substring(0, tmp.indexOf(' '));
else
return tmp;
} else {
return name;
}

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,23 @@ public void testProfiler10() throws IOException {
Assert.assertTrue(session.getModuleById(1).getLinesToCover().contains(-2));
}

@Test
public void testProfiler11() throws IOException {
// New file format in 12.1 - Module name includes callee name when using super:xxx() or methods not overidden in child class
ProfilerSession session = ProfilerUtils.getProfilerSession(new File("src/test/resources/profiler11.out"));
Assert.assertEquals(session.getVersionNumber(), 3);
Assert.assertEquals(session.getModules().size(), 7);
Assert.assertNotNull(session.getModuleByName("MyLogger"));
Assert.assertEquals(session.getModuleByName("MyLogger").getCoveredLines().size(), 3);
Assert.assertEquals(session.getModuleByName("MyLogger").getLinesToCover().size(), 3);

// Same test but using 11.7 profiler
ProfilerSession session2 = ProfilerUtils.getProfilerSession(new File("src/test/resources/profiler12.out"));
Assert.assertEquals(session2.getVersionNumber(), 1);
Assert.assertEquals(session2.getModules().size(), 7);
Assert.assertNotNull(session2.getModuleByName("MyLogger"));
Assert.assertEquals(session2.getModuleByName("MyLogger").getCoveredLines().size(), 3);
Assert.assertEquals(session2.getModuleByName("MyLogger").getLinesToCover().size(), 3);
}

}
Loading

0 comments on commit d5352f7

Please sign in to comment.