From 8367146f8f6a13e1183fb23aa6da92cc8253a14b Mon Sep 17 00:00:00 2001 From: George Cook Date: Tue, 4 Jun 2019 20:59:05 -0500 Subject: [PATCH 1/3] fix for box crash on asString when used on an aa with mock methods --- frameworkTests/source/tests/BasicTests.brs | 12 ++++++++++++ src/Rooibos_CommonUtils.brs | 4 +++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/frameworkTests/source/tests/BasicTests.brs b/frameworkTests/source/tests/BasicTests.brs index cf6564de..f6aee906 100644 --- a/frameworkTests/source/tests/BasicTests.brs +++ b/frameworkTests/source/tests/BasicTests.brs @@ -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 '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/src/Rooibos_CommonUtils.brs b/src/Rooibos_CommonUtils.brs index ef481d0b..0f5ce968 100755 --- a/src/Rooibos_CommonUtils.brs +++ b/src/Rooibos_CommonUtils.brs @@ -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 From 774ade1ec8740fbb15d4025cd607674224bebab6 Mon Sep 17 00:00:00 2001 From: George Cook Date: Tue, 4 Jun 2019 20:59:28 -0500 Subject: [PATCH 2/3] runtime config is now provided by rooibosC --- docs/index.md | 17 +++-------------- src/Rooibos_TestRunner.brs | 37 +++++++------------------------------ 2 files changed, 10 insertions(+), 44 deletions(-) diff --git a/docs/index.md b/docs/index.md index 2c7ccfad..838eb54f 100644 --- a/docs/index.md +++ b/docs/index.md @@ -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._ diff --git a/src/Rooibos_TestRunner.brs b/src/Rooibos_TestRunner.brs index e866ac89..9d680d5f 100644 --- a/src/Rooibos_TestRunner.brs +++ b/src/Rooibos_TestRunner.brs @@ -15,36 +15,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 'mix in parsed in args @@ -148,7 +125,7 @@ sub RBS_TR_Run() skipSuite: end for m.logger.PrintStatistic(totalStatObj) - + if RBS_CMN_IsFunction(RBS_ReportCodeCoverage) RBS_ReportCodeCoverage() end if From 3c8106406baaff619ad216ff8a062e8407256709 Mon Sep 17 00:00:00 2001 From: George Cook Date: Tue, 4 Jun 2019 20:59:45 -0500 Subject: [PATCH 3/3] bounce to 3.0.3 --- CHANGELOG.md | 20 ++++++++++ dist/rooibosDist.brs | 35 +++++------------ docs/Rooibos.brs.html | 2 +- docs/Rooibos_BaseTestSuite.brs.html | 2 +- docs/Rooibos_CommonUtils.brs.html | 6 ++- docs/Rooibos_ItemGenerator.brs.html | 2 +- docs/Rooibos_TestRunner.brs.html | 39 ++++--------------- docs/index.html | 2 +- docs/module-BaseTestSuite.html | 2 +- docs/module-CommonUtils.html | 2 +- docs/module-ItemGenerator.html | 2 +- docs/module-TestRunner.html | 2 +- docs/module-rooibosh.html | 2 +- package.json | 2 +- .../source/tests/rooibos/rooibosDist.brs | 35 +++++------------ 15 files changed, 60 insertions(+), 95 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec18b3e0..0a3bdf08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/dist/rooibosDist.brs b/dist/rooibosDist.brs index 0b12f640..e137f17e 100644 --- a/dist/rooibosDist.brs +++ b/dist/rooibosDist.brs @@ -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 @@ -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" diff --git a/docs/Rooibos.brs.html b/docs/Rooibos.brs.html index b6b37a73..e750601f 100644 --- a/docs/Rooibos.brs.html +++ b/docs/Rooibos.brs.html @@ -126,7 +126,7 @@

Rooibos.brs


- Generated by JSDoc 3.5.5 on Tue May 28 2019 11:14:36 GMT-0500 (-05) using the Minami theme. + Generated by JSDoc 3.5.5 on Tue Jun 04 2019 20:26:45 GMT-0500 (-05) using the Minami theme.
diff --git a/docs/Rooibos_BaseTestSuite.brs.html b/docs/Rooibos_BaseTestSuite.brs.html index 9b550baf..e0df0955 100644 --- a/docs/Rooibos_BaseTestSuite.brs.html +++ b/docs/Rooibos_BaseTestSuite.brs.html @@ -2005,7 +2005,7 @@

Rooibos_BaseTestSuite.brs


- Generated by JSDoc 3.5.5 on Tue May 28 2019 11:14:36 GMT-0500 (-05) using the Minami theme. + Generated by JSDoc 3.5.5 on Tue Jun 04 2019 20:26:45 GMT-0500 (-05) using the Minami theme.
diff --git a/docs/Rooibos_CommonUtils.brs.html b/docs/Rooibos_CommonUtils.brs.html index e3e3567d..bb94e232 100644 --- a/docs/Rooibos_CommonUtils.brs.html +++ b/docs/Rooibos_CommonUtils.brs.html @@ -347,7 +347,9 @@

Rooibos_CommonUtils.brs

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 @@ -598,7 +600,7 @@

Rooibos_CommonUtils.brs


- Generated by JSDoc 3.5.5 on Tue May 28 2019 11:14:36 GMT-0500 (-05) using the Minami theme. + Generated by JSDoc 3.5.5 on Tue Jun 04 2019 20:26:45 GMT-0500 (-05) using the Minami theme.
diff --git a/docs/Rooibos_ItemGenerator.brs.html b/docs/Rooibos_ItemGenerator.brs.html index b7044e32..0f6fdd9a 100644 --- a/docs/Rooibos_ItemGenerator.brs.html +++ b/docs/Rooibos_ItemGenerator.brs.html @@ -273,7 +273,7 @@

Rooibos_ItemGenerator.brs


- Generated by JSDoc 3.5.5 on Tue May 28 2019 11:14:36 GMT-0500 (-05) using the Minami theme. + Generated by JSDoc 3.5.5 on Tue Jun 04 2019 20:26:45 GMT-0500 (-05) using the Minami theme.
diff --git a/docs/Rooibos_TestRunner.brs.html b/docs/Rooibos_TestRunner.brs.html index 1ca2788a..b2c66149 100644 --- a/docs/Rooibos_TestRunner.brs.html +++ b/docs/Rooibos_TestRunner.brs.html @@ -56,36 +56,13 @@

Rooibos_TestRunner.brs

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 'mix in parsed in args @@ -189,7 +166,7 @@

Rooibos_TestRunner.brs

skipSuite: end for m.logger.PrintStatistic(totalStatObj) - + if RBS_CMN_IsFunction(RBS_ReportCodeCoverage) RBS_ReportCodeCoverage() end if @@ -437,7 +414,7 @@

Rooibos_TestRunner.brs


- Generated by JSDoc 3.5.5 on Tue May 28 2019 11:14:36 GMT-0500 (-05) using the Minami theme. + Generated by JSDoc 3.5.5 on Tue Jun 04 2019 20:26:45 GMT-0500 (-05) using the Minami theme.
diff --git a/docs/index.html b/docs/index.html index 77e3a790..908aed97 100644 --- a/docs/index.html +++ b/docs/index.html @@ -57,7 +57,7 @@
- Generated by JSDoc 3.5.5 on Tue May 28 2019 11:14:36 GMT-0500 (-05) using the Minami theme. + Generated by JSDoc 3.5.5 on Tue Jun 04 2019 20:26:45 GMT-0500 (-05) using the Minami theme.
diff --git a/docs/module-BaseTestSuite.html b/docs/module-BaseTestSuite.html index 96d9f62b..139c8c28 100644 --- a/docs/module-BaseTestSuite.html +++ b/docs/module-BaseTestSuite.html @@ -12420,7 +12420,7 @@
Returns:

- Generated by JSDoc 3.5.5 on Tue May 28 2019 11:14:36 GMT-0500 (-05) using the Minami theme. + Generated by JSDoc 3.5.5 on Tue Jun 04 2019 20:26:45 GMT-0500 (-05) using the Minami theme.
diff --git a/docs/module-CommonUtils.html b/docs/module-CommonUtils.html index 28f84d6e..f7f5b8c3 100644 --- a/docs/module-CommonUtils.html +++ b/docs/module-CommonUtils.html @@ -5062,7 +5062,7 @@
Returns:

- Generated by JSDoc 3.5.5 on Tue May 28 2019 11:14:36 GMT-0500 (-05) using the Minami theme. + Generated by JSDoc 3.5.5 on Tue Jun 04 2019 20:26:45 GMT-0500 (-05) using the Minami theme.
diff --git a/docs/module-ItemGenerator.html b/docs/module-ItemGenerator.html index affccd54..73ebdfdd 100644 --- a/docs/module-ItemGenerator.html +++ b/docs/module-ItemGenerator.html @@ -1442,7 +1442,7 @@
Returns:

- Generated by JSDoc 3.5.5 on Tue May 28 2019 11:14:36 GMT-0500 (-05) using the Minami theme. + Generated by JSDoc 3.5.5 on Tue Jun 04 2019 20:26:45 GMT-0500 (-05) using the Minami theme.
diff --git a/docs/module-TestRunner.html b/docs/module-TestRunner.html index 7dc5fe48..f6039f5e 100644 --- a/docs/module-TestRunner.html +++ b/docs/module-TestRunner.html @@ -651,7 +651,7 @@

Run
- Generated by JSDoc 3.5.5 on Tue May 28 2019 11:14:36 GMT-0500 (-05) using the Minami theme. + Generated by JSDoc 3.5.5 on Tue Jun 04 2019 20:26:45 GMT-0500 (-05) using the Minami theme.
diff --git a/docs/module-rooibosh.html b/docs/module-rooibosh.html index b2bede08..24c57c06 100644 --- a/docs/module-rooibosh.html +++ b/docs/module-rooibosh.html @@ -294,7 +294,7 @@
Parameters:

- Generated by JSDoc 3.5.5 on Tue May 28 2019 11:14:36 GMT-0500 (-05) using the Minami theme. + Generated by JSDoc 3.5.5 on Tue Jun 04 2019 20:26:45 GMT-0500 (-05) using the Minami theme.
diff --git a/package.json b/package.json index 2991bd34..345c8611 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/samples/example/source/tests/rooibos/rooibosDist.brs b/samples/example/source/tests/rooibos/rooibosDist.brs index 0b12f640..e137f17e 100644 --- a/samples/example/source/tests/rooibos/rooibosDist.brs +++ b/samples/example/source/tests/rooibos/rooibosDist.brs @@ -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 @@ -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"