Skip to content

Commit

Permalink
runtime config is now provided by rooibosC
Browse files Browse the repository at this point in the history
  • Loading branch information
George Cook committed Jun 5, 2019
1 parent 8367146 commit 774ade1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 44 deletions.
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
37 changes: 7 additions & 30 deletions src/Rooibos_TestRunner.brs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 774ade1

Please sign in to comment.