Skip to content

Commit

Permalink
Merge pull request #54 from georgejecook/feature/move_json_config
Browse files Browse the repository at this point in the history
Feature/move json config
  • Loading branch information
georgejecook authored Jun 5, 2019
2 parents dd47d74 + 3c81064 commit 3b5737e
Show file tree
Hide file tree
Showing 19 changed files with 85 additions and 140 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# Rooibos CHANGELOG

## 3.0.3 - out of beta - yay!

### Added

- loads runtime config from a rooibosC generated function which
- enables fail fast mode
- enables show only failures mode.

### Changed

### Deprecated

### Removed

- testConfig.json file - we now use rooibosC flags for everything

### Fixed

- crash when any function calls asString on an aa that has mocked functions

## 3.0.2-beta

### Added
Expand Down
35 changes: 9 additions & 26 deletions dist/rooibosDist.brs
Original file line number Diff line number Diff line change
Expand Up @@ -1363,7 +1363,9 @@ function RBS_CMN_AsString(input ) as string
isFirst = false
end if
for each key in input
text += key + ":" + RBS_CMN_AsString(input[key])
if key <> "__mocks" and key <> "__stubs"
text += key + ":" + RBS_CMN_AsString(input[key])
end if
end for
text += "}"
return text
Expand Down Expand Up @@ -1932,32 +1934,13 @@ function RBS_TR_TestRunner(args = {}) as object
this = {}
this.testScene = args.testScene
this.nodeContext = args.nodeContext
fs = CreateObject("roFileSystem")
defaultConfig = {
logLevel : 1,
testsDirectory: "pkg:/source/Tests",
testFilePrefix: "Test__",
failFast: false,
showOnlyFailures: false,
maxLinesWithoutSuiteDirective: 100
}
rawConfig = invalid
config = invalid
if (args.testConfigPath <> invalid and fs.Exists(args.testConfigPath))
? "Loading test config from " ; args.testConfigPath
rawConfig = ReadAsciiFile(args.testConfigPath)
else if (fs.Exists("pkg:/source/tests/testconfig.json"))
? "Loading test config from default location : pkg:/source/tests/testconfig.json"
rawConfig = ReadAsciiFile("pkg:/source/tests/testconfig.json")
else
? "None of the testConfig.json locations existed"
end if
if (rawConfig <> invalid)
config = ParseJson(rawConfig)
end if
if (config = invalid or not RBS_CMN_IsAssociativeArray(config) or RBS_CMN_IsNotEmptyString(config.rawtestsDirectory))
config = RBSFM_getRuntimeConfig()
if (config = invalid or not RBS_CMN_IsAssociativeArray(config))
? "WARNING : specified config is invalid - using default"
config = defaultConfig
config = {
showOnlyFailures: false
failFast: false
}
end if
if (args.showOnlyFailures <> invalid)
config.showOnlyFailures = args.showOnlyFailures = "true"
Expand Down
2 changes: 1 addition & 1 deletion docs/Rooibos.brs.html
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ <h1 class="page-title">Rooibos.brs</h1>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue May 28 2019 11:14:36 GMT-0500 (-05) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Jun 04 2019 20:26:45 GMT-0500 (-05) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/Rooibos_BaseTestSuite.brs.html
Original file line number Diff line number Diff line change
Expand Up @@ -2005,7 +2005,7 @@ <h1 class="page-title">Rooibos_BaseTestSuite.brs</h1>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue May 28 2019 11:14:36 GMT-0500 (-05) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Jun 04 2019 20:26:45 GMT-0500 (-05) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
6 changes: 4 additions & 2 deletions docs/Rooibos_CommonUtils.brs.html
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,9 @@ <h1 class="page-title">Rooibos_CommonUtils.brs</h1>
isFirst = false
end if
for each key in input
text += key + ":" + RBS_CMN_AsString(input[key])
if key &lt;> "__mocks" and key &lt;> "__stubs"
text += key + ":" + RBS_CMN_AsString(input[key])
end if
end for
text += "}"
return text
Expand Down Expand Up @@ -598,7 +600,7 @@ <h1 class="page-title">Rooibos_CommonUtils.brs</h1>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue May 28 2019 11:14:36 GMT-0500 (-05) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Jun 04 2019 20:26:45 GMT-0500 (-05) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/Rooibos_ItemGenerator.brs.html
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ <h1 class="page-title">Rooibos_ItemGenerator.brs</h1>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue May 28 2019 11:14:36 GMT-0500 (-05) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Jun 04 2019 20:26:45 GMT-0500 (-05) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
39 changes: 8 additions & 31 deletions docs/Rooibos_TestRunner.brs.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,36 +56,13 @@ <h1 class="page-title">Rooibos_TestRunner.brs</h1>
this = {}
this.testScene = args.testScene
this.nodeContext = args.nodeContext
fs = CreateObject("roFileSystem")
defaultConfig = {
logLevel : 1,
testsDirectory: "pkg:/source/Tests",
testFilePrefix: "Test__",
failFast: false,
showOnlyFailures: false,
maxLinesWithoutSuiteDirective: 100
}

rawConfig = invalid
config = invalid

if (args.testConfigPath &lt;> invalid and fs.Exists(args.testConfigPath))
? "Loading test config from " ; args.testConfigPath
rawConfig = ReadAsciiFile(args.testConfigPath)
else if (fs.Exists("pkg:/source/tests/testconfig.json"))
? "Loading test config from default location : pkg:/source/tests/testconfig.json"
rawConfig = ReadAsciiFile("pkg:/source/tests/testconfig.json")
else
? "None of the testConfig.json locations existed"
end if

if (rawConfig &lt;> invalid)
config = ParseJson(rawConfig)
end if

if (config = invalid or not RBS_CMN_IsAssociativeArray(config) or RBS_CMN_IsNotEmptyString(config.rawtestsDirectory))
config = RBSFM_getRuntimeConfig()
if (config = invalid or not RBS_CMN_IsAssociativeArray(config))
? "WARNING : specified config is invalid - using default"
config = defaultConfig
config = {
showOnlyFailures: false
failFast: false
}
end if

'mix in parsed in args
Expand Down Expand Up @@ -189,7 +166,7 @@ <h1 class="page-title">Rooibos_TestRunner.brs</h1>
skipSuite:
end for
m.logger.PrintStatistic(totalStatObj)

if RBS_CMN_IsFunction(RBS_ReportCodeCoverage)
RBS_ReportCodeCoverage()
end if
Expand Down Expand Up @@ -437,7 +414,7 @@ <h1 class="page-title">Rooibos_TestRunner.brs</h1>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue May 28 2019 11:14:36 GMT-0500 (-05) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Jun 04 2019 20:26:45 GMT-0500 (-05) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue May 28 2019 11:14:36 GMT-0500 (-05) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Jun 04 2019 20:26:45 GMT-0500 (-05) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
17 changes: 3 additions & 14 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,25 +158,14 @@ There are two ways to invoke RooibosC:
| `-o` | `--outputPath` | you can also specity the _"outputPath"_. This is where rooibosC will write the map file, and other files it needs which informs rooibos about your tests. It is relative to |
| `-v` | `--isRecordingCodeCoverage` | indicates that we want to generate coverage
| `-s` | `--sourceFilePattern` | array of globs, specifying which files to include/exclude in code coverage. Relative to projectPath. Required if `-v` is set. |

| `-f` | `--showFailuresOnly` | Show results for failed tests, if any. If none fail, then all results are shown |
| `-F` | `--failFast` | Test execution will stop at the first failure |


### Configuring Rooibos's runtime behaviour

Rooibos's configuration is controlled via a json config file. The default location for this file is `pkg:/source/tests/rooibos/testconfig.json`.
See [Example app](../samples/example)
If the no testconfig is found a default one will be used.

An example config file looks like this:
Rooibos's configuration is controlled via the configuration passed into the `rooibos-preprocessor` via flags on the `rooibosC` command, or values in the json used to initialize `rooibosC` via the command line, or via javacript code.

```json
{
"logLevel": 1,
"failFast": false,
"swallowRuntimeErrors": false,
"showOnlyFailures": false,
}
```

_Deprecation warning: This behaviour is going to change - in future, these json settings will be merged with the preprocessor config._

Expand Down
2 changes: 1 addition & 1 deletion docs/module-BaseTestSuite.html
Original file line number Diff line number Diff line change
Expand Up @@ -12420,7 +12420,7 @@ <h5>Returns:</h5>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue May 28 2019 11:14:36 GMT-0500 (-05) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Jun 04 2019 20:26:45 GMT-0500 (-05) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/module-CommonUtils.html
Original file line number Diff line number Diff line change
Expand Up @@ -5062,7 +5062,7 @@ <h5>Returns:</h5>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue May 28 2019 11:14:36 GMT-0500 (-05) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Jun 04 2019 20:26:45 GMT-0500 (-05) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/module-ItemGenerator.html
Original file line number Diff line number Diff line change
Expand Up @@ -1442,7 +1442,7 @@ <h5>Returns:</h5>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue May 28 2019 11:14:36 GMT-0500 (-05) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Jun 04 2019 20:26:45 GMT-0500 (-05) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/module-TestRunner.html
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ <h4 class="name" id="Run"><span class="type-signature"></span>Run<span class="si
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue May 28 2019 11:14:36 GMT-0500 (-05) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Jun 04 2019 20:26:45 GMT-0500 (-05) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/module-rooibosh.html
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ <h5>Parameters:</h5>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue May 28 2019 11:14:36 GMT-0500 (-05) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Jun 04 2019 20:26:45 GMT-0500 (-05) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
12 changes: 12 additions & 0 deletions frameworkTests/source/tests/BasicTests.brs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ function BT_EqualsFixForStubbedAAs() as void
aa.getStubbedObject(aa)
end function

'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
'@It tests aa's that get printed as failures don't crash box
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

'@Test
function BT_PrintResultsFixForStubbedAAs() as void
aa = {"test":"value"}
bb = {"other": value}
m.expectOnce(bb, "getStubbedObject", [aa])
assertEqual(aa, bb)
end function

'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
'@It url in params
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rooibos",
"version": "3.0.1-beta",
"version": "3.0.3",
"description": "simple, flexible, fun brihhtscript test framework for roku scenegraph apps",
"main": "index.js",
"directories": {
Expand Down
35 changes: 9 additions & 26 deletions samples/example/source/tests/rooibos/rooibosDist.brs
Original file line number Diff line number Diff line change
Expand Up @@ -1363,7 +1363,9 @@ function RBS_CMN_AsString(input ) as string
isFirst = false
end if
for each key in input
text += key + ":" + RBS_CMN_AsString(input[key])
if key <> "__mocks" and key <> "__stubs"
text += key + ":" + RBS_CMN_AsString(input[key])
end if
end for
text += "}"
return text
Expand Down Expand Up @@ -1932,32 +1934,13 @@ function RBS_TR_TestRunner(args = {}) as object
this = {}
this.testScene = args.testScene
this.nodeContext = args.nodeContext
fs = CreateObject("roFileSystem")
defaultConfig = {
logLevel : 1,
testsDirectory: "pkg:/source/Tests",
testFilePrefix: "Test__",
failFast: false,
showOnlyFailures: false,
maxLinesWithoutSuiteDirective: 100
}
rawConfig = invalid
config = invalid
if (args.testConfigPath <> invalid and fs.Exists(args.testConfigPath))
? "Loading test config from " ; args.testConfigPath
rawConfig = ReadAsciiFile(args.testConfigPath)
else if (fs.Exists("pkg:/source/tests/testconfig.json"))
? "Loading test config from default location : pkg:/source/tests/testconfig.json"
rawConfig = ReadAsciiFile("pkg:/source/tests/testconfig.json")
else
? "None of the testConfig.json locations existed"
end if
if (rawConfig <> invalid)
config = ParseJson(rawConfig)
end if
if (config = invalid or not RBS_CMN_IsAssociativeArray(config) or RBS_CMN_IsNotEmptyString(config.rawtestsDirectory))
config = RBSFM_getRuntimeConfig()
if (config = invalid or not RBS_CMN_IsAssociativeArray(config))
? "WARNING : specified config is invalid - using default"
config = defaultConfig
config = {
showOnlyFailures: false
failFast: false
}
end if
if (args.showOnlyFailures <> invalid)
config.showOnlyFailures = args.showOnlyFailures = "true"
Expand Down
4 changes: 3 additions & 1 deletion src/Rooibos_CommonUtils.brs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,9 @@ function RBS_CMN_AsString(input ) as string
isFirst = false
end if
for each key in input
text += key + ":" + RBS_CMN_AsString(input[key])
if key <> "__mocks" and key <> "__stubs"
text += key + ":" + RBS_CMN_AsString(input[key])
end if
end for
text += "}"
return text
Expand Down
Loading

0 comments on commit 3b5737e

Please sign in to comment.