rooibos-roku 5.11.0 → 5.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.md +5 -5
  2. package/dist/lib/framework/BaseTestReporter.bs +6 -6
  3. package/dist/lib/framework/BaseTestSuite.bs +4 -2
  4. package/dist/lib/framework/CommonUtils.bs +3 -1
  5. package/dist/lib/framework/ConsoleTestReporter.bs +2 -10
  6. package/dist/lib/framework/Coverage.bs +30 -11
  7. package/dist/lib/framework/JUnitTestReporter.bs +1 -5
  8. package/dist/lib/framework/Rooibos.bs +7 -2
  9. package/dist/lib/framework/RuntimeConfig.bs +9 -0
  10. package/dist/lib/framework/TestRunner.bs +37 -13
  11. package/dist/lib/rooibos/Annotation.js +200 -200
  12. package/dist/lib/rooibos/CodeCoverageProcessor.js +145 -140
  13. package/dist/lib/rooibos/CodeCoverageProcessor.js.map +1 -1
  14. package/dist/lib/rooibos/CodeCoverageType.js +10 -10
  15. package/dist/lib/rooibos/FileFactory.js +110 -106
  16. package/dist/lib/rooibos/FileFactory.js.map +1 -1
  17. package/dist/lib/rooibos/MockUtil.js +177 -174
  18. package/dist/lib/rooibos/MockUtil.js.map +1 -1
  19. package/dist/lib/rooibos/RawCodeExpression.js +21 -21
  20. package/dist/lib/rooibos/RawCodeStatement.js +24 -24
  21. package/dist/lib/rooibos/RooibosConfig.js +10 -10
  22. package/dist/lib/rooibos/RooibosSession.js +213 -202
  23. package/dist/lib/rooibos/RooibosSession.js.map +1 -1
  24. package/dist/lib/rooibos/RooibosSessionInfo.js +203 -202
  25. package/dist/lib/rooibos/RooibosSessionInfo.js.map +1 -1
  26. package/dist/lib/rooibos/TestCase.js +54 -54
  27. package/dist/lib/rooibos/TestGroup.js +206 -206
  28. package/dist/lib/rooibos/TestSuite.js +104 -100
  29. package/dist/lib/rooibos/TestSuite.js.map +1 -1
  30. package/dist/lib/rooibos/TestSuiteBuilder.js +195 -195
  31. package/dist/lib/rooibos/Utils.js +115 -115
  32. package/dist/lib/rooibos/Utils.js.map +1 -1
  33. package/dist/lib/utils/Diagnostics.js +119 -119
  34. package/dist/plugin.js +226 -202
  35. package/dist/plugin.js.map +1 -1
  36. package/package.json +18 -18
package/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  <p align="center">
2
- <img src="https://github.com/georgejecook/rooibos/raw/master/images/logo.png" alt="Rooibos test framework" width="200" height="200"/>
2
+ <img src="https://github.com/rokucommunity/rooibos/raw/master/images/logo.png" alt="Rooibos test framework" width="200" height="200"/>
3
3
  </p>
4
4
 
5
- [![build](https://img.shields.io/github/workflow/status/georgejecook/rooibos/build.svg?logo=github)](https://github.com/georgejecook/rooibos/actions?query=workflow%3Abuild)
6
- [![GitHub](https://img.shields.io/github/release/georgejecook/rooibos.svg?style=flat-square)](https://github.com/georgejecook/rooibos/releases)
5
+ [![build](https://img.shields.io/github/workflow/status/rokucommunity/rooibos/build.svg?logo=github)](https://github.com/rokucommunity/rooibos/actions?query=workflow%3Abuild)
6
+ [![GitHub](https://img.shields.io/github/release/rokucommunity/rooibos.svg?style=flat-square)](https://github.com/rokucommunity/rooibos/releases)
7
7
  [![NPM Version](https://badge.fury.io/js/rooibos-roku.svg?style=flat)](https://npmjs.org/package/rooibos-roku)
8
8
 
9
9
  ## Links
10
- - **[Documentation](https://github.com/georgejecook/rooibos/blob/master/docs/index.md)**
11
- - **[API Documentation](https://georgejecook.github.io/rooibos)**
10
+ - **[Documentation](https://github.com/rokucommunity/rooibos/blob/master/docs/index.md)**
11
+ - **[API Documentation](https://rokucommunity.github.io/rooibos)**
12
12
  - \#roku channel on the [roku developer's slack](https://join.slack.com/t/rokudevelopers/shared_invite/enQtMzgyODg0ODY0NDM5LTc2ZDdhZWI2MDBmYjcwYTk5MmE1MTYwMTA2NGVjZmJiNWM4ZWY2MjY1MDY0MmViNmQ1ZWRmMWUzYTVhNzJiY2M)
@@ -1,4 +1,8 @@
1
1
  namespace rooibos
2
+ interface ITestReporterOnEndEvent
3
+ stats as rooibos.Stats
4
+ end interface
5
+
2
6
  class BaseTestReporter
3
7
 
4
8
  public testRunner = invalid
@@ -11,15 +15,11 @@ namespace rooibos
11
15
  m.allStats = runner.stats
12
16
  end function
13
17
 
14
- function reportResults(allStats as dynamic)
15
- 'override me
16
- end function
17
-
18
- function testLogInfo(text as string)
18
+ function onBegin(ev as dynamic)
19
19
  'override me
20
20
  end function
21
21
 
22
- function testLogError(text as string)
22
+ function onEnd(ev as rooibos.ITestReporterOnEndEvent)
23
23
  'override me
24
24
  end function
25
25
 
@@ -199,6 +199,8 @@ namespace rooibos
199
199
  m.testRunner.top.unobserveFieldScoped("rooibosGroupFinished")
200
200
  ' m.testGroupDone()
201
201
  m.onAsyncGroupComplete(group)
202
+ else if m.testRunner.top.rooibosGroupFinished
203
+ m.onAsyncGroupComplete(group)
202
204
  end if
203
205
 
204
206
  end if
@@ -1833,7 +1835,7 @@ namespace rooibos
1833
1835
  end if
1834
1836
 
1835
1837
  if not type(stubOrReturnValue).endsWith("Function")
1836
- throw "Did not provide a stub function"
1838
+ ' throw "Did not provide a stub function"
1837
1839
  end if
1838
1840
 
1839
1841
  ' Store the stub on the component scope
@@ -1906,7 +1908,7 @@ namespace rooibos
1906
1908
  ' m.currentResult.fail("Setting up mock failed: " + error.message, m.currentAssertLineNumber)
1907
1909
  ' return false
1908
1910
  ' end try
1909
- return false
1911
+ ' return false
1910
1912
  end function
1911
1913
 
1912
1914
  ' /**
@@ -334,7 +334,9 @@ namespace rooibos.common
334
334
  'bs:disable-next-line
335
335
  isFirst = false
336
336
  end if
337
- for each key in input
337
+ keys = input.keys()
338
+ keys.sort()
339
+ for each key in keys
338
340
  if rooibos.common.canSafelyIterateAAKey(input, key)
339
341
  text = text + key + ":" + rooibos.common.asString(input[key], includeType)
340
342
  end if
@@ -13,8 +13,8 @@ namespace rooibos
13
13
  end if
14
14
  end function
15
15
 
16
- override function reportResults(allStats)
17
- m.allStats = allStats
16
+ override function onEnd(ev as rooibos.ITestReporterOnEndEvent)
17
+ m.allStats = ev.stats
18
18
  m.startReport()
19
19
  for each testSuite in m.testRunner.testSuites
20
20
  if not m.allStats.hasFailures or ((not m.config.showOnlyFailures) or testSuite.stats.failedCount > 0 or testSuite.stats.crashedCount > 0)
@@ -186,14 +186,6 @@ namespace rooibos
186
186
  '++ printing
187
187
  '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
188
188
 
189
- override function testLogInfo(text)
190
- ? "INFO " ; text
191
- end function
192
-
193
- override function testLogError(text)
194
- ? "ERROR " ; text
195
- end function
196
-
197
189
  function printLine(depth = 0, text = "")
198
190
  ? " " ; text
199
191
  end function
@@ -72,7 +72,7 @@ namespace rooibos.Coverage
72
72
  ? "+++++++++++++++++++++++++++++++++++++++++++"
73
73
  end function
74
74
 
75
- function createLCovOutput()
75
+ function createLCovOutput(logToConsole = true as boolean)
76
76
  ? "Generating lcov.info file..."
77
77
 
78
78
  cc = m.global._rbs_ccn
@@ -80,9 +80,10 @@ namespace rooibos.Coverage
80
80
  filePathMap = cc.filePathMap
81
81
  resolvedMap = cc.resolvedMap
82
82
 
83
- buffer = ""
83
+ results = []
84
84
 
85
85
  for each module in filePathMap.items()
86
+ buffer = ""
86
87
  moduleNumber = module.key
87
88
  filePath = module.value
88
89
  packageName = "."
@@ -90,33 +91,51 @@ namespace rooibos.Coverage
90
91
  relativePath = filePath.replace("pkg:", packageName)
91
92
  sanitizedPath = relativePath.replace("\\", "/")
92
93
 
93
- buffer = buffer + "TN:" + chr(10)
94
- buffer = buffer + "SF:" + sanitizedPath + chr(10)
94
+ buffer += "TN:" + chr(10)
95
+ buffer += "SF:" + sanitizedPath + chr(10)
95
96
 
96
97
  for each expected in expectedMap[moduleNumber]
97
- lineNumber = expected[0]
98
+ lineNumber = val(expected)
98
99
  SHIFT = 1
99
100
 
100
- if resolvedMap[moduleNumber] <> invalid and resolvedMap[moduleNumber].doesExist(str(lineNumber))
101
- buffer = buffer + "DA:" + str(lineNumber + SHIFT) + ",1" + chr(10)
101
+ if resolvedMap[moduleNumber] <> invalid and resolvedMap[moduleNumber].doesExist(expected)
102
+ buffer += "DA:" + str(lineNumber + SHIFT).trim() + "," + str(resolvedMap[moduleNumber][expected]).trim() + chr(10)
102
103
  else
103
- buffer = buffer + "DA:" + str(lineNumber + SHIFT) + ",0" + chr(10)
104
+ buffer += "DA:" + str(lineNumber + SHIFT).trim() + ",0" + chr(10)
104
105
  end if
105
106
  end for
106
107
 
107
- buffer = buffer + "end_of_record" + chr(10)
108
+ buffer += "LF:" + str(expectedMap[moduleNumber].count()).trim() + chr(10)
109
+
110
+ if resolvedMap[moduleNumber] <> invalid
111
+ buffer += "LH:" + str(resolvedMap[moduleNumber].count()).trim() + chr(10)
112
+ else
113
+ buffer += "LH:0" + chr(10)
114
+ end if
115
+
116
+ buffer += "end_of_record"
117
+ if logToConsole
118
+ ? buffer
119
+ ' When logging to the console it is very possible to flood the buffer and cause the application to exit.
120
+ ' Sleep for a short amount of time so as to give console scrapers time to empty the buffer
121
+ sleep(30)
122
+ else
123
+ results.push(buffer)
124
+ end if
108
125
  end for
109
- return buffer
126
+
127
+ return results.join(chr(10))
110
128
  end function
111
129
 
112
130
  function printLCovInfo()
131
+
113
132
  ?
114
133
  ? "+++++++++++++++++++++++++++++++++++++++++++"
115
134
  ? "LCOV.INFO FILE"
116
135
  ? "+++++++++++++++++++++++++++++++++++++++++++"
117
136
  ?
118
137
  ? "+-=-coverage:start"
119
- ? rooibos.coverage.createLCovOutput()
138
+ rooibos.coverage.createLCovOutput()
120
139
  ? "+-=-coverage:end"
121
140
  end function
122
141
 
@@ -1,11 +1,7 @@
1
1
  namespace rooibos
2
2
  class JUnitTestReporter extends rooibos.BaseTestReporter
3
3
 
4
- function new(testRunner as dynamic)
5
- super(testRunner)
6
- end function
7
-
8
- override function reportResults(allStats as dynamic)
4
+ override function onEnd(ev as rooibos.ITestReporterOnEndEvent)
9
5
  root = createObject("roXMLElement")
10
6
  root.SetName("testsuites")
11
7
  properties = root.addElement("properties")
@@ -34,7 +34,12 @@ namespace rooibos
34
34
 
35
35
  if runner.config.keepAppOpen = false
36
36
  ? "keepAppOpen is false; exiting Rooibos"
37
- return
37
+ ' End statement will also exit the caller of this function
38
+ ' leading to an instant exit of the application
39
+
40
+ ' Give the io port time to finish sending all the logs
41
+ sleep(400)
42
+ end
38
43
  end if
39
44
  end if
40
45
 
@@ -89,4 +94,4 @@ namespace rooibos
89
94
  return 0
90
95
 
91
96
  end function
92
- end namespace
97
+ end namespace
@@ -1,16 +1,25 @@
1
1
  namespace rooibos
2
2
  class RuntimeConfig
3
3
 
4
+ function new()
5
+ m.testSuites = m.getTestSuiteClassMap()
6
+ end function
7
+
4
8
  function getVersionText()
5
9
  end function
6
10
 
7
11
  function getRuntimeConfig()
8
12
  end function
9
13
 
14
+ function getTestSuiteClassMap()
15
+ end function
16
+
10
17
  function getTestSuiteClassWithName(name)
18
+ return m.testSuites[name]
11
19
  end function
12
20
 
13
21
  function getAllTestSuitesNames()
22
+ return m.testSuites.keys()
14
23
  end function
15
24
 
16
25
  function getIgnoredTestInfo()
@@ -11,7 +11,7 @@ namespace rooibos
11
11
  ' */
12
12
  class TestRunner
13
13
  public testScene = invalid
14
- public testReporter = invalid
14
+ public testReporters = []
15
15
  public nodeContext = invalid
16
16
  public config = invalid
17
17
  public testSuites = []
@@ -33,11 +33,7 @@ namespace rooibos
33
33
  m.runtimeConfig = new rooibos.RuntimeConfig()
34
34
  m.config = m.runtimeConfig.getRuntimeConfig()
35
35
 
36
- if m.config.reporter = "JUnitTestReporter"
37
- m.testReporter = new Rooibos.JUnitTestReporter(m)
38
- else
39
- m.testReporter = new Rooibos.ConsoleTestReporter(m)
40
- end if
36
+ m.testReporters = m.getTestReporters()
41
37
  end function
42
38
 
43
39
  ' /**
@@ -49,6 +45,12 @@ namespace rooibos
49
45
  ' */
50
46
  public function run()
51
47
 
48
+ for each reporter in m.testReporters
49
+ if rooibos.common.isFunction(reporter.onBegin)
50
+ reporter.onBegin({})
51
+ end if
52
+ end for
53
+
52
54
  rooibosTimer = createObject("roTimespan")
53
55
  rooibosTimer.mark()
54
56
  suiteNames = m.runtimeConfig.getAllTestSuitesNames()
@@ -103,7 +105,11 @@ namespace rooibos
103
105
 
104
106
  m.stats.time = rooibosTimer.totalMilliseconds()
105
107
 
106
- m.testReporter.reportResults(m.stats)
108
+ for each reporter in m.testReporters
109
+ if rooibos.common.isFunction(reporter.onEnd)
110
+ reporter.onEnd({ stats: m.stats })
111
+ end if
112
+ end for
107
113
 
108
114
  rooibosResult = {
109
115
  stats: m.stats
@@ -111,9 +117,7 @@ namespace rooibos
111
117
  }
112
118
  m.nodeContext.global.testsScene.rooibosTestResult = rooibosResult
113
119
 
114
- 'bs:disable-next-line
115
- if rooibos.common.isFunction(rooibos.Coverage.reportCodeCoverage)
116
- 'bs:disable-next-line
120
+ if m.config.isRecordingCodeCoverage
117
121
  rooibos.Coverage.reportCodeCoverage()
118
122
 
119
123
  if m.config.printLcov = true
@@ -159,6 +163,7 @@ namespace rooibos
159
163
  ? "Running suite asynchronously!"
160
164
  m.nodeContext.top.observeFieldScoped("rooibosSuiteFinished", "Rooibos_onTestSuiteComplete")
161
165
  testSuite.run()
166
+ return invalid
162
167
  else
163
168
  ? "Running suite synchronously!"
164
169
  testSuite.run()
@@ -252,7 +257,13 @@ namespace rooibos
252
257
  timeout = testSuite.asyncTimeout = invalid ? 60000 : testSuite.asyncTimeout
253
258
 
254
259
  ? "Waiting max " timeout "ms for the test suite to finish"
255
- m.waitForField(node, "rooibosSuiteFinished", 10, timeout / 10)
260
+ t = createObject("roTimespan")
261
+ while node.rooibosSuiteFinished = false
262
+ m.wait(10)
263
+ if t.totalMilliseconds() >= timeout
264
+ exit while
265
+ end if
266
+ end while
256
267
  end if
257
268
  end if
258
269
  nodeResults = node.asyncRooibosTestResult
@@ -260,7 +271,7 @@ namespace rooibos
260
271
  testSuite.stats.merge(nodeResults.stats)
261
272
  m.mergeGroups(testSuite, nodeResults.groups)
262
273
  else
263
- ? " ERROR! The node test"; testSuite.name; " did not indicate test completion. Did you call m.done() in your test? Did you correctly configure your node test? Please refer to : https://github.com/georgejecook/rooibos/blob/master/docs/index.md#testing-scenegraph-nodes"
274
+ ? " ERROR! The node test"; testSuite.name; " did not indicate test completion. Did you call m.done() in your test? Did you correctly configure your node test? Please refer to : https://github.com/rokucommunity/rooibos/blob/master/docs/index.md#testing-scenegraph-nodes"
264
275
  end if
265
276
  m.testScene.removeChild(node)
266
277
  return
@@ -303,6 +314,19 @@ namespace rooibos
303
314
  ut.PostFromString("")
304
315
  end function
305
316
 
317
+ private function getTestReporters()
318
+ reporters = []
319
+ for each factory in m.config.reporters
320
+ if rooibos.common.isFunction(factory)
321
+ reporters.push(factory(m))
322
+ end if
323
+ end for
324
+ if reporters.isEmpty()
325
+ reporters.push(new rooibos.ConsoleTestReporter(m))
326
+ end if
327
+ return reporters
328
+ end function
329
+
306
330
  end class
307
331
 
308
332
  '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@@ -329,4 +353,4 @@ namespace rooibos
329
353
  function onTestSuiteComplete()
330
354
  m.testRunner.onTestSuiteComplete()
331
355
  end function
332
- end namespace
356
+ end namespace