rooibos-roku 5.13.0 → 5.15.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 (62) hide show
  1. package/dist/cli.js +111 -0
  2. package/dist/cli.js.map +1 -0
  3. package/dist/lib/framework/components/roku_modules/rooibos_promises/Promise.xml +6 -0
  4. package/dist/lib/framework/manifest +0 -0
  5. package/dist/lib/framework/source/roku_modules/rokucommunity_bslib_v0/bslib.brs +48 -0
  6. package/dist/lib/framework/source/roku_modules/rooibos_promises/promises.brs +719 -0
  7. package/dist/lib/framework/source/roku_modules/rooibos_promises/promises.d.bs +166 -0
  8. package/dist/lib/framework/source/rooibos/BaseTestReporter.bs +87 -0
  9. package/dist/lib/framework/{BaseTestSuite.bs → source/rooibos/BaseTestSuite.bs} +851 -485
  10. package/dist/lib/framework/{CommonUtils.bs → source/rooibos/CommonUtils.bs} +173 -7
  11. package/dist/lib/framework/{ConsoleTestReporter.bs → source/rooibos/ConsoleTestReporter.bs} +56 -15
  12. package/dist/lib/framework/{JUnitTestReporter.bs → source/rooibos/JUnitTestReporter.bs} +1 -1
  13. package/dist/lib/framework/source/rooibos/MochaTestReporter.bs +967 -0
  14. package/dist/lib/framework/{Rooibos.bs → source/rooibos/Rooibos.bs} +8 -6
  15. package/dist/lib/framework/{Stats.bs → source/rooibos/Stats.bs} +3 -0
  16. package/dist/lib/framework/source/rooibos/Test.bs +193 -0
  17. package/dist/lib/framework/{TestGroup.bs → source/rooibos/TestGroup.bs} +107 -56
  18. package/dist/lib/framework/{TestResult.bs → source/rooibos/TestResult.bs} +21 -3
  19. package/dist/lib/framework/{TestRunner.bs → source/rooibos/TestRunner.bs} +41 -60
  20. package/dist/lib/rooibos/Annotation.js +28 -4
  21. package/dist/lib/rooibos/Annotation.js.map +1 -1
  22. package/dist/lib/rooibos/CodeCoverageProcessor.js +6 -1
  23. package/dist/lib/rooibos/CodeCoverageProcessor.js.map +1 -1
  24. package/dist/lib/rooibos/CodeCoverageProcessor.spec.js +507 -0
  25. package/dist/lib/rooibos/CodeCoverageProcessor.spec.js.map +1 -0
  26. package/dist/lib/rooibos/FileFactory.js +48 -45
  27. package/dist/lib/rooibos/FileFactory.js.map +1 -1
  28. package/dist/lib/rooibos/MockUtil.spec.js +484 -0
  29. package/dist/lib/rooibos/MockUtil.spec.js.map +1 -0
  30. package/dist/lib/rooibos/RawCodeExpression.js +3 -0
  31. package/dist/lib/rooibos/RawCodeExpression.js.map +1 -1
  32. package/dist/lib/rooibos/RawCodeStatement.js +3 -0
  33. package/dist/lib/rooibos/RawCodeStatement.js.map +1 -1
  34. package/dist/lib/rooibos/RooibosSession.js +8 -0
  35. package/dist/lib/rooibos/RooibosSession.js.map +1 -1
  36. package/dist/lib/rooibos/RooibosSessionInfo.js +59 -94
  37. package/dist/lib/rooibos/RooibosSessionInfo.js.map +1 -1
  38. package/dist/lib/rooibos/TestCase.js +4 -8
  39. package/dist/lib/rooibos/TestCase.js.map +1 -1
  40. package/dist/lib/rooibos/TestGroup.js +6 -16
  41. package/dist/lib/rooibos/TestGroup.js.map +1 -1
  42. package/dist/lib/rooibos/TestSuite.js +11 -13
  43. package/dist/lib/rooibos/TestSuite.js.map +1 -1
  44. package/dist/lib/rooibos/TestSuiteBuilder.js +3 -0
  45. package/dist/lib/rooibos/TestSuiteBuilder.js.map +1 -1
  46. package/dist/lib/rooibos/TestSuiteBuilder.spec.js +1126 -0
  47. package/dist/lib/rooibos/TestSuiteBuilder.spec.js.map +1 -0
  48. package/dist/lib/utils/Diagnostics.js +5 -1
  49. package/dist/lib/utils/Diagnostics.js.map +1 -1
  50. package/dist/plugin.js +4 -1
  51. package/dist/plugin.js.map +1 -1
  52. package/package.json +22 -6
  53. package/dist/lib/framework/BaseTestReporter.bs +0 -27
  54. package/dist/lib/framework/Test.bs +0 -110
  55. /package/dist/lib/framework/{CodeCoverage.xml → components/rooibos/CodeCoverage.xml} +0 -0
  56. /package/dist/lib/framework/{RooibosScene.xml → components/rooibos/RooibosScene.xml} +0 -0
  57. /package/dist/lib/framework/{CodeCoverage.brs → source/rooibos/CodeCoverage.brs} +0 -0
  58. /package/dist/lib/framework/{CodeCoverageSupport.brs → source/rooibos/CodeCoverageSupport.brs} +0 -0
  59. /package/dist/lib/framework/{Coverage.bs → source/rooibos/Coverage.bs} +0 -0
  60. /package/dist/lib/framework/{Matchers.bs → source/rooibos/Matchers.bs} +0 -0
  61. /package/dist/lib/framework/{RuntimeConfig.bs → source/rooibos/RuntimeConfig.bs} +0 -0
  62. /package/dist/lib/framework/{Utils.bs → source/rooibos/Utils.bs} +0 -0
package/dist/cli.js ADDED
@@ -0,0 +1,111 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const roku_debug_1 = require("roku-debug");
5
+ const brighterscript_1 = require("brighterscript");
6
+ const yargs = require("yargs");
7
+ const roku_deploy_1 = require("roku-deploy");
8
+ const fs = require("fs");
9
+ let options = yargs
10
+ .usage('$0', 'Rooibos: a simple, flexible, fun Brightscript test framework for Roku Scenegraph apps')
11
+ .help('help', 'View help information about this tool.')
12
+ .option('project', { type: 'string', description: 'Path to a bsconfig.json project file.' })
13
+ .option('host', { type: 'string', description: 'Host of the Roku device to connect to. Overrides value in bsconfig file.' })
14
+ .option('password', { type: 'string', description: 'Password of the Roku device to connect to. Overrides value in bsconfig file.' })
15
+ .option('log-level', { type: 'string', defaultDescription: '"log"', description: 'The log level. Value can be "error", "warn", "log", "info", "debug".' })
16
+ .check((argv) => {
17
+ if (!argv.host) {
18
+ return new Error('You must provide a host. (--host)');
19
+ }
20
+ if (!argv.password) {
21
+ return new Error('You must provide a password. (--password)');
22
+ }
23
+ if (!argv.project) {
24
+ console.log('No project file specified. Using "./bsconfig.json"');
25
+ }
26
+ let bsconfigPath = argv.project || './bsconfig.json';
27
+ if (!fs.existsSync(bsconfigPath)) {
28
+ return new Error(`Unable to load ${bsconfigPath}`);
29
+ }
30
+ return true;
31
+ })
32
+ .argv;
33
+ async function main() {
34
+ var _a, _b, _c, _d;
35
+ let currentErrorCode = 0;
36
+ let bsconfigPath = (_a = options.project) !== null && _a !== void 0 ? _a : 'bsconfig.json';
37
+ console.log(`Using bsconfig: ${bsconfigPath}`);
38
+ const rawConfig = brighterscript_1.util.loadConfigFile(bsconfigPath);
39
+ const bsConfig = brighterscript_1.util.normalizeConfig(rawConfig);
40
+ const host = (_b = options.host) !== null && _b !== void 0 ? _b : bsConfig.host;
41
+ const password = (_c = options.password) !== null && _c !== void 0 ? _c : bsConfig.password;
42
+ const logLevel = (_d = brighterscript_1.LogLevel[options['log-level']]) !== null && _d !== void 0 ? _d : bsConfig.logLevel;
43
+ const builder = new brighterscript_1.ProgramBuilder();
44
+ builder.logger.logLevel = logLevel;
45
+ await builder.run(Object.assign(Object.assign({}, options), { retainStagingDir: true, createPackage: true }));
46
+ const rokuDeploy = new roku_deploy_1.RokuDeploy();
47
+ const deviceInfo = await rokuDeploy.getDeviceInfo({ host: host });
48
+ const rendezvousTracker = new roku_debug_1.RendezvousTracker({ softwareVersion: deviceInfo['software-version'] }, { host: host, remotePort: 8085 });
49
+ const telnet = new roku_debug_1.TelnetAdapter({ host: options.host }, rendezvousTracker);
50
+ telnet.logger.logLevel = logLevel;
51
+ await telnet.activate();
52
+ await telnet.connect();
53
+ const failRegex = /\[Rooibos Result\]: (FAIL|PASS)/g;
54
+ const endRegex = /\[Rooibos Shutdown\]/g;
55
+ async function doExit(emitAppExit = false) {
56
+ if (emitAppExit) {
57
+ telnet.beginAppExit();
58
+ }
59
+ await rokuDeploy.pressHomeButton(host); // roku-deploy v4: keyPress({ host: options.host, key: 'home' });
60
+ process.exit(currentErrorCode);
61
+ }
62
+ telnet.on('console-output', (output) => {
63
+ console.log(output);
64
+ //check for Fails or Crashes
65
+ let failMatches = failRegex.exec(output);
66
+ if (failMatches && failMatches.length > 0) {
67
+ if (failMatches[1] === 'FAIL') {
68
+ currentErrorCode = 1;
69
+ }
70
+ }
71
+ let endMatches = endRegex.exec(output);
72
+ if (endMatches && endMatches.length > 0) {
73
+ doExit(true).catch(e => {
74
+ console.error(e);
75
+ process.exit(1);
76
+ });
77
+ }
78
+ });
79
+ telnet.on('runtime-error', (error) => {
80
+ console.error(`Runtime Error: ${error.errorCode} - ${error.message}`);
81
+ currentErrorCode = 1;
82
+ doExit(true).catch(e => {
83
+ console.error(e);
84
+ process.exit(1);
85
+ });
86
+ });
87
+ telnet.on('app-exit', () => {
88
+ doExit(false).catch(e => {
89
+ console.error(e);
90
+ process.exit(1);
91
+ });
92
+ });
93
+ // Actually start the unit tests
94
+ //deploy a .zip package of your project to a roku device
95
+ async function deployBuiltFiles() {
96
+ const outFile = bsConfig.outFile;
97
+ console.log(`Deploying ${outFile} to ${host}`);
98
+ await rokuDeploy.publish({
99
+ password: password,
100
+ host: host,
101
+ outFile: outFile,
102
+ outDir: process.cwd()
103
+ });
104
+ }
105
+ await deployBuiltFiles();
106
+ }
107
+ main().catch(e => {
108
+ console.error(e);
109
+ process.exit(1);
110
+ });
111
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;AAEA,2CAA8D;AAE9D,mDAAgE;AAChE,+BAA+B;AAC/B,6CAAyC;AACzC,yBAAyB;AAIzB,IAAI,OAAO,GAAG,KAAK;KACd,KAAK,CAAC,IAAI,EAAE,uFAAuF,CAAC;KACpG,IAAI,CAAC,MAAM,EAAE,wCAAwC,CAAC;KACtD,MAAM,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,uCAAuC,EAAE,CAAC;KAC3F,MAAM,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,0EAA0E,EAAE,CAAC;KAC3H,MAAM,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,8EAA8E,EAAE,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,CAAC,CAAC,CAAC,CAAC;YACjB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,gCAAgC;IAEhC,wDAAwD;IACxD,KAAK,UAAU,gBAAgB;QAC3B,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;QACjC,OAAO,CAAC,GAAG,CAAC,aAAa,OAAO,OAAO,IAAI,EAAE,CAAC,CAAC;QAC/C,MAAM,UAAU,CAAC,OAAO,CAAC;YACrB,QAAQ,EAAE,QAAQ;YAClB,IAAI,EAAE,IAAI;YACV,OAAO,EAAE,OAAO;YAChB,MAAM,EAAE,OAAO,CAAC,GAAG,EAAE;SACxB,CAAC,CAAC;IACP,CAAC;IAED,MAAM,gBAAgB,EAAE,CAAC;AAC7B,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;IACb,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACjB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ <component name="rooibos_promises_Promise" extends="Node">
2
+ <interface>
3
+ <field id="promiseState" type="string" value="pending" alwaysNotify="true" />
4
+ </interface>
5
+ </component>
6
+ <!--//# sourceMappingURL=./Promise.xml.map -->
File without changes
@@ -0,0 +1,48 @@
1
+ ' bslib: BrightScript runtime functions for the BrighterScript language
2
+ ' v0.1.1
3
+
4
+ '
5
+ ' Convert a value into a string. For non-primitive values, this will return the type instead of its value in most cases.
6
+ ' @param dynamic value - the value to be turned into a string.
7
+ ' @return string - the string representation of `value`
8
+ '
9
+ function rokucommunity_bslib_v0_toString(value)
10
+ valueType = type(value)
11
+ 'if the var supports `toStr()`
12
+ if valueType = "<uninitialized>" then
13
+ return valueType
14
+ else if value = invalid then
15
+ return "<invalid>"
16
+ else if GetInterface(value, "ifToStr") <> invalid then
17
+ return value.toStr()
18
+ else if valueType = "roSGNode"
19
+ return "Node(" + value.subType() + ")"
20
+ end if
21
+ 'TODO add class name for objects once we have reflection implemented
22
+
23
+ 'when all else fails, just return the type
24
+ return "<" + valueType + ">"
25
+ end function
26
+
27
+ '
28
+ ' Simple ternary function. Given a condition, return the
29
+ ' consequent if true, and the alternate if false
30
+ '
31
+ function rokucommunity_bslib_v0_ternary(condition, consequent, alternate)
32
+ if condition then
33
+ return consequent
34
+ else
35
+ return alternate
36
+ end if
37
+ end function
38
+
39
+ '
40
+ ' Return consequent if consequent is not invalid, otherwise return alternate
41
+ '
42
+ function rokucommunity_bslib_v0_coalesce(consequent, alternate)
43
+ if consequent <> invalid then
44
+ return consequent
45
+ else
46
+ return alternate
47
+ end if
48
+ end function