Skip to content
This repository has been archived by the owner on Jul 8, 2019. It is now read-only.

Commit

Permalink
Merge PR #100 fixing LCOV handling with multiple exclamations
Browse files Browse the repository at this point in the history
  • Loading branch information
Pablissimo committed Feb 4, 2017
2 parents 99b61e8 + 6a86fcb commit cc5572e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main/java/com/pablissimo/sonar/LCOVParserImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ private FileData loadCurrentFileData(final Map<InputFile, FileData> files, Strin

// Try to accommodate Angular projects that, when the angular template loader's used
// by checking for a ! in the filepath if the path isn't found - have a bash at seeking
// everything after the ! as a second fallback pass
if (inputFile == null && filePath.contains("!") && (filePath.indexOf("!") + 1) < filePath.length()) {
String amendedPath = filePath.substring(filePath.indexOf("!") + 1);
// everything after the last ! as a second fallback pass
if (inputFile == null && filePath.contains("!") && (filePath.lastIndexOf("!") + 1) < filePath.length()) {
String amendedPath = filePath.substring(filePath.lastIndexOf("!") + 1);

LOG.debug("Failed to resolve " + filePath + " as a valid source file, so attempting " + amendedPath + " instead");

Expand Down
12 changes: 12 additions & 0 deletions src/test/java/com/pablissimo/sonar/LCOVParserImplTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ public void parsesAngularTemplateLoaderOutput() {
assertEquals(3, c.linesToCover());
}

@Test
public void parsesAngularTemplateLoaderOutput_IfPassedThroughMultipleLoaders() {
Map<InputFile, NewCoverage> coverage = executeForTestCase("angularmanybangs");
DefaultCoverage c = (DefaultCoverage) coverage.get(this.inputFile);

assertEquals((Integer) 3, c.hitsByLine().get(1));
assertEquals((Integer) 0, c.hitsByLine().get(2));
assertEquals((Integer) 1, c.hitsByLine().get(3));

assertEquals(3, c.linesToCover());
}

@Test
public void handlesNoContent() {
Map<InputFile, NewCoverage> coverage = executeForTestCase("blank");
Expand Down
5 changes: 5 additions & 0 deletions src/test/resources/lcov/angularmanybangs.lcov
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SF:path/to/template/loader.js!path/to/some/other/loader.js!path/to/file.ts
DA:1,3
DA:2,0
DA:3,1
end_of_record

0 comments on commit cc5572e

Please sign in to comment.