diff --git a/example/lcov.info b/example/lcov.info index c89e8172..2ffea7b1 100644 --- a/example/lcov.info +++ b/example/lcov.info @@ -1,5 +1,5 @@ -TN:example # source: https://github.com/linux-test-project/lcov/blob/07a1127c2b4390abf4a516e9763fb28a956a9ce4/tests/lcov/merge/a.info#L1-L38 +TN:example SF:a.cpp DA:1,1 #common line: my count is zero and yours is nonzero diff --git a/example/nodes.json b/example/nodes.json index f047ec36..bab9ac49 100644 --- a/example/nodes.json +++ b/example/nodes.json @@ -3,17 +3,17 @@ "done": false, "incomplete": false, "value": [ - "example" + " source: https://github.com/linux-test-project/lcov/blob/07a1127c2b4390abf4a516e9763fb28a956a9ce4/tests/lcov/merge/a.info#L1-L38" ], - "variant": 14 + "variant": 4 }, { "done": false, "incomplete": false, "value": [ - " source: https://github.com/linux-test-project/lcov/blob/07a1127c2b4390abf4a516e9763fb28a956a9ce4/tests/lcov/merge/a.info#L1-L38" + "example" ], - "variant": 4 + "variant": 14 }, { "done": false, diff --git a/src/lib/handle-result.ts b/src/lib/handle-result.ts index 8c57e2c0..36ba36bc 100644 --- a/src/lib/handle-result.ts +++ b/src/lib/handle-result.ts @@ -24,7 +24,7 @@ export function handleResult(entry: EntryVariants, functionMap: FunctionMap, sec section.path = entry.path break case Variant.EndOfRecord: - // we've left the test module, to prevent name conflicts simply clear the current FunctionMap + // we've left the test module, to prevent name conflicts clear the current FunctionMap functionMap.clear() return true @@ -61,16 +61,8 @@ export function updateResults( functionMap: FunctionMap, sections: SectionSummary[] ): number { - if (entry.variant === Variant.TestName) { - const length = sections.length - // creating a new test module, clearing the current FunctionMap - functionMap.clear() - - sections.push(createSection(entry)) - - return length - } else if (sectionIndex === sections.length) { - // prevent OOB, which happens if "TestName" isn't the first variant encountered for a section + if (sectionIndex === sections.length) { + // the section for the current index doesn't exist, creating a new one with default values sections[sectionIndex] = createSection() } diff --git a/src/tests/handle-result.spec.ts b/src/tests/handle-result.spec.ts index d34177fa..14534d59 100644 --- a/src/tests/handle-result.spec.ts +++ b/src/tests/handle-result.spec.ts @@ -431,8 +431,11 @@ describe('updateResults', (): void => { [ getTestNameEntry('example #1'), getFilePathEntry('path/to/file.ext'), + getEndOfRecord(), getTestNameEntry('example #2'), - getTestNameEntry('example #3') + getEndOfRecord(), + getTestNameEntry('example #3'), + getEndOfRecord() ], [ {