rooibos-roku 4.4.2

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 (57) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +12 -0
  3. package/dist/lib/framework/BaseTestReporter.bs +27 -0
  4. package/dist/lib/framework/BaseTestSuite.bs +2131 -0
  5. package/dist/lib/framework/CommonUtils.bs +732 -0
  6. package/dist/lib/framework/ConsoleTestReporter.bs +200 -0
  7. package/dist/lib/framework/Coverage.bs +51 -0
  8. package/dist/lib/framework/Matchers.bs +28 -0
  9. package/dist/lib/framework/Rooibos.bs +83 -0
  10. package/dist/lib/framework/RooibosScene.xml +50 -0
  11. package/dist/lib/framework/RuntimeConfig.bs +20 -0
  12. package/dist/lib/framework/Stats.bs +46 -0
  13. package/dist/lib/framework/Test.bs +109 -0
  14. package/dist/lib/framework/TestGroup.bs +109 -0
  15. package/dist/lib/framework/TestResult.bs +74 -0
  16. package/dist/lib/framework/TestRunner.bs +187 -0
  17. package/dist/lib/framework/Utils.bs +63 -0
  18. package/dist/lib/framework/unused/CodeCoverage.brs +35 -0
  19. package/dist/lib/framework/unused/CodeCoverage.xml +13 -0
  20. package/dist/lib/framework/unused/CodeCoverageSupport.brs +56 -0
  21. package/dist/lib/rooibos/Annotation.js +187 -0
  22. package/dist/lib/rooibos/Annotation.js.map +1 -0
  23. package/dist/lib/rooibos/CodeCoverageProcessor.js +114 -0
  24. package/dist/lib/rooibos/CodeCoverageProcessor.js.map +1 -0
  25. package/dist/lib/rooibos/CodeCoverageProcessor.spec.js +62 -0
  26. package/dist/lib/rooibos/CodeCoverageProcessor.spec.js.map +1 -0
  27. package/dist/lib/rooibos/CodeCoverageType.js +11 -0
  28. package/dist/lib/rooibos/CodeCoverageType.js.map +1 -0
  29. package/dist/lib/rooibos/FileFactory.js +92 -0
  30. package/dist/lib/rooibos/FileFactory.js.map +1 -0
  31. package/dist/lib/rooibos/RawCodeStatement.js +21 -0
  32. package/dist/lib/rooibos/RawCodeStatement.js.map +1 -0
  33. package/dist/lib/rooibos/RooibosConfig.js +11 -0
  34. package/dist/lib/rooibos/RooibosConfig.js.map +1 -0
  35. package/dist/lib/rooibos/RooibosSession.js +151 -0
  36. package/dist/lib/rooibos/RooibosSession.js.map +1 -0
  37. package/dist/lib/rooibos/RooibosSessionInfo.js +181 -0
  38. package/dist/lib/rooibos/RooibosSessionInfo.js.map +1 -0
  39. package/dist/lib/rooibos/TestCase.js +65 -0
  40. package/dist/lib/rooibos/TestCase.js.map +1 -0
  41. package/dist/lib/rooibos/TestGroup.js +86 -0
  42. package/dist/lib/rooibos/TestGroup.js.map +1 -0
  43. package/dist/lib/rooibos/TestSuite.js +118 -0
  44. package/dist/lib/rooibos/TestSuite.js.map +1 -0
  45. package/dist/lib/rooibos/TestSuiteBuilder.js +192 -0
  46. package/dist/lib/rooibos/TestSuiteBuilder.js.map +1 -0
  47. package/dist/lib/rooibos/TestSuiteBuilder.spec.js +1126 -0
  48. package/dist/lib/rooibos/TestSuiteBuilder.spec.js.map +1 -0
  49. package/dist/lib/rooibos/Utils.js +173 -0
  50. package/dist/lib/rooibos/Utils.js.map +1 -0
  51. package/dist/lib/utils/Diagnostics.js +116 -0
  52. package/dist/lib/utils/Diagnostics.js.map +1 -0
  53. package/dist/lib/utils/testHelpers.spec.js +24 -0
  54. package/dist/lib/utils/testHelpers.spec.js.map +1 -0
  55. package/dist/plugin.js +116 -0
  56. package/dist/plugin.js.map +1 -0
  57. package/package.json +110 -0
@@ -0,0 +1,200 @@
1
+ namespace rooibos
2
+ class ConsoleTestReporter extends rooibos.BaseTestReporter
3
+
4
+ private lineWidth = 60
5
+
6
+ function new(testRunner)
7
+ super(testRunner)
8
+ if m.config.lineWidth <> invalid
9
+ m.lineWidth = m.config.lineWidth
10
+ else
11
+ m.lineWidth = 60
12
+ end if
13
+ end function
14
+
15
+ override function reportResults(allStats)
16
+ m.allStats = allStats
17
+ m.startReport()
18
+
19
+ for each testSuite in m.testRunner.testSuites
20
+ if not m.allStats.hasFailures or ((not m.config.showOnlyFailures) or testSuite.stats.failedCount > 0 or testSuite.stats.crashedCount > 0)
21
+ m.printSuiteStart(testSuite)
22
+
23
+ for each testGroup in testSuite.groups
24
+ m.printGroup(testGroup)
25
+ end for
26
+ end if
27
+ end for
28
+
29
+ m.printLine()
30
+
31
+ 'bs:disable-next-line
32
+ ignoredInfo = m.testRunner.runtimeConfig.getIgnoredTestInfo()
33
+ m.printLine(0, "Total: " + Rooibos.Common.AsString(m.allStats.ranCount))
34
+ m.printLine(0, " Passed: " + Rooibos.Common.AsString(m.allStats.passedCount))
35
+ m.printLine(0, " Crashed: " + Rooibos.Common.AsString(m.allStats.crashedCount))
36
+ m.printLine(0, " Failed: " + Rooibos.Common.AsString(m.allStats.failedCount))
37
+ m.printLine(0, " Ignored: " + Rooibos.Common.AsString(ignoredInfo.count))
38
+ m.printLine(0, " Time: " + Rooibos.Common.AsString(m.allStats.time) + "ms")
39
+ m.printLine()
40
+ m.printLine()
41
+
42
+ if ignoredInfo.count > 0
43
+ m.printLine(0, "IGNORED TESTS:")
44
+ for each ignoredItemName in ignoredInfo.items
45
+ m.printLine(1, ignoredItemName)
46
+ end for
47
+ m.printLine()
48
+ m.printLine()
49
+ end if
50
+
51
+ if m.allStats.hasFailures
52
+ overrallResult = "Fail"
53
+ else
54
+ overrallResult = "Success"
55
+ end if
56
+ m.printLine(0, "RESULT: " + overrallResult)
57
+ m.endReport()
58
+ end function
59
+
60
+ function printGroup(testGroup)
61
+ isGroupPrinted = false
62
+
63
+ for each test in testGroup.tests
64
+ if not m.allStats.hasFailures or ((not m.config.showOnlyFailures) or test.result.isFail)
65
+ if not isGroupPrinted
66
+ m.printGroupStart(testGroup)
67
+ isGroupPrinted = true
68
+ end if
69
+
70
+ m.printTest(test)
71
+ end if
72
+ end for
73
+
74
+ if isGroupPrinted
75
+ m.printLine(0, " |")
76
+ end if
77
+ end function
78
+
79
+ function printTest(test)
80
+
81
+ testLocationLine = StrI(test.lineNumber).trim()
82
+
83
+ locationLine = invalid
84
+ if test.result.isCrash
85
+ testChar = "|"
86
+ locationLine = StrI(test.lineNumber).trim()
87
+ else if test.result.isFail
88
+ testChar = "-"
89
+ locationLine = StrI(test.result.lineNumber + 1).trim()
90
+ else
91
+ testChar = "|"
92
+ locationLine = StrI(test.lineNumber).trim()
93
+ end if
94
+
95
+ testLocationText = "file://" + test.testSuite.filePath.trim() + ":" + testLocationLine
96
+
97
+ if m.config.printTestTimes = true
98
+ timeText = " (" + stri(test.result.time).trim() + "ms)"
99
+ else
100
+ timeText = ""
101
+ end if
102
+
103
+ insetText = ""
104
+ if test.isParamTest <> true
105
+ messageLine = Rooibos.Common.fillText(" " + testChar + " |--" + test.name + " : ", ".", m.lineWidth)
106
+ m.printLine(0, messageLine + test.result.getStatusText() + timeText)
107
+ m.printLine(0, " | " + insettext + " |--Test : " + testLocationText)
108
+ else if test.paramTestIndex = 0
109
+ name = test.name
110
+ if len(name) > 1 and right(name, 1) = "0"
111
+ name = left(name, len(name) - 1)
112
+ end if
113
+ m.printLine(0, " " + testChar + " |--" + name + " : ")
114
+ m.printLine(0, " | " + insettext + " |--Test : " + testLocationText)
115
+ end if
116
+
117
+ locationText = "file://" + test.testSuite.filePath.trim() + ":" + locationLine
118
+ if test.isParamTest = true
119
+ insetText = " "
120
+
121
+ if type(test.rawParams) = "roAssociativeArray"
122
+ rawParams = {}
123
+ for each key in test.rawParams
124
+ if type(test.rawParams[key]) <> "Function" and type(test.rawParams[key]) <> "roFunction"
125
+ rawParams[key] = test.rawParams[key]
126
+ end if
127
+ end for
128
+ else
129
+ rawParams = test.rawParams
130
+ end if
131
+ messageLine = Rooibos.Common.fillText(" " + testChar + insetText + " |--" + formatJson(rawParams) + " : ", ".", m.lineWidth)
132
+ m.printLine(0, messageLine + test.result.getStatusText() + timeText)
133
+ end if
134
+
135
+ if test.result.isCrash
136
+ m.printLine(0, " | " + insettext + " |--Crashed at: " + locationText)
137
+ m.printStackTrace(insettext, test.result.error)
138
+ m.printLine(0, " | ")
139
+ else if test.result.isFail
140
+ m.printLine(0, " | " + insettext + " |--Failed at: " + locationText)
141
+ if test.isParamTest = true
142
+ m.printLine(0, " | " + insettext + " |--Param Line: " + StrI(test.paramLineNumber - 1).trim())
143
+ end if
144
+ m.printLine(0, " | " + insettext + " |--Error Message: " + test.result.message)
145
+ m.printLine(0, " | ")
146
+ end if
147
+ end function
148
+
149
+ function printStackTrace(insettext, error)
150
+ m.printLine(0, " | " + insettext + " |")
151
+ m.printLine(0, " | " + insettext + " |--Message: " + error.message)
152
+ m.printLine(0, " | " + insettext + " |--Stack trace: ")
153
+
154
+ for i = error.backTrace.count() - 1 to 0 step -1
155
+ e = error.backTrace[i]
156
+ if e.filename.instr("pkg:/source/rooibos") = -1
157
+ m.printLine(0, " | " + insettext + " " + e.filename + "(" + stri(e.line_number).trim() + ")")
158
+ end if
159
+ end for
160
+ end function
161
+
162
+ function startReport()
163
+ m.printLine()
164
+ m.printLine(0, "[START TEST REPORT]")
165
+ m.printLine()
166
+ end function
167
+
168
+ function endReport()
169
+ m.printLine()
170
+ m.printLine(0, "[END TEST REPORT]")
171
+ m.printLine()
172
+ end function
173
+
174
+ function printSuiteStart(testSuite)
175
+ m.printLine(0, " " + testSuite.name + " file://" + testSuite.filePath.trim() + ":" + str(testSuite.lineNumber).trim())
176
+
177
+ end function
178
+
179
+ function printGroupStart(testGroup)
180
+ m.printLine(0, " |-" + testGroup.name)
181
+ end function
182
+
183
+ '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
184
+ '++ printing
185
+ '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
186
+
187
+ override function testLogInfo(text)
188
+ ? "INFO " ; text
189
+ end function
190
+
191
+ override function testLogError(text)
192
+ ? "ERROR " ; text
193
+ end function
194
+
195
+ function printLine(depth = 0, text = "")
196
+ ? " " ; text
197
+ end function
198
+
199
+ end class
200
+ end namespace
@@ -0,0 +1,51 @@
1
+ namespace rooibos.Coverage
2
+
3
+ ' function createLCovOutput()
4
+ ' ? "Generating lcov.info file..."
5
+
6
+ ' cc = m.global._rbs_ccn
7
+ ' expectedMap = cc.expectedMap
8
+ ' filePathMap = cc.filePathMap
9
+ ' resolvedMap = cc.resolvedMap
10
+
11
+ ' buffer = ""
12
+
13
+ ' for each module in filePathMap.items()
14
+ ' moduleNumber = module.key
15
+ ' filePath = module.value
16
+ ' packageName = "."
17
+
18
+ ' relativePath = filePath.replace("pkg:", packageName)
19
+ ' sanitizedPath = relativePath.replace("\\", "/")
20
+
21
+ ' buffer = buffer + "TN:" + chr(10)
22
+ ' buffer = buffer + "SF:" + sanitizedPath + chr(10)
23
+
24
+ ' for each expected in expectedMap[moduleNumber]
25
+ ' lineNumber = expected[0]
26
+ ' SHIFT = 1
27
+
28
+ ' if resolvedMap[moduleNumber] <> invalid and resolvedMap[moduleNumber].doesExist(str(lineNumber)) then
29
+ ' buffer = buffer + "DA:" + str(lineNumber + SHIFT) + ",1" + chr(10)
30
+ ' else
31
+ ' buffer = buffer + "DA:" + str(lineNumber + SHIFT) + ",0" + chr(10)
32
+ ' end if
33
+ ' end for
34
+
35
+ ' buffer = buffer + "end_of_record" + chr(10)
36
+ ' end for
37
+ ' return buffer
38
+ ' end function
39
+
40
+ ' function printLCovInfo()
41
+ ' ?
42
+ ' ? "+++++++++++++++++++++++++++++++++++++++++++"
43
+ ' ? "LCOV.INFO FILE"
44
+ ' ? "+++++++++++++++++++++++++++++++++++++++++++"
45
+ ' ?
46
+ ' ? "+-=-coverage:start"
47
+ ' ? Coverage.createLCovOutput()
48
+ ' ? "+-=-coverage:end"
49
+ ' end function
50
+
51
+ end namespace
@@ -0,0 +1,28 @@
1
+ namespace rooibos.Matcher
2
+
3
+ function anyString(value)
4
+ return Rooibos.Common.isString(value)
5
+ end function
6
+
7
+ function anyBool(value)
8
+ return Rooibos.Common.isBoolean(value)
9
+ end function
10
+
11
+ function anyNumber(value)
12
+ return Rooibos.Common.isNumber(value)
13
+ end function
14
+
15
+ function anyAA(value)
16
+ return Rooibos.Common.isAssociativeArray(value)
17
+ end function
18
+
19
+ function anyArray(value)
20
+ return Rooibos.Common.isArray(value)
21
+ end function
22
+
23
+ function anyNode(value)
24
+ return Rooibos.Common.isSGNode(value)
25
+ end function
26
+
27
+
28
+ end namespace
@@ -0,0 +1,83 @@
1
+ namespace rooibos
2
+ function init() as void
3
+ args = {}
4
+ if createObject("roAPPInfo").IsDev() <> true then
5
+ ? " not running in dev mode! - rooibos tests only support sideloaded builds - aborting"
6
+ return
7
+ end if
8
+
9
+ screen = CreateObject("roSGScreen")
10
+ m.port = CreateObject("roMessagePort")
11
+ screen.setMessagePort(m.port)
12
+ testSceneName = "TestsScene"
13
+
14
+ ? "Starting test using test scene with name TestsScene" ; testSceneName
15
+ scene = screen.CreateScene(testSceneName)
16
+ scene.id = "ROOT"
17
+ screen.show()
18
+
19
+ m.global = screen.getGlobalNode()
20
+ m.global.addFields({ "testsScene": scene })
21
+
22
+ if scene.hasField("isReadyToStartTests") and scene.isReadyToStartTests = false
23
+ ? "The scene is not ready yet - waiting for it to set isReadyToStartTests to true"
24
+ scene.observeField("isReadyToStartTests", m.port)
25
+
26
+ else
27
+ ? "scene is ready; running tests now"
28
+ runner = new TestRunner(scene, m)
29
+ runner.Run()
30
+ end if
31
+
32
+ while(true)
33
+ msg = wait(0, m.port)
34
+ msgType = type(msg)
35
+ if msgType = "roSGScreenEvent"
36
+ if msg.isScreenClosed()
37
+ return
38
+ end if
39
+ else if msgType = "roSGNodeEvent"
40
+
41
+ if msg.getField() = "isReadyToStartTests" and msg.getData() = true
42
+ ? "scene is ready; running tests now"
43
+ runner = new TestRunner(scene, m)
44
+ runner.Run()
45
+ end if
46
+ end if
47
+ end while
48
+ end function
49
+
50
+ function versionCompare(v1, v2)
51
+ v1parts = v1.split(".")
52
+ v2parts = v2.split(".")
53
+
54
+ while v1parts.count() < v2parts.count()
55
+ v1parts.push("0")
56
+ end while
57
+
58
+ while v2parts.count() < v1parts.count()
59
+ v2parts.push("0")
60
+ end while
61
+
62
+ for i = 0 to v1parts.count() - 1
63
+ if v2parts.count() = i
64
+ return 1
65
+ end if
66
+
67
+ if v1parts[i] <> v2parts[i]
68
+ if v1parts[i] > v2parts[i]
69
+ return 1
70
+ else
71
+ return -1
72
+ end if
73
+ end if
74
+ end for
75
+
76
+ if v1parts.count() <> v2parts.count()
77
+ return -1
78
+ end if
79
+
80
+ return 0
81
+
82
+ end function
83
+ end namespace
@@ -0,0 +1,50 @@
1
+ <component
2
+ name='TestsScene'
3
+ extends='Scene'>
4
+ <interface>
5
+ <function name='Rooibos_CreateTestNode' />
6
+ </interface>
7
+
8
+ <!-- <script
9
+ type='text/brighterscript'
10
+ uri='source/rooibos/BaseTestSuite.bs' />
11
+ <script
12
+ type='text/brighterscript'
13
+ uri='source/rooibos/CommonUtils.bs' />
14
+ <script
15
+ type='text/brighterscript'
16
+ uri='source/rooibos/Coverage.bs' />
17
+ <script
18
+ type='text/brighterscript'
19
+ uri='source/rooibos/Matchers.bs' />
20
+ <script
21
+ type='text/brighterscript'
22
+ uri='source/rooibos/Rooibos.bs' />
23
+ <script
24
+ type='text/brighterscript'
25
+ uri='source/rooibos/RuntimeConfig.bs' />
26
+ <script
27
+ type='text/brighterscript'
28
+ uri='source/rooibos/Stats.bs' />
29
+ <script
30
+ type='text/brighterscript'
31
+ uri='source/rooibos/Test.bs' />
32
+ <script
33
+ type='text/brighterscript'
34
+ uri='source/rooibos/TestGroup.bs' />
35
+ <script
36
+ type='text/brighterscript'
37
+ uri='source/rooibos/TestLogger.bs' />
38
+ <script
39
+ type='text/brighterscript'
40
+ uri='source/rooibos/TestResult.bs' />
41
+ <script
42
+ type='text/brighterscript'
43
+ uri='source/rooibos/TestRunner.bs' /> -->
44
+
45
+ <children>
46
+ <LayoutGroup>
47
+ <Label text='Rooibos tests are running' />
48
+ </LayoutGroup>
49
+ </children>
50
+ </component>
@@ -0,0 +1,20 @@
1
+ namespace rooibos
2
+ class RuntimeConfig
3
+
4
+ function getVersionText()
5
+ end function
6
+
7
+ function getRuntimeConfig()
8
+ end function
9
+
10
+ function getTestSuiteClassWithName(name)
11
+ end function
12
+
13
+ function getAllTestSuitesNames()
14
+ end function
15
+
16
+ function getIgnoredTestInfo()
17
+ end function
18
+
19
+ end class
20
+ end namespace
@@ -0,0 +1,46 @@
1
+ namespace rooibos
2
+ class Stats
3
+ public time = 0
4
+ public ranCount = 0
5
+ public passedCount = 0
6
+ public failedCount = 0
7
+ public crashedCount = 0
8
+ public ignoredCount = 0
9
+ public ignoredTestNames = []
10
+ public hasFailures = false
11
+ public testResult = invalid
12
+
13
+ function new()
14
+ end function
15
+
16
+ function merge(other) as void
17
+ m.time += other.time
18
+ m.ranCount += other.ranCount
19
+ m.passedCount += other.passedCount
20
+ m.failedCount += other.failedCount
21
+ m.crashedCount += other.crashedCount
22
+ m.ignoredCount += other.ignoredCount
23
+ m.ignoredTestNames.append(other.IgnoredTestNames)
24
+ m.onUpdate()
25
+ end function
26
+
27
+ function appendTestResult(result)
28
+ m.time += result.time
29
+ m.ranCount++
30
+ if result.isCrash
31
+ m.crashedCount++
32
+ else if result.isFail
33
+ m.failedCount++
34
+ else
35
+ m.passedCount++
36
+ end if
37
+
38
+ m.onUpdate()
39
+ end function
40
+
41
+ function onUpdate()
42
+ m.hasFailures = m.failedCount > 0 or m.crashedCount > 0
43
+ end function
44
+
45
+ end class
46
+ end namespace