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.
- package/LICENSE +21 -0
- package/README.md +12 -0
- package/dist/lib/framework/BaseTestReporter.bs +27 -0
- package/dist/lib/framework/BaseTestSuite.bs +2131 -0
- package/dist/lib/framework/CommonUtils.bs +732 -0
- package/dist/lib/framework/ConsoleTestReporter.bs +200 -0
- package/dist/lib/framework/Coverage.bs +51 -0
- package/dist/lib/framework/Matchers.bs +28 -0
- package/dist/lib/framework/Rooibos.bs +83 -0
- package/dist/lib/framework/RooibosScene.xml +50 -0
- package/dist/lib/framework/RuntimeConfig.bs +20 -0
- package/dist/lib/framework/Stats.bs +46 -0
- package/dist/lib/framework/Test.bs +109 -0
- package/dist/lib/framework/TestGroup.bs +109 -0
- package/dist/lib/framework/TestResult.bs +74 -0
- package/dist/lib/framework/TestRunner.bs +187 -0
- package/dist/lib/framework/Utils.bs +63 -0
- package/dist/lib/framework/unused/CodeCoverage.brs +35 -0
- package/dist/lib/framework/unused/CodeCoverage.xml +13 -0
- package/dist/lib/framework/unused/CodeCoverageSupport.brs +56 -0
- package/dist/lib/rooibos/Annotation.js +187 -0
- package/dist/lib/rooibos/Annotation.js.map +1 -0
- package/dist/lib/rooibos/CodeCoverageProcessor.js +114 -0
- package/dist/lib/rooibos/CodeCoverageProcessor.js.map +1 -0
- package/dist/lib/rooibos/CodeCoverageProcessor.spec.js +62 -0
- package/dist/lib/rooibos/CodeCoverageProcessor.spec.js.map +1 -0
- package/dist/lib/rooibos/CodeCoverageType.js +11 -0
- package/dist/lib/rooibos/CodeCoverageType.js.map +1 -0
- package/dist/lib/rooibos/FileFactory.js +92 -0
- package/dist/lib/rooibos/FileFactory.js.map +1 -0
- package/dist/lib/rooibos/RawCodeStatement.js +21 -0
- package/dist/lib/rooibos/RawCodeStatement.js.map +1 -0
- package/dist/lib/rooibos/RooibosConfig.js +11 -0
- package/dist/lib/rooibos/RooibosConfig.js.map +1 -0
- package/dist/lib/rooibos/RooibosSession.js +151 -0
- package/dist/lib/rooibos/RooibosSession.js.map +1 -0
- package/dist/lib/rooibos/RooibosSessionInfo.js +181 -0
- package/dist/lib/rooibos/RooibosSessionInfo.js.map +1 -0
- package/dist/lib/rooibos/TestCase.js +65 -0
- package/dist/lib/rooibos/TestCase.js.map +1 -0
- package/dist/lib/rooibos/TestGroup.js +86 -0
- package/dist/lib/rooibos/TestGroup.js.map +1 -0
- package/dist/lib/rooibos/TestSuite.js +118 -0
- package/dist/lib/rooibos/TestSuite.js.map +1 -0
- package/dist/lib/rooibos/TestSuiteBuilder.js +192 -0
- package/dist/lib/rooibos/TestSuiteBuilder.js.map +1 -0
- package/dist/lib/rooibos/TestSuiteBuilder.spec.js +1126 -0
- package/dist/lib/rooibos/TestSuiteBuilder.spec.js.map +1 -0
- package/dist/lib/rooibos/Utils.js +173 -0
- package/dist/lib/rooibos/Utils.js.map +1 -0
- package/dist/lib/utils/Diagnostics.js +116 -0
- package/dist/lib/utils/Diagnostics.js.map +1 -0
- package/dist/lib/utils/testHelpers.spec.js +24 -0
- package/dist/lib/utils/testHelpers.spec.js.map +1 -0
- package/dist/plugin.js +116 -0
- package/dist/plugin.js.map +1 -0
- package/package.json +110 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
namespace rooibos.utils
|
|
2
|
+
class MockNode
|
|
3
|
+
public id
|
|
4
|
+
public name
|
|
5
|
+
|
|
6
|
+
public createdNodes = []
|
|
7
|
+
public createdChildren = []
|
|
8
|
+
public children = []
|
|
9
|
+
public _subType = "Node"
|
|
10
|
+
public _parent
|
|
11
|
+
|
|
12
|
+
function new(id = "", subType = "Node")
|
|
13
|
+
m.id = id
|
|
14
|
+
m._subType = subType
|
|
15
|
+
end function
|
|
16
|
+
|
|
17
|
+
function subType()
|
|
18
|
+
return m._subType
|
|
19
|
+
end function
|
|
20
|
+
|
|
21
|
+
function createObject(nodeType)
|
|
22
|
+
node = new rooibos.utils.MockNode("", nodeType)
|
|
23
|
+
m.createdNodes.push(node)
|
|
24
|
+
return node
|
|
25
|
+
end function
|
|
26
|
+
|
|
27
|
+
function createChild(nodeType)
|
|
28
|
+
node = new rooibos.utils.MockNode("", nodeType)
|
|
29
|
+
m.createdChildren.push(node)
|
|
30
|
+
return node
|
|
31
|
+
end function
|
|
32
|
+
|
|
33
|
+
function appendChild(child)
|
|
34
|
+
m.children.push(child)
|
|
35
|
+
end function
|
|
36
|
+
function getParent()
|
|
37
|
+
if m._parent = invalid
|
|
38
|
+
m._parent = new rooibos.utils.MockNode("_generated_parent")
|
|
39
|
+
end if
|
|
40
|
+
return m._parent
|
|
41
|
+
end function
|
|
42
|
+
|
|
43
|
+
function addFields(fields)
|
|
44
|
+
m.append(fields)
|
|
45
|
+
end function
|
|
46
|
+
function setField(field, value)
|
|
47
|
+
m[field] = value
|
|
48
|
+
end function
|
|
49
|
+
function setFields(fields)
|
|
50
|
+
m.append(fields)
|
|
51
|
+
end function
|
|
52
|
+
function observeField(field, callback)
|
|
53
|
+
end function
|
|
54
|
+
function getChildren(offset, count)
|
|
55
|
+
return m.children
|
|
56
|
+
end function
|
|
57
|
+
function removeChildren(children)
|
|
58
|
+
|
|
59
|
+
end function
|
|
60
|
+
function observeFieldScoped(field, callback)
|
|
61
|
+
end function
|
|
62
|
+
end class
|
|
63
|
+
end namespace
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
function init()
|
|
2
|
+
m.resolvedMap = {}
|
|
3
|
+
m.top.observeField("entry", "onEntryChange")
|
|
4
|
+
m.top.observeField("save", "onSave")
|
|
5
|
+
|
|
6
|
+
end function
|
|
7
|
+
|
|
8
|
+
function setExpectedMap()
|
|
9
|
+
m.top.expectedMap = "#EXPECTED_MAP#"
|
|
10
|
+
end function
|
|
11
|
+
|
|
12
|
+
function setFilePathMap()
|
|
13
|
+
m.top.filePathMap = "#FILE_PATH_MAP#"
|
|
14
|
+
end function
|
|
15
|
+
|
|
16
|
+
function onEntryChange()
|
|
17
|
+
entry = m.top.entry
|
|
18
|
+
if entry <> invalid
|
|
19
|
+
lineMap = m.resolvedMap[entry.f]
|
|
20
|
+
|
|
21
|
+
if lineMap = invalid
|
|
22
|
+
lineMap = {}
|
|
23
|
+
end if
|
|
24
|
+
lineMap[entry.l] = entry.r
|
|
25
|
+
|
|
26
|
+
m.resolvedMap[entry.f] = lineMap
|
|
27
|
+
end if
|
|
28
|
+
end function
|
|
29
|
+
|
|
30
|
+
function onSave()
|
|
31
|
+
? "saving data"
|
|
32
|
+
m.top.resolvedMap = m.resolvedMap
|
|
33
|
+
setExpectedMap()
|
|
34
|
+
setFilePathMap()
|
|
35
|
+
end function
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<component name="CodeCoverage"
|
|
3
|
+
extends="ContentNode"
|
|
4
|
+
>
|
|
5
|
+
<script type="text/brightscript" uri="CodeCoverage.brs" />
|
|
6
|
+
<interface>
|
|
7
|
+
<field id="entry" type="assocarray" />
|
|
8
|
+
<field id="save" type="boolean" />
|
|
9
|
+
<field id="expectedMap" type="assocarray" />
|
|
10
|
+
<field id="resolvedMap" type="assocarray" />
|
|
11
|
+
<field id="filePathMap" type="assocarray" />
|
|
12
|
+
</interface>
|
|
13
|
+
</component>
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
function RBS_ReportCodeCoverage() as void
|
|
2
|
+
|
|
3
|
+
if m.global._rbs_ccn = invalid
|
|
4
|
+
? "There was no rooibos code coverage component - not generating coverage report"
|
|
5
|
+
return
|
|
6
|
+
end if
|
|
7
|
+
? ""
|
|
8
|
+
? "...Generating code coverage report"
|
|
9
|
+
? ""
|
|
10
|
+
m.global._rbs_ccn.save = true
|
|
11
|
+
cc = m.global._rbs_ccn
|
|
12
|
+
hitFiles = []
|
|
13
|
+
missFiles = []
|
|
14
|
+
allLinesCount = 0
|
|
15
|
+
allLinesHit = 0
|
|
16
|
+
for each key in cc.expectedMap
|
|
17
|
+
filename = cc.filePathMap[key]
|
|
18
|
+
expectedCount = cc.expectedMap[key].count()
|
|
19
|
+
allLinesCount += expectedCount
|
|
20
|
+
if expectedCount > 0
|
|
21
|
+
if cc.resolvedMap[key] <> invalid
|
|
22
|
+
resolvedCount = cc.resolvedMap[key].count()
|
|
23
|
+
allLinesHit += resolvedCount
|
|
24
|
+
resolvedPercent = (resolvedCount / expectedCount) * 100
|
|
25
|
+
hitFiles.push({percent:resolvedPercent, text:filename + ": " +str(resolvedPercent).trim() + "% (" + stri(resolvedCount).trim() + "/" + stri(expectedCount).trim() + ")"})
|
|
26
|
+
else
|
|
27
|
+
resolvedCount = 0
|
|
28
|
+
resolvedPercent = 0
|
|
29
|
+
missFiles.push(filename + ": MISS!")
|
|
30
|
+
end if
|
|
31
|
+
end if
|
|
32
|
+
end for
|
|
33
|
+
allLinesPercent = (allLinesHit / allLinesCount) * 100
|
|
34
|
+
? ""
|
|
35
|
+
? ""
|
|
36
|
+
? "+++++++++++++++++++++++++++++++++++++++++++"
|
|
37
|
+
? "Code Coverage Report"
|
|
38
|
+
? "+++++++++++++++++++++++++++++++++++++++++++"
|
|
39
|
+
? ""
|
|
40
|
+
? "Total Coverage: " ; str(allLinesPercent).trim() ; "% (" ; stri(allLinesHit).trim() ; "/" + stri(allLinesCount).trim() ; ")"
|
|
41
|
+
? "Files: " ; cc.resolvedMap.count(); "/" ; cc.expectedMap.count()
|
|
42
|
+
? ""
|
|
43
|
+
? "HIT FILES"
|
|
44
|
+
? "---------"
|
|
45
|
+
hitFiles.SortBy("percent")
|
|
46
|
+
for i = 0 to hitFiles.count() -1
|
|
47
|
+
? hitFiles[i].text
|
|
48
|
+
end for
|
|
49
|
+
? ""
|
|
50
|
+
? "MISSED FILES"
|
|
51
|
+
? "------------"
|
|
52
|
+
for i = 0 to missFiles.count() -1
|
|
53
|
+
? missFiles[i]
|
|
54
|
+
end for
|
|
55
|
+
|
|
56
|
+
end function
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAnnotationType = exports.RooibosAnnotation = exports.AnnotationParams = exports.AnnotationType = void 0;
|
|
4
|
+
const Diagnostics_1 = require("../utils/Diagnostics");
|
|
5
|
+
var AnnotationType;
|
|
6
|
+
(function (AnnotationType) {
|
|
7
|
+
AnnotationType["None"] = "none";
|
|
8
|
+
AnnotationType["TestSuite"] = "suite";
|
|
9
|
+
AnnotationType["Describe"] = "describe";
|
|
10
|
+
AnnotationType["It"] = "it";
|
|
11
|
+
AnnotationType["Ignore"] = "ignore";
|
|
12
|
+
AnnotationType["Solo"] = "only";
|
|
13
|
+
AnnotationType["NodeTest"] = "sgnode";
|
|
14
|
+
AnnotationType["Setup"] = "setup";
|
|
15
|
+
AnnotationType["TearDown"] = "teardown";
|
|
16
|
+
AnnotationType["BeforeEach"] = "beforeeach";
|
|
17
|
+
AnnotationType["AfterEach"] = "aftereach";
|
|
18
|
+
AnnotationType["Params"] = "params";
|
|
19
|
+
AnnotationType["IgnoreParams"] = "ignoreparams";
|
|
20
|
+
AnnotationType["SoloParams"] = "onlyparams";
|
|
21
|
+
AnnotationType["Tags"] = "tags";
|
|
22
|
+
AnnotationType["NoCatch"] = "nocatch";
|
|
23
|
+
AnnotationType["NoEarlyExit"] = "noearlyexit";
|
|
24
|
+
})(AnnotationType = exports.AnnotationType || (exports.AnnotationType = {}));
|
|
25
|
+
let annotationLookup = {
|
|
26
|
+
suite: AnnotationType.TestSuite,
|
|
27
|
+
describe: AnnotationType.Describe,
|
|
28
|
+
it: AnnotationType.It,
|
|
29
|
+
ignore: AnnotationType.Ignore,
|
|
30
|
+
only: AnnotationType.Solo,
|
|
31
|
+
sgnode: AnnotationType.NodeTest,
|
|
32
|
+
setup: AnnotationType.Setup,
|
|
33
|
+
teardown: AnnotationType.TearDown,
|
|
34
|
+
beforeeach: AnnotationType.BeforeEach,
|
|
35
|
+
aftereach: AnnotationType.AfterEach,
|
|
36
|
+
params: AnnotationType.Params,
|
|
37
|
+
ignoreparams: AnnotationType.IgnoreParams,
|
|
38
|
+
onlyparams: AnnotationType.SoloParams,
|
|
39
|
+
tags: AnnotationType.Tags,
|
|
40
|
+
nocatch: AnnotationType.NoCatch,
|
|
41
|
+
noearlyexit: AnnotationType.NoEarlyExit
|
|
42
|
+
};
|
|
43
|
+
class AnnotationParams {
|
|
44
|
+
constructor(annotation, text, lineNumber, params, isIgnore = false, isSolo = false, noCatch = false, noearlyexit = false) {
|
|
45
|
+
this.annotation = annotation;
|
|
46
|
+
this.text = text;
|
|
47
|
+
this.lineNumber = lineNumber;
|
|
48
|
+
this.params = params;
|
|
49
|
+
this.isIgnore = isIgnore;
|
|
50
|
+
this.isSolo = isSolo;
|
|
51
|
+
this.noCatch = noCatch;
|
|
52
|
+
this.noearlyexit = noearlyexit;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.AnnotationParams = AnnotationParams;
|
|
56
|
+
class RooibosAnnotation {
|
|
57
|
+
/**
|
|
58
|
+
* Represents a group of comments which contain tags such as @only, @suite, @describe, @it etc
|
|
59
|
+
* @param statement block of comments that contain annotations to apply to the next statement
|
|
60
|
+
*/
|
|
61
|
+
constructor(file, annotation, annotationType, text, name, isIgnore = false, isSolo = false, params = [], nodeName, rawTags = [], noCatch = false, noEarlyExit = false) {
|
|
62
|
+
this.file = file;
|
|
63
|
+
this.annotation = annotation;
|
|
64
|
+
this.annotationType = annotationType;
|
|
65
|
+
this.text = text;
|
|
66
|
+
this.name = name;
|
|
67
|
+
this.isIgnore = isIgnore;
|
|
68
|
+
this.isSolo = isSolo;
|
|
69
|
+
this.params = params;
|
|
70
|
+
this.nodeName = nodeName;
|
|
71
|
+
this.noCatch = noCatch;
|
|
72
|
+
this.noEarlyExit = noEarlyExit;
|
|
73
|
+
this.hasSoloParams = false;
|
|
74
|
+
this.tags = new Set(rawTags);
|
|
75
|
+
}
|
|
76
|
+
static getAnnotation(file, statement) {
|
|
77
|
+
var _a;
|
|
78
|
+
//split annotations in case they include an it group..
|
|
79
|
+
let blockAnnotation;
|
|
80
|
+
let testAnnotation;
|
|
81
|
+
let isSolo = false;
|
|
82
|
+
let isIgnore = false;
|
|
83
|
+
let noCatch = false;
|
|
84
|
+
let noEarlyExit = false;
|
|
85
|
+
let nodeName = null;
|
|
86
|
+
let tags = [];
|
|
87
|
+
if ((_a = statement.annotations) === null || _a === void 0 ? void 0 : _a.length) {
|
|
88
|
+
let describeAnnotations = statement.annotations.filter((a) => getAnnotationType(a.name) === AnnotationType.Describe);
|
|
89
|
+
if (describeAnnotations.length > 1) {
|
|
90
|
+
for (let a of describeAnnotations) {
|
|
91
|
+
Diagnostics_1.diagnosticMultipleDescribeAnnotations(file, a);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
for (let annotation of statement.annotations) {
|
|
95
|
+
const annotationType = getAnnotationType(annotation.name);
|
|
96
|
+
switch (annotationType) {
|
|
97
|
+
case AnnotationType.NoEarlyExit:
|
|
98
|
+
noEarlyExit = true;
|
|
99
|
+
break;
|
|
100
|
+
case AnnotationType.NoCatch:
|
|
101
|
+
noCatch = true;
|
|
102
|
+
break;
|
|
103
|
+
case AnnotationType.Solo:
|
|
104
|
+
isSolo = true;
|
|
105
|
+
break;
|
|
106
|
+
case AnnotationType.NodeTest:
|
|
107
|
+
nodeName = annotation.getArguments()[0];
|
|
108
|
+
break;
|
|
109
|
+
case AnnotationType.Tags:
|
|
110
|
+
tags = annotation.getArguments().map((a) => a.toString());
|
|
111
|
+
break;
|
|
112
|
+
case AnnotationType.Ignore:
|
|
113
|
+
isIgnore = true;
|
|
114
|
+
break;
|
|
115
|
+
case AnnotationType.BeforeEach:
|
|
116
|
+
case AnnotationType.AfterEach:
|
|
117
|
+
case AnnotationType.Setup:
|
|
118
|
+
case AnnotationType.TearDown:
|
|
119
|
+
testAnnotation = new RooibosAnnotation(file, annotation, annotationType, annotation.name, annotation.name);
|
|
120
|
+
break;
|
|
121
|
+
case AnnotationType.Describe:
|
|
122
|
+
case AnnotationType.TestSuite:
|
|
123
|
+
const groupName = annotation.getArguments()[0];
|
|
124
|
+
blockAnnotation = new RooibosAnnotation(file, annotation, annotationType, annotation.name, groupName, isIgnore, isSolo, null, nodeName, tags, noCatch, noEarlyExit);
|
|
125
|
+
nodeName = null;
|
|
126
|
+
isSolo = false;
|
|
127
|
+
isIgnore = false;
|
|
128
|
+
break;
|
|
129
|
+
case AnnotationType.It:
|
|
130
|
+
const testName = annotation.getArguments()[0];
|
|
131
|
+
if (!testName || testName.trim() === '') {
|
|
132
|
+
Diagnostics_1.diagnosticNoTestNameDefined(file, annotation);
|
|
133
|
+
}
|
|
134
|
+
let newAnnotation = new RooibosAnnotation(file, annotation, annotationType, annotation.name, testName, isIgnore, isSolo, undefined, undefined, tags, noCatch);
|
|
135
|
+
if (testAnnotation) {
|
|
136
|
+
Diagnostics_1.diagnosticMultipleTestOnFunctionDefined(file, newAnnotation.annotation);
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
testAnnotation = newAnnotation;
|
|
140
|
+
}
|
|
141
|
+
isSolo = false;
|
|
142
|
+
isIgnore = false;
|
|
143
|
+
break;
|
|
144
|
+
case AnnotationType.Params:
|
|
145
|
+
case AnnotationType.SoloParams:
|
|
146
|
+
case AnnotationType.IgnoreParams:
|
|
147
|
+
if (testAnnotation) {
|
|
148
|
+
testAnnotation.parseParams(file, annotation, annotationType, noCatch);
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
//error
|
|
152
|
+
}
|
|
153
|
+
break;
|
|
154
|
+
case AnnotationType.None:
|
|
155
|
+
default:
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return { blockAnnotation: blockAnnotation, testAnnotation: testAnnotation };
|
|
161
|
+
}
|
|
162
|
+
parseParams(file, annotation, annotationType, noCatch) {
|
|
163
|
+
let rawParams = JSON.stringify(annotation.getArguments());
|
|
164
|
+
let isSolo = annotationType === AnnotationType.SoloParams;
|
|
165
|
+
let isIgnore = annotationType === AnnotationType.IgnoreParams;
|
|
166
|
+
if (isSolo) {
|
|
167
|
+
this.hasSoloParams = true;
|
|
168
|
+
}
|
|
169
|
+
try {
|
|
170
|
+
if (rawParams) {
|
|
171
|
+
this.params.push(new AnnotationParams(annotation, rawParams, annotation.range.start.line, annotation.getArguments(), isIgnore, isSolo, noCatch));
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
Diagnostics_1.diagnosticIllegalParams(file, annotation);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
catch (e) {
|
|
178
|
+
Diagnostics_1.diagnosticIllegalParams(file, annotation);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
exports.RooibosAnnotation = RooibosAnnotation;
|
|
183
|
+
function getAnnotationType(text) {
|
|
184
|
+
return annotationLookup[text.toLowerCase()] || AnnotationType.None;
|
|
185
|
+
}
|
|
186
|
+
exports.getAnnotationType = getAnnotationType;
|
|
187
|
+
//# sourceMappingURL=Annotation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Annotation.js","sourceRoot":"","sources":["../../../src/lib/rooibos/Annotation.ts"],"names":[],"mappings":";;;AACA,sDAA4K;AAE5K,IAAY,cAkBX;AAlBD,WAAY,cAAc;IACtB,+BAAa,CAAA;IACb,qCAAmB,CAAA;IACnB,uCAAqB,CAAA;IACrB,2BAAS,CAAA;IACT,mCAAiB,CAAA;IACjB,+BAAa,CAAA;IACb,qCAAmB,CAAA;IACnB,iCAAe,CAAA;IACf,uCAAqB,CAAA;IACrB,2CAAyB,CAAA;IACzB,yCAAuB,CAAA;IACvB,mCAAiB,CAAA;IACjB,+CAA6B,CAAA;IAC7B,2CAAyB,CAAA;IACzB,+BAAa,CAAA;IACb,qCAAmB,CAAA;IACnB,6CAA2B,CAAA;AAC/B,CAAC,EAlBW,cAAc,GAAd,sB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oBACzB;wBACI,SAAS;iBAChB;aACJ;SACJ;QACD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,CAAC;IAChF,CAAC;IAEM,WAAW,CAAC,IAAa,EAAE,UAAgC,EAAE,cAA8B,EAAE,OAAgB;QAChH,IAAI,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,YAAY,EAAE,CAAC,CAAC;QAC1D,IAAI,MAAM,GAAG,cAAc,KAAK,cAAc,CAAC,UAAU,CAAC;QAC1D,IAAI,QAAQ,GAAG,cAAc,KAAK,cAAc,CAAC,YAAY,CAAC;QAC9D,IAAI,MAAM,EAAE;YACR,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;SAC7B;QACD,IAAI;YACA,IAAI,SAAS,EAAE;gBACX,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,gBAAgB,CAAC,UAAU,EAAE,SAAS,EAAE,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,YAAY,EAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;aAC3J;iBAAM;gBACH,qCAAuB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;aAC7C;SACJ;QAAC,OAAO,CAAC,EAAE;YACR,qCAAuB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;SAC7C;IACL,CAAC;CAEJ;AA/HD,8CA+HC;AAED,SAAgB,iBAAiB,CAAC,IAAY;IAC1C,OAAO,gBAAgB,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,IAAI,cAAc,CAAC,IAAI,CAAC;AACvE,CAAC;AAFD,8CAEC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CodeCoverageProcessor = void 0;
|
|
4
|
+
class CodeCoverageProcessor {
|
|
5
|
+
constructor(builder) {
|
|
6
|
+
this._config = builder.options.rooibos || {};
|
|
7
|
+
this._fileId = 0;
|
|
8
|
+
try {
|
|
9
|
+
// this._coverageBrsTemplate = fs.readFileSync(path.join(__dirname, './CodeCoverageTemplate.brs'), 'utf8');
|
|
10
|
+
// this._coverageComponentBrsTemplate = fs.readFileSync(path.join(__dirname, './CodeCoverage.brs'), 'utf8');
|
|
11
|
+
// this._coverageComponentXmlTemplate = fs.readFileSync(path.join(__dirname, './CodeCoverage.xml'), 'utf8');
|
|
12
|
+
// this._coverageSupportTemplate = fs.readFileSync(path.join(__dirname, './CodeCoverageSupport.brs'), 'utf8');
|
|
13
|
+
}
|
|
14
|
+
catch (e) {
|
|
15
|
+
// console.log('Error:', e.stack);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
generateMetadata() {
|
|
19
|
+
//DO when everythin is ran
|
|
20
|
+
this.createCoverageComponent();
|
|
21
|
+
this.createCoverageSupport();
|
|
22
|
+
}
|
|
23
|
+
addCodeCoverage(file) {
|
|
24
|
+
//not yet supported
|
|
25
|
+
if (false && this._config.isRecordingCodeCoverage) {
|
|
26
|
+
this._processFile();
|
|
27
|
+
}
|
|
28
|
+
//if matches glob
|
|
29
|
+
// this._processFile(file);
|
|
30
|
+
//
|
|
31
|
+
}
|
|
32
|
+
_processFile() {
|
|
33
|
+
// this._fileId++;
|
|
34
|
+
// let fileContents = '';
|
|
35
|
+
// let lines = file.getFileContents().split(/\r?\n/);
|
|
36
|
+
// let coverageMap: Map<number, number> = new Map<number, number>();
|
|
37
|
+
// this.visitableLines = new Map<number, Statement>();
|
|
38
|
+
// this.getVisitableLinesForStatements(file.ast);
|
|
39
|
+
// //TODO - walks the ast
|
|
40
|
+
// for (let lineNumber = 0; lineNumber < lines.length; lineNumber++) {
|
|
41
|
+
// let line = lines[lineNumber];
|
|
42
|
+
// let statement = this.visitableLines.get(lineNumber);
|
|
43
|
+
// let coverageType = CodeCoverageLineType.noCode;
|
|
44
|
+
// if (statement) {
|
|
45
|
+
// if (statement instanceof IfStatement) {
|
|
46
|
+
// let conditionStartPos = statement.condition.range.start.character;
|
|
47
|
+
// let conditionEndPos = statement.condition.range.end.character;
|
|
48
|
+
// let funcCall = this.getFuncCallText(lineNumber, CodeCoverageLineType.condition);
|
|
49
|
+
// let conditionText = line.substr(conditionStartPos, conditionEndPos - conditionStartPos);
|
|
50
|
+
// let restofLineText = line.substring(conditionEndPos);
|
|
51
|
+
// line = `${line.substr(0, conditionStartPos)} ${funcCall} and (${conditionText}) ${restofLineText}`;
|
|
52
|
+
// coverageType = CodeCoverageLineType.condition;
|
|
53
|
+
// } else if (statement instanceof IfStatement) {
|
|
54
|
+
// // let conditionStartPos = statement.condition.location.start.column;
|
|
55
|
+
// // let conditionEndPos = statement.condition.location.end.column;
|
|
56
|
+
// // let funcCall = this.getFuncCallText(lineNumber, CodeCoverageLineType.condition);
|
|
57
|
+
// // let conditionText = line.substr(conditionStartPos, conditionEndPos - conditionStartPos);
|
|
58
|
+
// // let restofLineText = line.substring(conditionEndPos);
|
|
59
|
+
// // line = `${line.substr(0, conditionStartPos)} ${funcCall} and (${conditionText}) ${restofLineText}`;
|
|
60
|
+
// // coverageType = CodeCoverageLineType.condition;
|
|
61
|
+
// } else {
|
|
62
|
+
// //all types that can be prefixed with the funcall and a colon (i.e for, while, return foreach, assign)
|
|
63
|
+
// let funcCall = this.getFuncCallText(lineNumber, CodeCoverageLineType.code);
|
|
64
|
+
// line = `${funcCall}: ${line}`;
|
|
65
|
+
// coverageType = CodeCoverageLineType.code;
|
|
66
|
+
// }
|
|
67
|
+
// } else {
|
|
68
|
+
// `could not ascertain symbol type for line "${line} - ignoring`);
|
|
69
|
+
// }
|
|
70
|
+
// if (!line.endsWith('\n')) {
|
|
71
|
+
// line += '\n';
|
|
72
|
+
// }
|
|
73
|
+
// fileContents += line;
|
|
74
|
+
// if (coverageType > CodeCoverageLineType.noCode) {
|
|
75
|
+
// coverageMap.set(lineNumber, coverageType);
|
|
76
|
+
// }
|
|
77
|
+
// }
|
|
78
|
+
// this._expectedCoverageMap[this._fileId.toString().trim()] = Array.from(coverageMap);
|
|
79
|
+
// this._filePathMap[this._fileId] = file.pkgUri;
|
|
80
|
+
// fileContents += this.getBrsAPIText();
|
|
81
|
+
// file.setFileContents(fileContents);
|
|
82
|
+
//`Writing to ${file.fullPath}`);
|
|
83
|
+
// file.saveFileContents();
|
|
84
|
+
}
|
|
85
|
+
getBrsAPIText() {
|
|
86
|
+
let template = this._coverageBrsTemplate.replace(/\#ID\#/g, this._fileId.toString().trim());
|
|
87
|
+
return template;
|
|
88
|
+
}
|
|
89
|
+
createCoverageComponent() {
|
|
90
|
+
// //Write this out via program
|
|
91
|
+
// let targetPath = path.resolve(this._program.options.rootDir);
|
|
92
|
+
// let file = new File(path.resolve(path.join(targetPath), 'components'), 'components', 'CodeCoverage.xml', '.xml');
|
|
93
|
+
// file.setFileContents(this._coverageComponentXmlTemplate);
|
|
94
|
+
//`Writing to ${file.fullPath}`);
|
|
95
|
+
// file.saveFileContents();
|
|
96
|
+
// file = new File(path.resolve(path.join(targetPath, 'components')), 'components', 'CodeCoverage.brs', '.brs');
|
|
97
|
+
// let template = this._coverageComponentBrsTemplate;
|
|
98
|
+
// template = template.replace(/\#EXPECTED_MAP\#/g, JSON.stringify(this._expectedCoverageMap));
|
|
99
|
+
// template = template.replace(/\#FILE_PATH_MAP\#/g, JSON.stringify(this._filePathMap));
|
|
100
|
+
// file.setFileContents(template);
|
|
101
|
+
//`Writing to ${file.fullPath}`);
|
|
102
|
+
// file.saveFileContents();
|
|
103
|
+
}
|
|
104
|
+
createCoverageSupport() {
|
|
105
|
+
// //write this out via program
|
|
106
|
+
// let targetPath = path.resolve(this._program.options.rootDir);
|
|
107
|
+
// let file = new File(path.resolve(path.join(targetPath), 'source'), 'source', 'CodeCoverageSupport.brs', '.brs');
|
|
108
|
+
// file.setFileContents(this._coverageSupportTemplate);
|
|
109
|
+
//`Writing to ${file.fullPath}`);
|
|
110
|
+
// file.saveFileContents();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
exports.CodeCoverageProcessor = CodeCoverageProcessor;
|
|
114
|
+
//# sourceMappingURL=CodeCoverageProcessor.js.map
|