Skip to content

Commit

Permalink
Fix/doc improvements (#139)
Browse files Browse the repository at this point in the history
* fix test failures

* docs: improves getting started docs

* feat: adds screen output to unit test runs

* doc improvements
  • Loading branch information
georgejecook authored Jan 5, 2022
1 parent 3500c88 commit ba22f41
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 57 deletions.
33 changes: 0 additions & 33 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,5 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "test",
"type": "brightscript",
"request": "launch",
"consoleOutput": "full",
"internalConsoleOptions": "neverOpen",
"preLaunchTask": "build-tests",
"envFile": "${workspaceFolder}/tests/.vscode/.env",
"host": "${env:ROKU_DEV_TARGET}",
"password": "${env:ROKU_DEVPASSWORD}",
"retainStagingFolder": true,
"stopOnEntry": false,
"files": [
"!**/images/*.*",
"!**/fonts/*.*",
"!*.jpg",
"!*.png",
"*",
"*.*",
"**/*.*",
"!*.zip",
"!**/*.zip"
],
"rootDir": "${workspaceFolder}/tests/build",
"sourceDirs": [
"${workspaceFolder}/tests/src",
],
"enableDebuggerAutoRecovery": true,
"stopDebuggerOnAppExit": true,
"enableVariablesPanel": false,
"injectRaleTrackerTask": false,
"enableDebugProtocol": false
}
]
}
18 changes: 0 additions & 18 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build-tests",
"type": "shell",
"command": "gulp build && cd frameworkTests && export TS_NODE_COMPILER_OPTIONS='{\"incremental\":true, \"allowJs\":false}' && export TS_NODE_TRANSPILE_ONLY=true && gulp prePublishTests",
"problemMatcher": [],
"presentation": {
"echo": true,
"reveal": "silent",
"focus": false,
"panel": "shared",
"showReuseMessage": false,
"clear": true
},
"group": {
"kind": "test",
"isDefault": true
}
}
]
}
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ Rooibos is an independent open-source project, maintained exclusively by volunte

You might want to help! Get in touch via the slack group, or raise issues.

## Sample project
https://github.com/georgejecook/rooibos-roku-sample

## Quick start
https://github.com/georgejecook/rooibos/blob/master/docs/index.md#getting-started

## FAQ
### Is Rooibos ready for production use?

Expand Down
11 changes: 8 additions & 3 deletions bsc-plugin/src/lib/rooibos/FileFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,16 @@ export class FileFactory {
${scriptImports.join('\n')}
<interface>
<field id="rooibosTestResult" type="assocarray"/>
<field id="testText" type="string" alias="statusLabel.text" />
<field id="failedText" type="string" alias="failedLabel.text" />
<field id="statusColor" type="string" alias="statusBackground.color" />
<function name='Rooibos_CreateTestNode' />
</interface>
<children>
<LayoutGroup>
<Label text="Rooibos tests are running" />
</LayoutGroup>
<Rectangle id="statusBackground" color="#444444" width="1920" height="1080" />
<Label id="statusLabel" text='Rooibos is running tests' />
<Label id="failedLabel" text="" translation="[0, 100]" width="1800" wrap="true" maxLines="15"/>
</children>
</component>
`;
Expand Down
5 changes: 4 additions & 1 deletion framework/src/source/BaseTestSuite.bs
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,19 @@ namespace rooibos
function run()
for each groupData in m.groupsData
'bs:disable-next-line

group = new TestGroup(m, groupData)
? ""
? rooibos.common.fillText(">>>> Describe: " + group.name, ">", 80)
'bs:disable-next-line
? ` Location: file://${group.testSuite.filePath.trim()}:${group.lineNumber}`
? ""

'bs:disable-next-line
m.groups.push(group)
'bs:disable-next-line
group.run()

'bs:disable-next-line
m.stats.merge(group.stats)

if m.stats.hasFailures and m.isFailingFast = true
Expand Down
11 changes: 11 additions & 0 deletions framework/src/source/CommonUtils.bs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,15 @@ namespace rooibos.Common
if not Rooibos.Common.isNotEmptyString(filename) then return invalid
'bs:disable-next-line
mapFunction = RBSFM_getFunctionsForFile(filename)
'bs:disable-next-line
if mapFunction <> invalid
'bs:disable-next-line
map = mapFunction()
'bs:disable-next-line
if type(map) = "roAssociativeArray"
'bs:disable-next-line
functionPointer = map[functionName]
'bs:disable-next-linenrb
return functionPointer
else
return invalid
Expand Down Expand Up @@ -76,11 +81,17 @@ namespace rooibos.Common
filename = filenames[i]
'bs:disable-next-line
mapFunction = RBSFM_getFunctionsForFile(filename)
'bs:disable-next-line
if mapFunction <> invalid
'bs:disable-next-line
map = mapFunction()
'bs:disable-next-line
if type(map) = "roAssociativeArray"
'bs:disable-next-line
functionPointer = map[functionName]
'bs:disable-next-line
if functionPointer <> invalid
'bs:disable-next-line
return functionPointer
end if
end if
Expand Down
1 change: 1 addition & 0 deletions framework/src/source/ConsoleTestReporter.bs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ namespace rooibos
m.printLine(0, " Passed: " + Rooibos.Common.AsString(m.allStats.passedCount))
m.printLine(0, " Crashed: " + Rooibos.Common.AsString(m.allStats.crashedCount))
m.printLine(0, " Failed: " + Rooibos.Common.AsString(m.allStats.failedCount))
'bs:disable-next-line
m.printLine(0, " Ignored: " + Rooibos.Common.AsString(ignoredInfo.count))
m.printLine(0, " Time: " + Rooibos.Common.AsString(m.allStats.time) + "ms")
m.printLine()
Expand Down
27 changes: 25 additions & 2 deletions framework/src/source/TestRunner.bs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,12 @@ namespace rooibos
timer.mark()
suiteNames = m.runtimeConfig.getAllTestSuitesNames()
includedSuites = []
isFailed = false
failedText = ""
i = 0
numSuites = suiteNames.count()
for each name in suiteNames
i++
'bs:disable-next-line
suiteClass = m.runtimeConfig.getTestSuiteClassWithName(name)
testSuite = invalid
Expand All @@ -59,15 +64,33 @@ namespace rooibos
testSuite.top = m.nodeContext.top
testSuite.scene = m.nodeContext.global.testsScene
testSuite.catchCrashes = m.config.catchCrashes
testSuite.scene.testText = `Running Suite ${i} of ${numSuites}: ${name}`
m.runTestSuite(testSuite)
if m.stats.hasFailures = true and m.config.failFast = true
exit for
if m.stats.hasFailures = true
if not isFailed
isFailed = true
testSuite.scene.statusColor = "#DA3633"
end if
if m.config.failFast = true
exit for
end if
end if

if testSuite.stats.hasFailures
failedText = name + chr(10) + failedText
testSuite.scene.failedText = "Failed Suites: " + chr(10) + failedText
end if
else
? "ERROR! could not create test for suite : "; name
failedText = "COULD NOT CREATE suite " + name + chr(10) + failedText
testSuite.scene.failedText = "Failed Suites: " + chr(10) + failedText
end if
end for

if not isFailed
testSuite.scene.statusColor = "#238636"
end if

m.stats.time = timer.totalMilliseconds()

m.testReporter.reportResults(m.stats)
Expand Down

0 comments on commit ba22f41

Please sign in to comment.