Skip to content

Commit

Permalink
Merge pull request #271 from georgejecook/bugfix/codecoverage-missing…
Browse files Browse the repository at this point in the history
…-expected-lines
  • Loading branch information
chrisdp authored Feb 10, 2024
2 parents bb4aad9 + ffdc3ca commit f9c9ab8
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 152 deletions.
2 changes: 1 addition & 1 deletion bsc-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@types/node": "^14.18.41",
"@typescript-eslint/eslint-plugin": "^5.27.0",
"@typescript-eslint/parser": "^5.27.0",
"brighterscript": "^0.65.15",
"brighterscript": "^0.65.22",
"chai": "^4.2.0",
"chai-subset": "^1.6.0",
"coveralls": "^3.0.0",
Expand Down
8 changes: 6 additions & 2 deletions bsc-plugin/src/lib/rooibos/CodeCoverageProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,11 @@ export class CodeCoverageProcessor {
}
}), { walkMode: WalkMode.visitAllRecursive });


this.expectedCoverageMap[this.fileId.toString().trim()] = Array.from(this.coverageMap);
const coverageMapObject = {};
for (let key of this.coverageMap.keys()) {
coverageMapObject[key] = this.coverageMap.get(key);
}
this.expectedCoverageMap[this.fileId.toString().trim()] = coverageMapObject;
this.filePathMap[this.fileId] = file.pkgPath;
this.addBrsAPIText(file, astEditor);
}
Expand Down Expand Up @@ -188,6 +191,7 @@ export class CodeCoverageProcessor {
}

private getFuncCallText(lineNumber: number, lineType: CodeCoverageLineType) {
this.coverageMap.set(lineNumber, lineType);
return `RBS_CC_${this.fileId}_reportLine("${lineNumber.toString().trim()}", ${lineType.toString().trim()})`;
}
}
6 changes: 4 additions & 2 deletions bsc-plugin/src/plugin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,8 @@ describe('RooibosPlugin', () => {
sub main()
Rooibos_init("RooibosScene")
print "hello"
end sub'//# sourceMappingURL=./test.spec.bs.map
end sub
'//# sourceMappingURL=./test.spec.brs.map
`, [
// print "h|ello" => print |"hello"
{ dest: [2, 12], src: [2, 26] }
Expand Down Expand Up @@ -408,7 +409,8 @@ describe('RooibosPlugin', () => {
instance = __ATest_builder()
instance.new()
return instance
end function'//# sourceMappingURL=./test.spec.bs.map
end function
'//# sourceMappingURL=./test.spec.brs.map
`, [
// m.assert|Equal("123", ("alpha-" + bslib_toString(number) + "-beta")) => m.|assertEqual("123", `alpha-${number}-beta`)
{ dest: [6, 16], src: [8, 26] },
Expand Down
3 changes: 2 additions & 1 deletion tests/bsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"failFast": false,
"sendHomeOnFinish": false,
"keepAppOpen": true,
"isGlobalMethodMockingEnabled": true
"isGlobalMethodMockingEnabled": true,
"isRecordingCodeCoverage": false
},
"sourceMap": true
}
152 changes: 7 additions & 145 deletions tests/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"watch": "npx bsc --project bsconfig.json --watch"
},
"devDependencies": {
"brighterscript": "^0.65.15",
"brighterscript": "^0.65.22",
"ts-node": "^10.7.0",
"typescript": "^4.6.4"
},
Expand Down
36 changes: 36 additions & 0 deletions tests/src/source/CodeCoverage.bs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
function hitAllStatements() as dynamic
loopCount = 0
for i = 0 to 10
loopCount++
end for

tryAgain:
if loopCount = 11 then
loopCount++
goto tryAgain
else if loopCount = 12 then
loopCount++
goto tryAgain
else
loopCount++
end if

while loopCount > 0
loopCount--
if loopCount = 1 then
exit while
end if
end while

obj = {
one: 1
}
obj["two"] = 2
obj.three = 3

for each key in obj
print obj[key]
end for

return false
end function
Loading

0 comments on commit f9c9ab8

Please sign in to comment.