diff options
author | iirina <elenairina@google.com> | 2018-08-09 06:49:18 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-08-09 06:50:36 -0700 |
commit | 6620107fb57598450d2cb7327f6b82c0a6e9afc3 (patch) | |
tree | f378693e115386c394769f8f35c7acc2945abc57 /tools/test/LcovMerger/java/com/google/devtools/lcovmerger/GcovParser.java | |
parent | 2fe53b7b2719dd5297da062f4cfcc7bb1e745058 (diff) |
Support 2 more valid gcov info lines in GcovParser.
Closes #5843.
PiperOrigin-RevId: 208041110
Diffstat (limited to 'tools/test/LcovMerger/java/com/google/devtools/lcovmerger/GcovParser.java')
-rw-r--r-- | tools/test/LcovMerger/java/com/google/devtools/lcovmerger/GcovParser.java | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/tools/test/LcovMerger/java/com/google/devtools/lcovmerger/GcovParser.java b/tools/test/LcovMerger/java/com/google/devtools/lcovmerger/GcovParser.java index 25592192b2..e62051e861 100644 --- a/tools/test/LcovMerger/java/com/google/devtools/lcovmerger/GcovParser.java +++ b/tools/test/LcovMerger/java/com/google/devtools/lcovmerger/GcovParser.java @@ -119,19 +119,22 @@ public class GcovParser { return true; } - // function:start_line_number,end_line_number,execution_count,function_name + /** + * Valid lines: function:start_line_number,end_line_number,execution_count,function_name + * function:start_line_number,execution_count,function_name + */ private boolean parseFunction(String line) { String lineContent = line.substring(GCOV_FUNCTION_MARKER.length()); String[] items = lineContent.split(DELIMITER, -1); - if (items.length != 4) { + if (items.length != 4 && items.length != 3) { logger.log(Level.WARNING, "gcov info contains invalid line " + line); return false; } try { // Ignore end_line_number since it's redundant information. int startLine = Integer.parseInt(items[0]); - int execCount = Integer.parseInt(items[2]); - String functionName = items[3]; + int execCount = items.length == 4 ? Integer.parseInt(items[2]) : Integer.parseInt(items[1]); + String functionName = items.length == 4 ? items[3] : items[2]; currentSourceFileCoverage.addLineNumber(functionName, startLine); currentSourceFileCoverage.addFunctionExecution(functionName, execCount); } catch (NumberFormatException e) { @@ -141,11 +144,14 @@ public class GcovParser { return true; } - // lcount:line number,execution_count,has_unexecuted_block + /** + * Valid lines: lcount:line number,execution_count,has_unexecuted_block lcount:line + * number,execution_count + */ private boolean parseLCount(String line) { String lineContent = line.substring(GCOV_LINE_MARKER.length()); String[] items = lineContent.split(DELIMITER, -1); - if (items.length != 3) { + if (items.length != 3 && items.length != 2) { logger.log(Level.WARNING, "gcov info contains invalid line " + line); return false; } |