Skip to content

Commit

Permalink
changed updateResults implementation to no longer rely on name bein…
Browse files Browse the repository at this point in the history
…g the first entry
  • Loading branch information
friedemannsommer committed Nov 12, 2023
1 parent ee35b6c commit b6495b6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 17 deletions.
2 changes: 1 addition & 1 deletion example/lcov.info
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 4 additions & 4 deletions example/nodes.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
14 changes: 3 additions & 11 deletions src/lib/handle-result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
}

Expand Down
5 changes: 4 additions & 1 deletion src/tests/handle-result.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
],
[
{
Expand Down

0 comments on commit b6495b6

Please sign in to comment.