diff --git a/.gitignore b/.gitignore index da5d3c0e..0ff86319 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,11 @@ rooibosDist.brs yarn.lock yarn-error.log /outRun/ +node_modules/ +out +**/roku_modules/ +package-lock.json + +!.vscode +.vscode/.env +dist/ diff --git a/.vscode/launch.json b/.vscode/launch.json index f1ef0db1..47127ff0 100755 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -8,7 +8,7 @@ "consoleOutput": "full", "internalConsoleOptions": "neverOpen", "preLaunchTask": "build-tests", - "envFile": "${workspaceFolder}/frameworkTests/.vscode/.env", + "envFile": "${workspaceFolder}/tests/.vscode/.env", "host": "${env:ROKU_DEV_TARGET}", "password": "${env:ROKU_DEVPASSWORD}", "retainStagingFolder": true, @@ -24,9 +24,9 @@ "!*.zip", "!**/*.zip" ], - "rootDir": "${workspaceFolder}/frameworkTests/build", + "rootDir": "${workspaceFolder}/tests/build", "sourceDirs": [ - "${workspaceFolder}/frameworkTests/src", + "${workspaceFolder}/tests/src", ], "enableDebuggerAutoRecovery": true, "stopDebuggerOnAppExit": true, diff --git a/.vscode/settings.json b/.vscode/settings.json index 9610d5f0..81d31881 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,11 +1,11 @@ -{ - "jira-plugin.workingProject": "", - "workbench.colorCustomizations": { - "statusBar.background": "#551A8B", - "statusBar.debuggingBackground": "#551A8B", - "panelTitle.activeBorder": "#ff0000", - "activityBar.background": "#452613", - "titleBar.activeBackground": "#61351A", - "titleBar.activeForeground": "#FDFAF9" - } +{ + "jira-plugin.workingProject": "", + "workbench.colorCustomizations": { + "statusBar.background": "#551A8B", + "statusBar.debuggingBackground": "#551A8B", + "panelTitle.activeBorder": "#ff0000", + "activityBar.background": "#143141", + "titleBar.activeBackground": "#1D445B", + "titleBar.activeForeground": "#F7FBFD" + } } \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 3592df41..eeba10d5 100755 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -18,24 +18,6 @@ "kind": "test", "isDefault": true } - }, - { - "label": "build-tests-with-coverage", - "type": "shell", - "command": "gulp build && cd frameworkTests && export TS_NODE_COMPILER_OPTIONS='{\"incremental\":true, \"allowJs\":false}' && export TS_NODE_TRANSPILE_ONLY=true && gulp prepareCodeCoverageTests", - "problemMatcher": [], - "presentation": { - "echo": true, - "reveal": "silent", - "focus": false, - "panel": "shared", - "showReuseMessage": false, - "clear": true - }, - "group": { - "kind": "test", - "isDefault": true - } } ] } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index da44584e..a36bb860 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,364 +1,290 @@ -#### 4.0.0 (2020-06-12) +### Changelog -This is a BREAKING RELEASE. +All notable changes to this project will be documented in this file. Dates are displayed in UTC. -You will have to change how you initialize rooibos. In your main.brs, you will now put: +Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). -``` - if (type(Rooibos_init) = "Function") then - 'bs:disable-next-line - if (type(Rooibos_init) = "Function") then Rooibos_init() - end if -``` +#### [v4.2.1](https://github.com/georgejecook/rooibos/compare/4.1.1...v4.2.1) -refer to the [documentation](file:///home/george/hope/open-source/rooibos/docs/module-rooibos.html#.Rooibos_init) for more info. +- fix(framework): Fixes framework tests [`7008e9d`](https://github.com/georgejecook/rooibos/commit/7008e9de1f21c78948a58eafdf3c7a799f0b454c) +- version bump [`a5dc306`](https://github.com/georgejecook/rooibos/commit/a5dc30636e911744c57912619603fc641c33ea90) +- doc improvements [`58d3c7a`](https://github.com/georgejecook/rooibos/commit/58d3c7a1d957a82788fb9ea09202ba6a7765464c) -#### Chores +#### [4.1.1](https://github.com/georgejecook/rooibos/compare/4.1.0...4.1.1) -* **core:** - * Upgrades to use the official brighterscript compiler - * Better partitions code into namespaces and classes - * Adds bs:disable-next-line directives to dynamically resovled function calls +> 1 March 2021 -##### Bug Fixes +- adds scripts for easy remote/local npm switching [`c033761`](https://github.com/georgejecook/rooibos/commit/c033761afcf5958228b16fe62cfd6cbc05e3b1a5) +- compile against latest bsc [`7d2c187`](https://github.com/georgejecook/rooibos/commit/7d2c187b61fec2da6fc4618018c570cbc1a29f93) -* **Core:** - * Fixes several small bugs, including wrong params sent for nodeContains and crashes on lcov reporting and test reporting - -#### 3.6.1 (2020-05-21) +#### [4.1.0](https://github.com/georgejecook/rooibos/compare/4.0.6...4.1.0) -##### Chores +> 23 February 2021 -* **tests:** Adds node test to framework suite, and also improves the file structure to include placeholder files, so as to better conform with brighterscript compiler ([f23b81d8](https://github.com/georgejecook/rooibos/commit/f23b81d8e34a6e0e86af84dc2441d0755bb5eba2)) +- feat: improves handling of errors in assertions [`f80d19b`](https://github.com/georgejecook/rooibos/commit/f80d19b405477f7fc46005b42eb49969818c6087) +- bump to 4.1.1 [`f349941`](https://github.com/georgejecook/rooibos/commit/f349941c4934f9f430670ccb65990e0bfa2b09de) +- bunch of fixes [`d95a506`](https://github.com/georgejecook/rooibos/commit/d95a50601520a33286123d1c837fe8102e9dcbb1) -##### Bug Fixes +#### [4.0.6](https://github.com/georgejecook/rooibos/compare/4.0.0...4.0.6) -* **TestRunner:** - * Do not crash if node tests do not return stat object, and instead provide useful links to documentation to help devs out ([a643df7a](https://github.com/georgejecook/rooibos/commit/a643df7ac3ec2245c972ad05f2adc65441fade22)) - * Adds more logoutput when a node test does not complete ([c4277d66](https://github.com/georgejecook/rooibos/commit/c4277d66779b7b6c9f77cbc71c74d60e7668dfb1)) +> 11 February 2021 -#### 3.6.0 (2020-05-21) +- feat(framework-tests): Improve framework tests by making it a bsc compiled app, so that it servers of an example of how to use rooibos with bsc [`#114`](https://github.com/georgejecook/rooibos/pull/114) +- first stab at moving over to ropm [`81b9e8f`](https://github.com/georgejecook/rooibos/commit/81b9e8f18c5005405ee7e303890e12735b3c05b7) +- refactoring to reflect new plugin-driven pattenr [`32faa19`](https://github.com/georgejecook/rooibos/commit/32faa192158081b8c2f325236dfc9592b377c610) +- adds linting and testing setup. Thanks Bronley Plumb [`cab1266`](https://github.com/georgejecook/rooibos/commit/cab12663620fabddf11c6e84632d0afb400e9ff8) -##### Chores +### [4.0.0](https://github.com/georgejecook/rooibos/compare/3.6.1...4.0.0) -* **docs:** add async assert docs ([6261e551](https://github.com/georgejecook/rooibos/commit/6261e551f1e6a3ad92eef07d2236c203141fa0ec)) +> 12 June 2020 -##### New Features +- Chore/move to new bs compiler [`#106`](https://github.com/georgejecook/rooibos/pull/106) +- bump to 4.0.0 [`a8eb8ac`](https://github.com/georgejecook/rooibos/commit/a8eb8acaede9a40d1a97733e73666bfd176bbbd7) +- chore(docs): adds missing logo [`2101474`](https://github.com/georgejecook/rooibos/commit/2101474ebc5106bd0c74be3bcfac2110e75c4d71) +- Update logos [`ea3200f`](https://github.com/georgejecook/rooibos/commit/ea3200f78b9d8bd1c7ceed01588e47111bbfa48c) -* **assertions:** adds support for async fields ([28f32754](https://github.com/georgejecook/rooibos/commit/28f32754daee7d4adef7a4e18baa0d6af07653f9)) +#### [3.6.1](https://github.com/georgejecook/rooibos/compare/3.6.0...3.6.1) -#### 3.5.1 (2020-05-20) +> 21 May 2020 -##### Bug Fixes +- chore(tests): Adds node test to framework suite, and also improves the file structure to include placeholder files, so as to better conform with brighterscript compiler [`f23b81d`](https://github.com/georgejecook/rooibos/commit/f23b81d8e34a6e0e86af84dc2441d0755bb5eba2) +- chore(core): bump to 3.6.1 [`167fab1`](https://github.com/georgejecook/rooibos/commit/167fab1bca39a381201664ffb4ca3d6132bfc4b3) +- fix(TestRunner): Adds more logoutput when a node test does not complete [`c4277d6`](https://github.com/georgejecook/rooibos/commit/c4277d66779b7b6c9f77cbc71c74d60e7668dfb1) -* **TestRunner:** Addresses issue that prevented node tests from correctly running ([c6aec599](https://github.com/georgejecook/rooibos/commit/c6aec599edd1e61cf90634a5bf718af1f02560d1)) +#### [3.6.0](https://github.com/georgejecook/rooibos/compare/3.5.1...3.6.0) -#### 3.5.0 (2020-05-20) +> 21 May 2020 -##### New Features +- feat(assertions): adds support for async fields [`28f3275`](https://github.com/georgejecook/rooibos/commit/28f32754daee7d4adef7a4e18baa0d6af07653f9) +- chore(docs): add async assert docs [`6261e55`](https://github.com/georgejecook/rooibos/commit/6261e551f1e6a3ad92eef07d2236c203141fa0ec) +- chore(core): bump to 3.6.0 [`660926b`](https://github.com/georgejecook/rooibos/commit/660926bb0d72997916863877d51c3e5b61da44c5) -* **runner:** adds ability to wait on scene.isReadyToStartTests, if present before starting the tests ([c1b71a9a](https://github.com/georgejecook/rooibos/commit/c1b71a9a6f7b8e4e974ecf33d4928d3b249b2532)) +#### [3.5.1](https://github.com/georgejecook/rooibos/compare/3.5.0...3.5.1) -##### Bug Fixes +> 20 May 2020 -* **mocks:** Better handling for mock creation failures ([df74e3b5](https://github.com/georgejecook/rooibos/commit/df74e3b52caf42ae9f8439a92694c7c36a7a827c)) +- fix(TestRunner): Addresses issue that prevented node tests from correctly running [`c6aec59`](https://github.com/georgejecook/rooibos/commit/c6aec599edd1e61cf90634a5bf718af1f02560d1) +- bump to 3.5.1 [`a08fff6`](https://github.com/georgejecook/rooibos/commit/a08fff6d25cc1d4a783dce15eac4d7f402adf676) -#### 3.4.3 (2020-05-10) +#### [3.5.0](https://github.com/georgejecook/rooibos/compare/3.4.3...3.5.0) -##### Bug Fixes +> 20 May 2020 -* **mocks:** Fixes crash on multi expect ([e02f96ca](https://github.com/georgejecook/rooibos/commit/e02f96cab091fc6a0d622f85b7302d7c48480aca)) +- feat(runner): adds ability to wait on scene.isReadyToStartTests, if present before starting the tests [`c1b71a9`](https://github.com/georgejecook/rooibos/commit/c1b71a9a6f7b8e4e974ecf33d4928d3b249b2532) +- fix(mocks): Better handling for mock creation failures [`df74e3b`](https://github.com/georgejecook/rooibos/commit/df74e3b52caf42ae9f8439a92694c7c36a7a827c) +- bump to 3.5.0 [`6246d42`](https://github.com/georgejecook/rooibos/commit/6246d420a0fa0a8e67f0e826487cb047bc99316d) -#### 3.4.2 (2020-05-07) +#### [3.4.3](https://github.com/georgejecook/rooibos/compare/3.4.2...3.4.3) -##### New Features +> 10 May 2020 -* **mocks:** adds shadow methods to facilitate mock failure line number reporting ([d1e652cc](https://github.com/georgejecook/rooibos/commit/d1e652cc9a622b7c3ee7bd86937d5b826ea08dc3)) +- bound to 3.4.3 [`c217996`](https://github.com/georgejecook/rooibos/commit/c2179965364b0d85e5ba0af97c7d88d891656abe) +- hotfix for wln error [`b30d44e`](https://github.com/georgejecook/rooibos/commit/b30d44e55e0b18e5842747562af06a584f0cb8af) +- fix(mocks): Fixes crash on multi expect [`e02f96c`](https://github.com/georgejecook/rooibos/commit/e02f96cab091fc6a0d622f85b7302d7c48480aca) -#### 3.4.1 (2020-05-06) +#### [3.4.2](https://github.com/georgejecook/rooibos/compare/3.4.1...3.4.2) -##### Bug Fixes +> 7 May 2020 -* **core:** minor logger fix ([61ee8113](https://github.com/georgejecook/rooibos/commit/61ee81136a609586c96e553ea49ab7828c7424fa)) +- feat(mocks):adds shadow methods to facilitate mock failure line number reporting [`d1e652c`](https://github.com/georgejecook/rooibos/commit/d1e652cc9a622b7c3ee7bd86937d5b826ea08dc3) +- chore: bounce to 3.4.2 [`cc2c559`](https://github.com/georgejecook/rooibos/commit/cc2c5598ab88def1d2dd93f35b8459b542959329) -#### 3.4.0 (2020-05-05) +#### [3.4.1](https://github.com/georgejecook/rooibos/compare/3.4.0...3.4.1) -##### Chores +> 5 May 2020 -* update version txt ([6066fd0b](https://github.com/georgejecook/rooibos/commit/6066fd0b344c4efc9aa559a8597007d794350d79)) +- bounce to 3.4.1 [`f9c4935`](https://github.com/georgejecook/rooibos/commit/f9c4935b4337b41d3fb69a666c95f6be40e1735c) +- updates version.txt [`ae130f3`](https://github.com/georgejecook/rooibos/commit/ae130f393a9df1014b8683c233f5f20603ff0e6f) +- fix(core): minor logger fix [`61ee811`](https://github.com/georgejecook/rooibos/commit/61ee81136a609586c96e553ea49ab7828c7424fa) -##### New Features +#### [3.4.0](https://github.com/georgejecook/rooibos/compare/3.3.0...3.4.0) -* **core:** Adds lcov report, and moves test files to brighterscript ([99b8d50a](https://github.com/georgejecook/rooibos/commit/99b8d50a7c0668c0bca29eedfdc190ebe10ff7e7)) -* lcov support ([0cfb9181](https://github.com/georgejecook/rooibos/commit/0cfb91813587fb26a7be1e3f64ad798be2e86b83)) -* **runner:** allows for up to 12 params on parameterized tests ([e9e9dfd7](https://github.com/georgejecook/rooibos/commit/e9e9dfd773abd64116d175e38a11eb731dab3e0a)) +> 4 May 2020 -#### 3.3.0 (2019-09-26) +- Feature/option to remove test times [`#82`](https://github.com/georgejecook/rooibos/pull/82) +- add option to not print test times [`#80`](https://github.com/georgejecook/rooibos/pull/80) +- Regenerates package-lock.json [`bf210cd`](https://github.com/georgejecook/rooibos/commit/bf210cd60062f04e807735dc8f2f772f786273ce) +- feat(core): Adds lcov report, and moves test files to brighterscript [`99b8d50`](https://github.com/georgejecook/rooibos/commit/99b8d50a7c0668c0bca29eedfdc190ebe10ff7e7) +- feat: lcov support [`0cfb918`](https://github.com/georgejecook/rooibos/commit/0cfb91813587fb26a7be1e3f64ad798be2e86b83) -##### Chores +#### [3.3.0](https://github.com/georgejecook/rooibos/compare/3.2.1...3.3.0) -* adds changelog generator to dependencies ([22a25308](https://github.com/georgejecook/rooibos/commit/22a25308cd4d448c4cdd01087dc43cda74ca82d5)) +> 26 September 2019 -##### New Features +- feat: Increase mocks limit to 25 - it is now possible to create up to 25 mocks for a given test suite. [`#73`](https://github.com/georgejecook/rooibos/pull/73) +- chore:adds changelog generator to dependencies [`22a2530`](https://github.com/georgejecook/rooibos/commit/22a25308cd4d448c4cdd01087dc43cda74ca82d5) +- version bounce, remove file that should not be scm [`0e60d54`](https://github.com/georgejecook/rooibos/commit/0e60d549504dda61ed53b3cb55aa005c20b123ca) +- fix: fixes incorrect reporting of version numbers during test run [`e820831`](https://github.com/georgejecook/rooibos/commit/e820831823993e33a6581926701d8263f7826fc4) -* Increase mocks limit to 25 - it is now possible to create up to 25 mocks for a given test suite. ([#73](https://github.com/georgejecook/rooibos/pull/73)) ([92369c3c](https://github.com/georgejecook/rooibos/commit/92369c3cc12e38065d6b4faaedf5a5c46995774b)) +#### [3.2.1](https://github.com/georgejecook/rooibos/compare/3.2.0...3.2.1) -##### Bug Fixes +> 22 September 2019 -* fixes incorrect reporting of version numbers during test run ([e8208318](https://github.com/georgejecook/rooibos/commit/e820831823993e33a6581926701d8263f7826fc4)) +- fix: fixes regression in node tests [`7b63c69`](https://github.com/georgejecook/rooibos/commit/7b63c69ecacdd26d6d9b067b46eb56908ae869e7) +- bounce to 3.2.1 [`07067e4`](https://github.com/georgejecook/rooibos/commit/07067e4ea3f3ddc74afe72fa46c89231f2521154) +- chore: add bash task to run gulp, coz vscode ide keeps opening a gulp tab [`c7a45ad`](https://github.com/georgejecook/rooibos/commit/c7a45ad2160fd3c7c31a7ccf692440ad7ec7391b) -#### 3.2.2 (2019-09-23) +#### [3.2.0](https://github.com/georgejecook/rooibos/compare/3.1.1...3.2.0) -#### 3.2.1 (2019-09-23) +> 22 September 2019 -##### Chores +- feat: migrate to using brighterscript, via maestro project's compiler [`391b902`](https://github.com/georgejecook/rooibos/commit/391b902c82b63a261a73f452879fbde72eb57ae0) +- chore: adds documentation for matchers [`ef79171`](https://github.com/georgejecook/rooibos/commit/ef791711abe87a02ee5c935aa5ac34f178cdf6e3) +- feat: adds matchers for mocks, you can now use built in anyXXXMatchers, or roll your own as function pointers, or inline functions [`f87609e`](https://github.com/georgejecook/rooibos/commit/f87609e5c1e0dc0b532333be4d6971755d3af229) -* add bash task to run gulp, coz vscode ide keeps opening a gulp tab ([c7a45ad2](https://github.com/georgejecook/rooibos/commit/c7a45ad2160fd3c7c31a7ccf692440ad7ec7391b)) +#### [3.1.1](https://github.com/georgejecook/rooibos/compare/3.1.0...3.1.1) -##### Bug Fixes +> 10 August 2019 -* fixes regression in node tests ([7b63c69e](https://github.com/georgejecook/rooibos/commit/7b63c69ecacdd26d6d9b067b46eb56908ae869e7)) +- fixes compatability issues with rooibos cli [`#68`](https://github.com/georgejecook/rooibos/pull/68) +- adds version task to gulp file and fixes docs [`815a61f`](https://github.com/georgejecook/rooibos/commit/815a61f39033d85b33d55fbba4b986008a30c7f4) +- updates version to 3.1.1 [`0a11e3d`](https://github.com/georgejecook/rooibos/commit/0a11e3dbd4339983763a40ced892afc6bd1d92a5) +- updates docs [`f2d9a1a`](https://github.com/georgejecook/rooibos/commit/f2d9a1ab112e6aa0f54758d880b3125b224b0c9b) -#### 3.2.0 (2019-09-22) +#### [3.1.0](https://github.com/georgejecook/rooibos/compare/3.0.4...3.1.0) -##### Chores +> 18 July 2019 -* adds documentation for matchers ([ef791711](https://github.com/georgejecook/rooibos/commit/ef791711abe87a02ee5c935aa5ac34f178cdf6e3)) +- Feature/check version [`#66`](https://github.com/georgejecook/rooibos/pull/66) +- adds legacy support [`#61`](https://github.com/georgejecook/rooibos/pull/61) +- adds checks for version [`17b9d83`](https://github.com/georgejecook/rooibos/commit/17b9d83ba717911672ba8adc6ae83c58f01d6c60) +- some format fixes [`745af9c`](https://github.com/georgejecook/rooibos/commit/745af9c9ae0170d1db5f15f79ae78e7f451b907a) +- some format fixes [`dba439c`](https://github.com/georgejecook/rooibos/commit/dba439c7fc26721d434322aea4f2e19abb460cf2) -##### New Features +#### [3.0.4](https://github.com/georgejecook/rooibos/compare/3.0.3...3.0.4) -* adds matchers for mocks, you can now use built in anyXXXMatchers, or roll your own as function pointers, or inline functions ([f87609e5](https://github.com/georgejecook/rooibos/commit/f87609e5c1e0dc0b532333be4d6971755d3af229)) -* migrate to using brighterscript, via maestro project's compiler ([391b902c](https://github.com/georgejecook/rooibos/commit/391b902c82b63a261a73f452879fbde72eb57ae0)) +> 23 June 2019 -##### Bug Fixes +- adds legacy support documentation [`a1fc451`](https://github.com/georgejecook/rooibos/commit/a1fc4515d7abc542f834d53f4260903c69b2ff74) +- fix borked formatting on rooibosC args table in the docs [`464b9cf`](https://github.com/georgejecook/rooibos/commit/464b9cf71da4915d62b821f16d9f6d325dc204fc) -* fixes versoin number mismatch errors - the framework now correctly ascertains if it has a version greater than the minimum required version, instead of requiring a direct match ([c6baa2dc](https://github.com/georgejecook/rooibos/commit/c6baa2dc33ef689b49ffc68310bb6f95f0919549)) +#### [3.0.3](https://github.com/georgejecook/rooibos/compare/3.0.2-beta...3.0.3) -# Rooibos CHANGELOG +> 4 June 2019 -## 3.0.4 - legacy support! +- Feature/move json config [`#54`](https://github.com/georgejecook/rooibos/pull/54) +- bounce to 3.0.3 [`3c81064`](https://github.com/georgejecook/rooibos/commit/3c8106406baaff619ad216ff8a062e8407256709) +- runtime config is now provided by rooibosC [`774ade1`](https://github.com/georgejecook/rooibos/commit/774ade1ec8740fbb15d4025cd607674224bebab6) +- fix for box crash on asString when used on an aa with mock methods [`8367146`](https://github.com/georgejecook/rooibos/commit/8367146f8f6a13e1183fb23aa6da92cc8253a14b) -### Added +#### [3.0.2-beta](https://github.com/georgejecook/rooibos/compare/3.0.1-beta...3.0.2-beta) - - legacy support with rooibosC 3.0.9 or later +> 28 May 2019 -### Changed +- adds path to test suite output [`73f0d17`](https://github.com/georgejecook/rooibos/commit/73f0d17a673d0ebd9f28e9e8ffb5be7721b6d4e7) -### Deprecated +#### [3.0.1-beta](https://github.com/georgejecook/rooibos/compare/3.0.0-beta...3.0.1-beta) -### Removed +> 27 May 2019 -### Fixed +- improves docs for code coverage [`f388804`](https://github.com/georgejecook/rooibos/commit/f388804f410b069b7a99d9fd6d7ee3a9fec07a55) - - ignored tests are now reported +#### [3.0.0-beta](https://github.com/georgejecook/rooibos/compare/2.3.0...3.0.0-beta) -## 3.0.3 - out of beta - yay! +> 25 May 2019 -### Added +- Feature/code coverage [`#46`](https://github.com/georgejecook/rooibos/pull/46) +- fix #45 [`#45`](https://github.com/georgejecook/rooibos/issues/45) +- Revert "remove files that should not be checked in" [`9c2ece6`](https://github.com/georgejecook/rooibos/commit/9c2ece66a88976cee6e4abbd908f6755083cad89) +- remove files that should not be checked in [`3e4ecdb`](https://github.com/georgejecook/rooibos/commit/3e4ecdb7127c487a949b268dedb1a0bf7b53c431) +- remove folder which should not be added [`ba257a5`](https://github.com/georgejecook/rooibos/commit/ba257a588a369592e360df58b8a4dbb1bf399c16) - - loads runtime config from a rooibosC generated function which - - enables fail fast mode - - enables show only failures mode. +#### [2.3.0](https://github.com/georgejecook/rooibos/compare/2.2.0...2.3.0) -### Changed +> 27 April 2019 -### Deprecated +- doc update [`e9d7a40`](https://github.com/georgejecook/rooibos/commit/e9d7a40aaf9ab21d9eef42de77100ccd60774ea2) +- 2.3.0 - adds ms time for each test in the test output [`f960e52`](https://github.com/georgejecook/rooibos/commit/f960e521b39d07543d987dd7e247a4b6e45638a6) -### Removed +#### [2.2.0](https://github.com/georgejecook/rooibos/compare/2.1.4...2.2.0) - - testConfig.json file - we now use rooibosC flags for everything +> 26 April 2019 -### Fixed +- 2.2.0 - adds ability to pass node scope into the test runner, for non-node tests so node-scoped functions/vars can be accessed [`67527eb`](https://github.com/georgejecook/rooibos/commit/67527eb009feeff109979146c81d177ea7ce8b14) - - crash when any function calls asString on an aa that has mocked functions +#### [2.1.4](https://github.com/georgejecook/rooibos/compare/2.1.3...2.1.4) -## 3.0.2-beta +> 26 April 2019 -### Added +- 2.1.4 adds paramter directive to allow creation of nodes [`189b1be`](https://github.com/georgejecook/rooibos/commit/189b1be7425455b6d55afe09e81dd267102f0f12) +- minor doc update [`b22363d`](https://github.com/georgejecook/rooibos/commit/b22363d93e08eb1aa4e951c835138543650340c7) - - adds path to code coverage +#### [2.1.3](https://github.com/georgejecook/rooibos/compare/2.1.2...2.1.3) -### Changed +> 25 April 2019 -### Deprecated +- Feature/update to use latest rooibos c [`#41`](https://github.com/georgejecook/rooibos/pull/41) +- improved docs for updated rooibos preprocessor [`fd48ffe`](https://github.com/georgejecook/rooibos/commit/fd48ffee19c67c0519157e994d88b0e891959217) +- fix typo [`0fc3fc0`](https://github.com/georgejecook/rooibos/commit/0fc3fc0265bd041bcba96bd3fea6aedb75f7fe9b) +- update changelog [`1e9f8f4`](https://github.com/georgejecook/rooibos/commit/1e9f8f4d03a24fcb40c26b7ad75928065e20fb90) -### Removed +#### [2.1.2](https://github.com/georgejecook/rooibos/compare/2.1.1...2.1.2) -### Fixed +> 21 March 2019 -## 3.0.1-beta +- Bugfix/overloaded expects collide on same method name on different objects [`#39`](https://github.com/georgejecook/rooibos/pull/39) +- formats base test suite, and addresses issue of overriding mocks colliding on method name across different objects [`297fcfa`](https://github.com/georgejecook/rooibos/commit/297fcfa6ebb586be784fa045e14cee8d9d9cdfc5) +- doc update [`01e4df0`](https://github.com/georgejecook/rooibos/commit/01e4df04d154d7eec7d62ad474be61f7550066fa) +- adds additinoaly testing to ensure that there were no regressions on non-overloaded expects mixed with overloaded ones [`9d0015c`](https://github.com/georgejecook/rooibos/commit/9d0015c85facf0381341b0c75329bc9ac519b92a) -### Added +#### [2.1.1](https://github.com/georgejecook/rooibos/compare/2.1.0...2.1.1) - - More documentation for code coverage +> 21 March 2019 -### Changed +- Bugfix/minor issues [`#35`](https://github.com/georgejecook/rooibos/pull/35) +- adds dist to repo to make life easier [`c5c364b`](https://github.com/georgejecook/rooibos/commit/c5c364bc0d2ecd18d499509c8fb7bdbacd973a48) +- fix incorrect docs on stub method [`18581b8`](https://github.com/georgejecook/rooibos/commit/18581b8f99f92893ccce4184d5d242e11f3f44e0) +- doc updates [`3b4e06e`](https://github.com/georgejecook/rooibos/commit/3b4e06e8e8016f4fee5dd0e283ba8f4afd660f42) -### Deprecated +#### [2.1.0](https://github.com/georgejecook/rooibos/compare/2.0.0...2.1.0) -### Removed +> 21 March 2019 -### Fixed - - crash on metaTestcase.time +- Feature/multi expect [`#34`](https://github.com/georgejecook/rooibos/pull/34) +- Bugfix/documentation samples restructuring [`#32`](https://github.com/georgejecook/rooibos/pull/32) +- Add multi overloads for expectOnce [`fac8adc`](https://github.com/georgejecook/rooibos/commit/fac8adc6831e992751d58509baa0269181d0d9d4) +- Bounce to 2.1.0 [`ee85712`](https://github.com/georgejecook/rooibos/commit/ee85712ba3b9534d1b1c12f35021fde1aa3cffac) +- updates travis ci and readme [`e849134`](https://github.com/georgejecook/rooibos/commit/e849134ddc7b492a1ff7f011edfc1a064adc518c) -## 3.0.0-beta +### [2.0.0](https://github.com/georgejecook/rooibos/compare/0.4.1...2.0.0) -### Added +> 18 February 2019 - - Code coverage support! +#### [0.4.1](https://github.com/georgejecook/rooibos/compare/v0.2...0.4.1) -### Changed +> 9 February 2021 - - there are breaking changes in rooibos-preprocessor which, are required for code coverage. I'm keeping the major versions of rooibos and rooibos-preprocessor in sync, due to documentation, and everyone's sanity +- feat(framework-tests): Improve framework tests by making it a bsc compiled app, so that it servers of an example of how to use rooibos with bsc [`#114`](https://github.com/georgejecook/rooibos/pull/114) +- Chore/move to new bs compiler [`#106`](https://github.com/georgejecook/rooibos/pull/106) +- Feature/option to remove test times [`#82`](https://github.com/georgejecook/rooibos/pull/82) +- add option to not print test times [`#80`](https://github.com/georgejecook/rooibos/pull/80) +- feat: Increase mocks limit to 25 - it is now possible to create up to 25 mocks for a given test suite. [`#73`](https://github.com/georgejecook/rooibos/pull/73) +- fixes compatability issues with rooibos cli [`#68`](https://github.com/georgejecook/rooibos/pull/68) +- Feature/check version [`#66`](https://github.com/georgejecook/rooibos/pull/66) +- adds legacy support [`#61`](https://github.com/georgejecook/rooibos/pull/61) +- Feature/move json config [`#54`](https://github.com/georgejecook/rooibos/pull/54) +- Feature/code coverage [`#46`](https://github.com/georgejecook/rooibos/pull/46) +- Feature/update to use latest rooibos c [`#41`](https://github.com/georgejecook/rooibos/pull/41) +- Bugfix/overloaded expects collide on same method name on different objects [`#39`](https://github.com/georgejecook/rooibos/pull/39) +- Bugfix/minor issues [`#35`](https://github.com/georgejecook/rooibos/pull/35) +- Feature/multi expect [`#34`](https://github.com/georgejecook/rooibos/pull/34) +- Bugfix/documentation samples restructuring [`#32`](https://github.com/georgejecook/rooibos/pull/32) +- Rooibos 2.0.0 [`#26`](https://github.com/georgejecook/rooibos/pull/26) +- fix #45 [`#45`](https://github.com/georgejecook/rooibos/issues/45) +- doc update [`2a562ce`](https://github.com/georgejecook/rooibos/commit/2a562cea0e965b54f492c5dff09d10554e88a745) +- removes rooibosPreprocessor - it now is in it's own repo [`1477b1e`](https://github.com/georgejecook/rooibos/commit/1477b1e3ee9ae8ec3a9ec9de9167a51308b945b0) +- bunch of fixes for solo test and solo param filtering, introduces more stub test data to work with (mainly just looking at output right now - needs more asserts) and also better handling of params (deals with bright scripts loose json parser and invalid type, by having direct control of the suite, group and test via asText, as opposed to simply doing asJson and stringily) [`26e1f09`](https://github.com/georgejecook/rooibos/commit/26e1f092b2c4c6050fe3d329af424597b643e35c) -### Deprecated +#### v0.2 -### Removed +> 1 October 2018 -### Fixed - - #45 - crash when checking an expect param, and one of the params is a mock/stub - - #40 - can now use / in the params - much better parsing, too - -## 2.3.0 - -### Added - - - prints ms duration of each test in the output - -### Changed - -### Deprecated - -### Removed - -### Fixed - -## 2.2.0 - -### Added - - - sets the node property on non-node test suites. This allows you to access the global namespace, in case you are testing mixin methods, or other non-scoped code (i.e. the equivalent of accessing `method` as opposed to `m.method` or `myObject.method`) - -### Changed - -### Deprecated - -### Removed - -### Fixed - -## 2.1.4 - -### Added - - - adds new Parameter arg directive #RBSNode, to allow creation of nodes in the parameterized args - -### Changed - -### Deprecated - -### Removed - -### Fixed - -## 2.1.3 - -### Added - -### Changed - - - improves documentation, explaining how to use rooibos-preprocessor from gulp/js toolchains - -### Deprecated - -### Removed - -### Fixed - - -## 2.1.2 - -### Added - -### Changed - -### Deprecated - -### Removed - -### Fixed - - - collision on overloaded expect calls that on same method name on different objects - - https://github.com/georgejecook/rooibos/issues/36 - -## 2.1.1 - -### Added - -### Changed - -### Deprecated - -### Removed - -### Fixed - - - removes debug logging for fake calls - - https://github.com/georgejecook/rooibos/issues/25 - - https://github.com/georgejecook/rooibos/issues/30 - - https://github.com/georgejecook/rooibos/issues/29 - -## 2.1.0 - -### Added - - Multiple overloads for expectOnce, allowing for easy definition of multi params and return values from the same method invocation - -### Changed - -### Deprecated - -### Removed - -### Fixed - - - Potential crash when passing wrong type of arg value into a fake - -## 2.0.0 - -### Added - - - Leverage rooibosC preprocessor - - Better examples - - Faster parsing - -### Changed - - - Now requires rooibosC to create the test metadata structures - -### Deprecated - -### Removed - - - Legacy framework support - -### Fixed - - - various runtime error scenarios - -## 0.2.0 Initial feedback release - - Compatability with Roku unit test framework - - Fix issues submitted by initial users - - Add `'@OnlyParams` tag - - Add `AssertArrayContainsOnlyValuesOfType` assertion - - Documentation tweaks - - Improvements to various assertions - - Adds more unit testing of assertions - - Improves test report to show ignored tests - - Annotations are more flexible, allowing spaces/blank lines and comments between `'@Test`, `'@Only`, `'@Ignore` and function definitions - - -## 0.1.0 Initial release - - Core framework - - Documentation - - API documentation - - Build scripts +- fixes #5 checking for test naming collisions needs improvements with Params tests - can lead to vague error messages for params [`#5`](https://github.com/georgejecook/rooibos/issues/5) +- fixes #13 aftereach not running [`#13`](https://github.com/georgejecook/rooibos/issues/13) +- fixes #15 [`#15`](https://github.com/georgejecook/rooibos/issues/15) +- fixes #8 Accept whitespace (carriage return) between annotations and test functions [`#8`](https://github.com/georgejecook/rooibos/issues/8) +- - fixes #7 - all annotations are now case insensitive [`#7`](https://github.com/georgejecook/rooibos/issues/7) +- fixes #9 Typo [`#9`](https://github.com/georgejecook/rooibos/issues/9) +- -remove unused api docs folder [`6af014d`](https://github.com/georgejecook/rooibos/commit/6af014d8d9352158739d36232e874ca26100b04d) +- - api docs in docs folder now [`66f50b9`](https://github.com/georgejecook/rooibos/commit/66f50b9e8cf0c7804ae3befe09c0880c8bf9c1da) +- Initial commit [`39969ee`](https://github.com/georgejecook/rooibos/commit/39969ee6760a610bf35b150b5f5b2eacb6be84c0) diff --git a/README.md b/README.md index b6a0508f..c353d578 100644 --- a/README.md +++ b/README.md @@ -2,17 +2,16 @@ Rooibos test framework

-Simple, mocha-inspired, flexible, fun Brightscript test framework for ROKU apps +Simple, mocha-and junit inspired, flexible, fun Brightscript test framework for ROKU apps

Mocha test framework

[![Build Status](https://travis-ci.org/georgejecook/rooibos.svg?branch=master)](https://travis-ci.org/georgejecook/rooibos) -[![GitHub](https://img.shields.io/github/release/georgejecook/rooibos.svg?style=flat-square)](https://github.com/georgejecook/rooibos/releases) +[![GitHub](https://img.shields.io/github/release/georgejecook/rooibos.svg?style=flat-square)](https://github.com/georgejecook/rooibos/releases) ## Links - - **[Youtube training videos](https://www.youtube.com/playlist?list=PLJRLV4QDx83vsYMD9bIs-cjoDXmNmO8Jv)** - **[Documentation](docs/index.md)** - **[API Documentaiton](https://georgejecook.github.io/rooibos)** - **[CHANGELOG](CHANGELOG.md)** @@ -37,25 +36,13 @@ Also thanks to the guys who made and maintain [mochaJs](https://mochajs.org/), o ## FAQ ### Is Rooibos ready for production use? -Rooibos is the test framework used by several of my clients, running CI with over 3000 tests between them. It started life as rewrite of the official roku unit testing framework, which has been in circulation for several years. +Yes, it's been used in production by quite a few folks, I'll provide a list in due-course; but there are 1000's of tests in production in some very respectable companies. ### Is Rooibos actively maintained? -I am actively invovled in Rooibos's development, and add more features and fixes on a weekly basis. You can expect rapid responses to issues. +I love rooibos, and always keep it up to date. I use it all the time. -### Why did you not just merge back your changes to roku's unit testing framework +### Why 4.0.0? -1. It does rewrite quite a lot of the original unit test framework code, so I doubt that roku would've merged it all back any time soon -2. It's conceptually entirely different: e.g. using annotations instead of naming conventions and boiler-plate code, completely different test reporting output, assertions and test cases maintain their own state, runs in a scenegraph scene, to name but a few -3. It has many more features than the original framework, not limited to : node specific assertions, exact assertion line failure reporting, better error messaging, easier setup, groupings, only and ignore for tests, mocks and stubs, etc, etc -4. Being completely frank, I enjoy roku work and want to do more of it, so it's useful to me to own this project, rather than lose control and wait on other's to merge my changes. On that note, email me at george[AT]tantawowa.com, or pm me (georgejecook) on the roku slack group to discuss any roku development requirements -5. I poured a _lot_ of work into the project (> 100 hours and counting), and expect to continue to do so. If I own the project, then I can do what I want, when I want. That goes for you guys as well, so get in touch with feature requests and PR's :) - -### Is Rooibos itself unit tested? - -At this point, it's WIP. I keep adding tests as bugs come up, and will continue to improve the test coverage. - -### Why 2.0.0? - -The latest version of Rooibos introduces a preprocessor which is a requirement for running all tests. I thought that was a significant enough departure to warrant a whole version bump. \ No newline at end of file +Rooibos now uses the excellent bsc compiler plugin mechanism to seamlessly integrate with the compiler and the vscode IDE extension. This is a breaking change - projects will require updates to work. \ No newline at end of file diff --git a/ROADMAP.md b/ROADMAP.md deleted file mode 100644 index 8f3dd8f3..00000000 --- a/ROADMAP.md +++ /dev/null @@ -1,26 +0,0 @@ -# Rooibos Roadmap - -## ShortTerm - -### Unit tests for the framework and general framework improvements - -Unit tests will be written which test the following: - - - Assertions - - Ignore - - Only - - Mocks - - Stubs - - Expect - -# MidTerm - -### Add additional reporting options - -Will add the ability to specify a unit test reporting class, to facilitate custom unit test reporting - -# LongTerm - -### Integrate with vscode ide - -Support test execution from and output to Visual Studio Code ide, as per mocha test runner extension diff --git a/VERSION b/VERSION deleted file mode 100644 index 276cbf9e..00000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -2.3.0 diff --git a/app.mk b/app.mk deleted file mode 100755 index 9f24a294..00000000 --- a/app.mk +++ /dev/null @@ -1,237 +0,0 @@ -######################################################################### -# common include file for application Makefiles -# -# Makefile Common Usage: -# > make -# > make install -# > make remove -# -# Makefile Less Common Usage: -# > make art-opt -# > make pkg -# > make install_native -# > make remove_native -# > make tr -# -# By default, ZIP_EXCLUDE will exclude -x \*.pkg -x storeassets\* -x keys\* -x .\* -# If you define ZIP_EXCLUDE in your Makefile, it will override the default setting. -# -# To exclude different files from being added to the zipfile during packaging -# include a line like this:ZIP_EXCLUDE= -x keys\* -# that will exclude any file who's name begins with 'keys' -# to exclude using more than one pattern use additional '-x ' arguments -# ZIP_EXCLUDE= -x \*.pkg -x storeassets\* -# -# Important Notes: -# To use the "install" and "remove" targets to install your -# application directly from the shell, you must do the following: -# -# 1) Make sure that you have the curl command line executable in your path -# 2) Set the variable ROKU_DEV_TARGET in your environment to the IP -# address of your Roku box. (e.g. export ROKU_DEV_TARGET=192.168.1.1. -# Set in your this variable in your shell startup (e.g. .bashrc) -########################################################################## -DISTREL = ../dist -COMMONREL ?= ../common -SOURCEREL = . - -ZIPREL = $(DISTREL)/apps -PKGREL = $(DISTREL)/packages - -APPSOURCEDIR = source -IMPORTFILES = $(foreach f,$(IMPORTS),$(COMMONREL)/$f.brs) -IMPORTCLEANUP = $(foreach f,$(IMPORTS),$(APPSOURCEDIR)/$f.brs) - -NATIVEDEVREL = $(DISTREL)/rootfs/Linux86_dev.OBJ/root/nvram/incoming -NATIVEDEVPKG = $(NATIVEDEVREL)/dev.zip -NATIVETICKLER = $(DISTREL)/application/Linux86_dev.OBJ/root/bin/plethora tickle-plugin-installer - -APPGENKEY = ./GENKEY -APPDEVID = $(shell grep DevID $(APPGENKEY) | sed "s/DevID: //") -GITCOMMIT = $(shell git rev-parse --short HEAD) -BUILDDATE = $(shell date -u | awk '{ print $$2,$$3,$$6,$$4 }') - -ifdef DEVPASSWORD - USERPASS = rokudev:$(DEVPASSWORD) -else - USERPASS = rokudev -endif - -ifndef ZIP_EXCLUDE - ZIP_EXCLUDE= -x \*.pkg -x storeassets\* -x keys\* -x \*/.\* -endif - -HTTPSTATUS = $(shell curl --silent --write-out "\n%{http_code}\n" $(ROKU_DEV_TARGET)) - -ifeq "$(HTTPSTATUS)" " 401" - CURLCMD = curl -S --connect-timeout 2 --max-time 30 --retry 5 -else - CURLCMD = curl -S --connect-timeout 2 --max-time 30 --retry 5 --user $(USERPASS) --digest -endif - -.PHONY: all $(APPNAME) verify-keys home - -home: - @echo "Forcing roku to main menu screen $(ROKU_DEV_TARGET)..." - curl -s -S -d '' http://$(ROKU_DEV_TARGET):8060/keypress/home - sleep 2 - -$(APPNAME): manifest - @echo "*** Creating $(APPNAME).zip ***" - - @echo " >> removing old application zip $(ZIPREL)/$(APPNAME).zip" - @if [ -e "$(ZIPREL)/$(APPNAME).zip" ]; \ - then \ - rm $(ZIPREL)/$(APPNAME).zip; \ - fi - - @echo " >> creating destination directory $(ZIPREL)" - @if [ ! -d $(ZIPREL) ]; \ - then \ - mkdir -p $(ZIPREL); \ - fi - - @echo " >> setting directory permissions for $(ZIPREL)" - @if [ ! -w $(ZIPREL) ]; \ - then \ - chmod 755 $(ZIPREL); \ - fi - - @echo " >> copying imports" - @if [ "$(IMPORTFILES)" ]; \ - then \ - mkdir $(APPSOURCEDIR)/common; \ - cp -f -p -v $(IMPORTFILES) $(APPSOURCEDIR)/common/; \ - fi \ - - @echo " >> generating build info file" - @if [ -e "$(APPSOURCEDIR)/buildinfo.brs" ]; \ - then \ - rm $(APPSOURCEDIR)/buildinfo.brs; \ - fi - echo "Function BuildDate()" >> $(APPSOURCEDIR)/buildinfo.brs - echo " return \"${BUILDDATE}\"" >> $(APPSOURCEDIR)/buildinfo.brs - echo "End Function" >> $(APPSOURCEDIR)/buildinfo.brs - echo "Function BuildCommit()" >> $(APPSOURCEDIR)/buildinfo.brs - echo " return \"${GITCOMMIT}\"" >> $(APPSOURCEDIR)/buildinfo.brs - echo "End Function" >> $(APPSOURCEDIR)/buildinfo.brs - -# zip .png files without compression -# do not zip up Makefiles, or any files ending with '~' - @echo " >> creating application zip $(ZIPREL)/$(APPNAME).zip" - @if [ -d $(SOURCEREL) ]; \ - then \ - (zip -0 -r "$(ZIPREL)/$(APPNAME).zip" . -i \*.png $(ZIP_EXCLUDE)); \ - (zip -9 -r "$(ZIPREL)/$(APPNAME).zip" . -x \*~ -x \*.png -x Makefile $(ZIP_EXCLUDE)); \ - else \ - echo "Source for $(APPNAME) not found at $(SOURCEREL)"; \ - fi - - @if [ "$(IMPORTCLEANUP)" ]; \ - then \ - echo " >> deleting imports";\ - rm -r -f $(APPSOURCEDIR)/common; \ - fi \ - - @echo "*** packaging $(APPNAME) complete ***" - -install: $(APPNAME) home - @echo "Installing $(APPNAME) to host $(ROKU_DEV_TARGET)" - @$(CURLCMD) --user $(USERPASS) --digest -F "mysubmit=Install" -F "archive=@$(ZIPREL)/$(APPNAME).zip" -F "passwd=" http://$(ROKU_DEV_TARGET)/plugin_install | grep "//" | sed "s[[[" - -# Make certain that the Roku is packaging with the correct key/DevID -verify-keys: $(APPGENKEY) - @echo "Verifying developer key is $(APPDEVID)" - @if [ "$(HTTPSTATUS)" == " 401" ]; \ - then \ - ROKU_DEV_ID=`$(CURLCMD) --user $(USERPASS) --digest http://$(ROKU_DEV_TARGET)/plugin_package | grep $(APPDEVID)`; \ - if [ "$$ROKU_DEV_IDx" == "x" ]; then echo "ROKU_DEV_ID doesn't match $(APPDEVID)"; exit 1; fi \ - else \ - ROKU_DEV_ID=`$(CURLCMD) http://$(ROKU_DEV_TARGET)/plugin_package | grep $(APPDEVID)`; \ - if [ "$$ROKU_DEV_IDx" == "x" ]; then echo "ROKU_DEV_ID doesn't match $(APPDEVID)"; exit 1; fi \ - fi - -pkg: install verify-keys - @echo "*** Creating Package ***" - - @echo " >> creating destination directory $(PKGREL)" - @if [ ! -d $(PKGREL) ]; \ - then \ - mkdir -p $(PKGREL); \ - fi - - @echo " >> setting directory permissions for $(PKGREL)" - @if [ ! -w $(PKGREL) ]; \ - then \ - chmod 755 $(PKGREL); \ - fi - - @echo "Packaging $(APPSRC)/$(APPNAME) on host $(ROKU_DEV_TARGET)" - @if [ "$(HTTPSTATUS)" == " 401" ]; \ - then \ - read -p "Password: " REPLY ; echo $$REPLY | xargs -I{} $(CURLCMD) --user $(USERPASS) --digest -Fmysubmit=Package -Fapp_name=$(APPNAME)/$(VERSION) -Fpasswd={} -Fpkg_time=`expr \`date +%s\` \* 1000` "http://$(ROKU_DEV_TARGET)/plugin_package" | grep '^//" | sed "s[[[" ; \ - else \ - curl -s -S -F "mysubmit=Delete" -F "archive=" -F "passwd=" http://$(ROKU_DEV_TARGET)/plugin_install | grep "//" | sed "s[[[" ; \ - fi - -install_native: $(APPNAME) - @echo "Installing $(APPNAME) to native." - @mkdir -p $(NATIVEDEVREL) - @cp $(ZIPREL)/$(APPNAME).zip $(NATIVEDEVPKG) - @$(NATIVETICKLER) - -remove_native: - @echo "Removing $(APPNAME) from native." - @rm $(NATIVEDEVPKG) - @$(NATIVETICKLER) - -APPS_JPG_ART=`\find . -name "*.jpg"` - -art-jpg-opt: - p4 edit $(APPS_JPG_ART) - for i in $(APPS_JPG_ART); \ - do \ - TMPJ=`mktemp` || return 1; \ - echo "optimizing $$i"; \ - (jpegtran -copy none -optimize -outfile $$TMPJ $$i && mv -f $$TMPJ $$i &); \ - done - wait - p4 revert -a $(APPS_JPG_ART) - -APPS_PNG_ART=`\find . -name "*.png"` - -art-png-opt: - p4 edit $(APPS_PNG_ART) - for i in $(APPS_PNG_ART); \ - do \ - (optipng -o7 $$i &); \ - done - wait - p4 revert -a $(APPS_PNG_ART) - -art-opt: art-png-opt art-jpg-opt - -tr: - p4 edit locale/.../translations.xml - ../../rdk/rokudev/utilities/linux/bin/maketr - rm locale/en_US/translations.xml - p4 revert -a locale/.../translations.xml - -screenshot: - SCREENSHOT_TIME=`date "+%s"`; \ - curl -m 1 -o screenshot.jpg --user $(USERPASS) --digest "http://$(ROKU_DEV_TARGET)/pkgs/dev.jpg?time=$$SCREENSHOT_TIME" -H 'Accept: image/png,image/*;q=0.8,*/*;q=0.5' -H 'Accept-Language: en-US,en;q=0.5' -H 'Accept-Encoding: gzip, deflate' - - - - diff --git a/bsc-plugin/.eslintrc.js b/bsc-plugin/.eslintrc.js new file mode 100644 index 00000000..7b2ff567 --- /dev/null +++ b/bsc-plugin/.eslintrc.js @@ -0,0 +1,205 @@ +module.exports = { + root: true, + parser: '@typescript-eslint/parser', + env: { + node: true, + mocha: true, + es6: true + }, + parserOptions: { + project: ['./tsconfig.json'], + createDefaultProgram: true + }, + plugins: [ + '@typescript-eslint', + 'no-only-tests', + 'github' + ], + extends: [ + 'eslint:all', + 'plugin:@typescript-eslint/all' + ], + rules: { + '@typescript-eslint/object-curly-spacing': ['off'], + '@typescript-eslint/array-type': 'off', + '@typescript-eslint/consistent-type-assertions': 'off', + '@typescript-eslint/explicit-function-return-type': 'off', + '@typescript-eslint/explicit-member-accessibility': 'off', + '@typescript-eslint/explicit-module-boundary-types': 'off', + '@typescript-eslint/init-declarations': 'off', + '@typescript-eslint/lines-between-class-members': 'off', + '@typescript-eslint/member-ordering': 'off', + '@typescript-eslint/method-signature-style': 'off', + '@typescript-eslint/naming-convention': 'off', + '@typescript-eslint/no-base-to-string': 'off', + '@typescript-eslint/no-dynamic-delete': 'off', + '@typescript-eslint/no-empty-function': 'off', + '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/no-extra-parens': 'off', + '@typescript-eslint/no-floating-promises': 'error', + '@typescript-eslint/no-implicit-any-catch': 'off', + '@typescript-eslint/no-invalid-this': 'off', + '@typescript-eslint/no-magic-numbers': 'off', + '@typescript-eslint/no-parameter-properties': 'off', + '@typescript-eslint/no-shadow': 'off', + '@typescript-eslint/no-this-alias': 'off', + //possibly disable this once we have converted all throw statements to actual errors + '@typescript-eslint/no-throw-literal': 'off', + '@typescript-eslint/no-invalid-void': 'off', + '@typescript-eslint/no-invalid-void-type': 'off', + '@typescript-eslint/no-type-alias': 'off', + '@typescript-eslint/no-unnecessary-boolean-literal-compare': 'off', + '@typescript-eslint/no-unnecessary-condition': 'off', + '@typescript-eslint/no-unsafe-assignment': 'off', + '@typescript-eslint/no-unsafe-call': 'off', + '@typescript-eslint/no-unsafe-member-access': 'off', + '@typescript-eslint/no-unsafe-return': 'off', + '@typescript-eslint/no-unused-vars': 'off', + '@typescript-eslint/no-unused-vars-experimental': 'off', + '@typescript-eslint/no-use-before-define': 'off', + '@typescript-eslint/prefer-for-of': 'off', + '@typescript-eslint/prefer-readonly': 'off', + '@typescript-eslint/prefer-readonly-parameter-types': 'off', + '@typescript-eslint/promise-function-async': 'off', + '@typescript-eslint/quotes': [ + 'error', + 'single', + { + 'allowTemplateLiterals': true + } + ], + '@typescript-eslint/require-array-sort-compare': 'off', + '@typescript-eslint/restrict-plus-operands': 'off', + '@typescript-eslint/restrict-template-expressions': 'off', + '@typescript-eslint/space-before-function-paren': 'off', + '@typescript-eslint/strict-boolean-expressions': 'off', + '@typescript-eslint/typedef': 'off', + '@typescript-eslint/unbound-method': 'off', + '@typescript-eslint/unified-signatures': 'off', + 'array-bracket-newline': 'off', + 'array-element-newline': 'off', + 'array-type': 'off', + 'arrow-body-style': 'off', + 'arrow-parens': 'off', + 'callback-return': 'off', + 'capitalized-comments': 'off', + 'class-methods-use-this': 'off', + 'complexity': 'off', + 'consistent-return': 'off', + 'consistent-this': 'off', + 'curly': 'error', + 'default-case': 'off', + 'dot-location': 'off', + 'dot-notation': 'off', + 'func-style': 'off', + 'function-call-argument-newline': 'off', + 'function-paren-newline': 'off', + 'getter-return': 'off', + 'github/array-foreach': 'error', + 'guard-for-in': 'off', + 'id-length': 'off', + 'indent': 'off', + 'init-declarations': 'off', + 'line-comment-position': 'off', + 'linebreak-style': 'off', + 'lines-around-comment': 'off', + 'lines-between-class-members': 'off', + 'max-classes-per-file': 'off', + 'max-depth': 'off', + 'max-len': 'off', + 'max-lines': 'off', + 'max-lines-per-function': 'off', + 'max-params': 'off', + 'max-statements': 'off', + 'no-only-tests/no-only-tests': 'error', + 'multiline-comment-style': 'off', + 'multiline-ternary': 'off', + 'new-cap': 'off', + 'newline-per-chained-call': 'off', + 'no-await-in-loop': 'off', + 'no-case-declarations': 'off', + 'no-constant-condition': 'off', + 'no-console': 'off', + 'no-continue': 'off', + 'no-else-return': 'off', + 'no-empty': 'off', + 'no-implicit-coercion': 'off', + 'no-inline-comments': 'off', + 'no-invalid-this': 'off', + 'no-labels': 'off', + 'no-lonely-if': 'off', + 'no-negated-condition': 'off', + 'no-param-reassign': 'off', + 'no-plusplus': 'off', + 'no-process-exit': 'off', + 'no-prototype-builtins': 'off', + 'no-shadow': 'off', + 'no-sync': 'off', + 'no-ternary': 'off', + 'no-undefined': 'off', + 'no-underscore-dangle': 'off', + 'no-unneeded-ternary': 'off', + 'no-useless-escape': 'off', + 'no-warning-comments': 'off', + 'object-curly-spacing': [ + 'error', + 'always' + ], + 'object-property-newline': 'off', + 'object-shorthand': [ + 'error', + 'never' + ], + 'one-var': [ + 'error', + 'never' + ], + 'padded-blocks': 'off', + 'prefer-const': 'off', + 'prefer-destructuring': 'off', + 'prefer-named-capture-group': 'off', + 'prefer-template': 'off', + 'quote-props': 'off', + 'radix': 'off', + 'require-atomic-updates': 'off', + 'require-unicode-regexp': 'off', + 'sort-imports': 'off', + 'sort-keys': 'off', + 'spaced-comment': 'off', + 'vars-on-top': 'off', + 'wrap-regex': 'off' + }, + //disable some rules for certain files + overrides: [{ + //these files are getting deleted soon, so ingore the eslint warnings for now + files: ['src/brsTypes/**/*.ts'], + rules: { + '@typescript-eslint/no-invalid-this': 'off', + '@typescript-eslint/method-signature-style': 'off', + '@typescript-eslint/no-unsafe-assignment': 'off', + '@typescript-eslint/prefer-enum-initializers': 'off' + } + }, + { + files: ['*.spec.ts'], + rules: { + '@typescript-eslint/no-unsafe-assignment': 'off', + '@typescript-eslint/no-unsafe-call': 'off', + '@typescript-eslint/no-unsafe-member-access': 'off', + '@typescript-eslint/no-unsafe-return': 'off', + '@typescript-eslint/no-unused-expressions': 'off', + '@typescript-eslint/no-unused-vars': 'off', + '@typescript-eslint/no-unused-vars-experimental': 'off', + '@typescript-eslint/dot-notation': 'off', + 'github/array-foreach': 'off', + 'new-cap': 'off', + 'no-shadow': 'off' + } + }, { + files: ['benchmarks/**/*'], + rules: { + '@typescript-eslint/no-require-imports': 'off', + '@typescript-eslint/no-var-requires': 'off' + } + }] +}; diff --git a/bsc-plugin/.github/workflows/build.yml b/bsc-plugin/.github/workflows/build.yml new file mode 100644 index 00000000..e21d2505 --- /dev/null +++ b/bsc-plugin/.github/workflows/build.yml @@ -0,0 +1,61 @@ +name: build +on: [push, pull_request] + +jobs: + ci: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-18.04, macos-10.15, windows-2019] + steps: + - uses: actions/checkout@master + - uses: actions/setup-node@master + with: + node-version: "10.19.0" + # - run: npm run build + # - run: cd bsc-plugin && npm i + # - run: cd bsc-plugin && npm ci + # - run: cd bsc-plugin && npm run build + # - run: cd bsc-plugin && npm run lint + # - run: cd bsc-plugin && npm run test + # - run: cd bsc-plugin && npm run publish-coverage + npm-release: + #only run this task if a tag starting with 'v' was used to trigger this (i.e. a tagged release) + if: startsWith(github.ref, 'refs/tags/v') + needs: ci + runs-on: ubuntu-18.04 + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + steps: + - uses: actions/checkout@master + - uses: actions/setup-node@master + with: + node-version: "10.19.0" + - run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ./.npmrc + - run: npm ci + - run: npm run build + #create npm package + - run: npm pack + + #create GitHub release + - name: Create GitHub Release + id: create_release + uses: actions/create-release@latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: ${{ github.ref }} + draft: false + prerelease: false #contains(github.ref, '-beta.') == true + + #upload package to GitHub release + - name: Upload GitHub Release Assets + uses: alexellis/upload-assets@0.2.3 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + asset_paths: '["./*.tgz"]' + + #upload to npm + - run: npm publish diff --git a/bsc-plugin/.gitignore b/bsc-plugin/.gitignore new file mode 100644 index 00000000..3082c3a5 --- /dev/null +++ b/bsc-plugin/.gitignore @@ -0,0 +1,64 @@ +tmp + +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env + +# next.js build output +.next +package-lock.json diff --git a/bsc-plugin/.travis.yml b/bsc-plugin/.travis.yml new file mode 100644 index 00000000..a44b898e --- /dev/null +++ b/bsc-plugin/.travis.yml @@ -0,0 +1,7 @@ +language : node_js +node_js : + - stable +install: + - npm install +script: + - npm test \ No newline at end of file diff --git a/bsc-plugin/.vscode/extensions.json b/bsc-plugin/.vscode/extensions.json new file mode 100644 index 00000000..897af65d --- /dev/null +++ b/bsc-plugin/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "dbaeumer.vscode-eslint" + ] +} \ No newline at end of file diff --git a/bsc-plugin/.vscode/launch.json b/bsc-plugin/.vscode/launch.json new file mode 100644 index 00000000..3f4d2d25 --- /dev/null +++ b/bsc-plugin/.vscode/launch.json @@ -0,0 +1,25 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Run tests (current file)", + "type": "node", + "request": "launch", + "smartStep": false, + "program": "${workspaceFolder}/node_modules/mocha/bin/_mocha", + "sourceMaps": true, + "args": [ + "${relativeFile}", + "--timeout", + "0" + ], + "skipFiles": [ + "${workspaceFolder}/node_modules/**/*.js", + "/**/*.js" + ], + "cwd": "${workspaceRoot}", + "protocol": "inspector", + "internalConsoleOptions": "openOnSessionStart" + } + ] +} \ No newline at end of file diff --git a/bsc-plugin/.vscode/settings.json b/bsc-plugin/.vscode/settings.json new file mode 100644 index 00000000..5ed2f0fa --- /dev/null +++ b/bsc-plugin/.vscode/settings.json @@ -0,0 +1,22 @@ +{ + "files.exclude": { + "**/.git": true, + "**/.svn": true, + "**/.hg": true, + "**/CVS": true, + "**/.DS_Store": true, + "**/node_modules": true, + "**/.nyc_output": true, + "**/coverage": true, + "**/dist": true + }, + "search.exclude": { + "**/node_modules": true, + "**/bower_components": true, + "**/dist": true + }, + "editor.tabSize": 4, + "editor.insertSpaces": true, + "typescript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions": true, + "files.trimTrailingWhitespace": true +} \ No newline at end of file diff --git a/bsc-plugin/.vscode/tasks.json b/bsc-plugin/.vscode/tasks.json new file mode 100644 index 00000000..a97e1285 --- /dev/null +++ b/bsc-plugin/.vscode/tasks.json @@ -0,0 +1,23 @@ +{ + "version": "0.2.0", + "tasks": [ + { + "type": "shell", + "label": "build-tests", + "command": "tsc -p .", + "presentation": { + "echo": true, + "reveal": "silent", + "focus": false, + "panel": "shared", + "showReuseMessage": false, + "clear": true, + }, + "options": { + "env": { + "TS_NODE_TRANSPILE_ONLY": "true" + } + } + } + ] +} \ No newline at end of file diff --git a/bsc-plugin/LICENSE b/bsc-plugin/LICENSE new file mode 100644 index 00000000..2b8b92c1 --- /dev/null +++ b/bsc-plugin/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 George Cook + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/bsc-plugin/README.md b/bsc-plugin/README.md new file mode 100644 index 00000000..80a7680c --- /dev/null +++ b/bsc-plugin/README.md @@ -0,0 +1,30 @@ +

+ Plugin for using maestro with vscode ide +

+

+VSCode ide plugin for [maestro](https://github.com/georgejecook/maestro) projects +

+ +[![Build Status](https://travis-ci.org/georgejecook/maestro-vsc-extension-plugin.svg?branch=master)](https://travis-ci.org/georgejecook/maestro-vsc-extension-plugin) +[![codecov](https://codecov.io/gh/georgejecook/maestro-vsc-extension-plugin/branch/master/graph/badge.svg)](https://codecov.io/gh/georgejecook/maestro-vsc-extension-plugin) +[![GitHub](https://img.shields.io/github/release/georgejecook/maestro-vsc-extension-plugin.svg?style=flat-square)](https://github.com/georgejecook/maestro-vsc-extension-plugin/releases) +[![NPM](https://nodei.co/npmmaestro-vsc-extension-plugin.png)](https://npmjs.org/packagemaestro-vsc-extension-plugin) + +## Links + - [maestro](https://github.com/georgejecook/maestro) + - [Issue tracker](https://github.com/georgejecook/maestro-vsc-extension-plugin/issues) + - [CHANGELOG](CHANGELOG.md) + +# About + +This repo contains the source for `maestro-vsc-extension-plugin`, which is used by the - [maestro framework](https://github.com/georgejecook/maestro). + +Use this plugin with vscode to use advanced features of maestro such as: + + - XML binding support + - Reflection + - Dynamic imports + +## Get help + +Read how to use these features and the maestro framework [here](https://github.com/georgejecook/maestro: \ No newline at end of file diff --git a/bsc-plugin/package.json b/bsc-plugin/package.json new file mode 100644 index 00000000..7876223c --- /dev/null +++ b/bsc-plugin/package.json @@ -0,0 +1,106 @@ +{ + "name": "rooibos-roku", + "version": "4.2.1", + "description": "simple, flexible, fun brightscript test framework for roku scenegraph apps - roku brighterscript plugin", + "files": [ + "dist/**/!(*.spec.*)*" + ], + "main": "dist/plugin.js", + "directories": { + "test": "test" + }, + "dependencies": { + "@types/node": "^14.14.16", + "source-map": "^0.7.3", + "stringify-object": "^3.3.0", + "vscode-languageserver": "~6.1.1", + "vscode-languageserver-protocol": "~3.15.3" + }, + "devDependencies": { + "@types/chai": "^4.1.2", + "@types/expect": "^24.3.0", + "@types/mocha": "^5.2.7", + "@types/sinon": "^9.0.4", + "@typescript-eslint/eslint-plugin": "^4.4.1", + "@typescript-eslint/parser": "^4.4.1", + "brighterscript": "^0.37.4", + "chai": "^4.2.0", + "chai-files": "^1.4.0", + "chai-subset": "^1.6.0", + "eslint": "^7.11.0", + "eslint-plugin-github": "^4.1.1", + "eslint-plugin-no-only-tests": "^2.4.0", + "fs-extra": "^9.1.0", + "minimatch": "^3.0.4", + "mocha": "^7.1.1", + "nyc": "^15.1.0", + "roku-deploy": "^3.2.4", + "sinon": "^9.0.2", + "source-map-support": "^0.5.13", + "ts-node": "^9.0.0", + "typescript": "^3.8.3", + "typescript-formatter": "^7.2.2" + }, + "scripts": { + "clean": "rm -rf ./dist && mkdir dist", + "compile": "npm run clean && tsc -p .", + "prepublishOnly": "npm run build", + "lint": "eslint \"src/**\"", + "build": "npm run compile && cp -r ../framework/src/source ./dist/lib/framework", + "test": "TS_NODE_TRANSPILE_ONLY=true mocha --full-trace --bail", + "coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov", + "publish-npm": "npm run test && npm publish", + "publish-npm:beta": "npm run test && npm publish --tag=beta", + "local": "ts-node scripts/install-local.js", + "remote": "ts-node scripts/install-npm.js" + }, + "preferGlobal": true, + "keywords": [ + "brightscript", + "scenegraph", + "roku", + "rooibos", + "britherscript" + ], + "author": "George Cook", + "license": "ISC", + "watch": { + "test": { + "extensions": "ts", + "patterns": [ + "src" + ] + } + }, + "nyc": { + "include": [ + "src/**/!(*.spec).ts" + ], + "extension": [ + ".ts" + ], + "require": [ + "ts-node/register", + "source-map-support/register" + ], + "reporter": [ + "text-summary", + "html" + ], + "sourceMap": true, + "instrument": true, + "check-coverage": true, + "lines": 5, + "statements": 5, + "functions": 5, + "branches": 5 + }, + "mocha": { + "spec": "src/**/*.spec.ts", + "fullTrace": true, + "require": [ + "source-map-support/register", + "ts-node/register" + ] + } +} diff --git a/bsc-plugin/scripts/install-local.js b/bsc-plugin/scripts/install-local.js new file mode 100644 index 00000000..96eb9600 --- /dev/null +++ b/bsc-plugin/scripts/install-local.js @@ -0,0 +1,33 @@ +/** + * Installs a local version of all the rokucommunity dependent packages into this project + */ + +import * as fsExtra from 'fs-extra'; +import * as path from 'path'; +import * as childProcess from 'child_process'; +import * as rimraf from 'rimraf'; + +//set the cwd to the root of this project +let thisProjectRootPath = path.join(__dirname, '..'); +process.chdir(thisProjectRootPath); +let packageJson = JSON.parse(fsExtra.readFileSync('package.json').toString()); + +let devPackages = { + 'brighterscript': '/home/george/hope/open-source/vsc/brighterscript' +}; + +for (let packageName in devPackages) { + console.log(`adding dev package: '${packageName}' to package.json`); + packageJson.devDependencies[packageName] = `${devPackages[packageName]}`; + rimraf.sync(path.join('node_modules', packageName)); +} + +console.log('saving package.json changes'); +fsExtra.writeFileSync('package.json', JSON.stringify(packageJson, null, 4)); +if (fsExtra.existsSync('package-lock.json')) { + fsExtra.rmSync('package-lock.json'); +} +console.log('install packages'); +childProcess.execSync('npm i', { + stdio: 'inherit' +}); diff --git a/bsc-plugin/scripts/install-npm.js b/bsc-plugin/scripts/install-npm.js new file mode 100644 index 00000000..5b867448 --- /dev/null +++ b/bsc-plugin/scripts/install-npm.js @@ -0,0 +1,21 @@ +/** + * Installs a local version of all the rokucommunity dependent packages into this project + */ + +import * as fsExtra from 'fs-extra'; +import * as path from 'path'; +import * as childProcess from 'child_process'; +import * as rimraf from 'rimraf'; + +//set the cwd to the root of this project +let thisProjectRootPath = path.join(__dirname, '..'); +process.chdir(thisProjectRootPath); + +rimraf.sync(path.join('node_modules/brighterscript')); +if (fsExtra.existsSync('package-lock.json')) { + fsExtra.rmSync('package-lock.json'); +} +console.log('install packages'); +childProcess.execSync('npm i brighterscript@latest --save-dev', { + stdio: 'inherit' +}); diff --git a/bsc-plugin/src/lib/rooibos/Annotation.ts b/bsc-plugin/src/lib/rooibos/Annotation.ts new file mode 100644 index 00000000..e2d248fa --- /dev/null +++ b/bsc-plugin/src/lib/rooibos/Annotation.ts @@ -0,0 +1,194 @@ +import type { BrsFile, Statement, AnnotationExpression } from 'brighterscript'; +import { diagnosticIllegalParams, diagnosticNoTestNameDefined, diagnosticMultipleDescribeAnnotations, diagnosticMultipleTestOnFunctionDefined } from '../utils/Diagnostics'; + +export enum AnnotationType { + None = 'none', + TestSuite = 'suite', + Describe = 'describe', + It = 'it', + Ignore = 'ignore', + Solo = 'only', + NodeTest = 'sgnode', + Setup = 'setup', + TearDown = 'teardown', + BeforeEach = 'beforeeach', + AfterEach = 'aftereach', + Params = 'params', + IgnoreParams = 'ignoreparams', + SoloParams = 'onlyparams', + Tags = 'tags', + NoCatch = 'nocatch', + NoEarlyExit = 'noearlyexit' +} + +let annotationLookup = { + suite: AnnotationType.TestSuite, + describe: AnnotationType.Describe, + it: AnnotationType.It, + ignore: AnnotationType.Ignore, + only: AnnotationType.Solo, + sgnode: AnnotationType.NodeTest, + setup: AnnotationType.Setup, + teardown: AnnotationType.TearDown, + beforeeach: AnnotationType.BeforeEach, + aftereach: AnnotationType.AfterEach, + params: AnnotationType.Params, + ignoreparams: AnnotationType.IgnoreParams, + onlyparams: AnnotationType.SoloParams, + tags: AnnotationType.Tags, + nocatch: AnnotationType.NoCatch, + noearlyexit: AnnotationType.NoEarlyExit +}; + +interface ParsedComment { + blockAnnotation?: RooibosAnnotation; + testAnnotation?: RooibosAnnotation; +} + +export class AnnotationParams { + + constructor( + public annotation: AnnotationExpression, + public text: string, + public lineNumber: number, + public params: any[], + public isIgnore = false, + public isSolo = false, + public noCatch = false, + public noearlyexit = false + ) { + + } +} +export class RooibosAnnotation { + /** + * Represents a group of comments which contain tags such as @only, @suite, @describe, @it etc + * @param statement block of comments that contain annotations to apply to the next statement + */ + constructor( + public file: BrsFile, + public annotation: AnnotationExpression, + public annotationType: AnnotationType, + public text: string, + public name: string, + public isIgnore = false, + public isSolo = false, + public params: AnnotationParams[] = [], + public nodeName?: string, + rawTags: string[] = [], + public noCatch = false, + public noEarlyExit = false + ) { + this.tags = new Set(rawTags); + } + public tags; + public hasSoloParams = false; + + public static getAnnotation(file: BrsFile, statement: Statement): ParsedComment | null { + + //split annotations in case they include an it group.. + let blockAnnotation: RooibosAnnotation; + let testAnnotation: RooibosAnnotation; + let isSolo = false; + let isIgnore = false; + let noCatch = false; + let noEarlyExit = false; + let nodeName = null; + let tags = []; + if (statement.annotations?.length) { + let describeAnnotations = statement.annotations.filter((a) => getAnnotationType(a.name) === AnnotationType.Describe); + if (describeAnnotations.length > 1) { + for (let a of describeAnnotations) { + diagnosticMultipleDescribeAnnotations(file, a); + } + } + for (let annotation of statement.annotations) { + const annotationType = getAnnotationType(annotation.name); + switch (annotationType) { + case AnnotationType.NoEarlyExit: + noEarlyExit = true; + break; + case AnnotationType.NoCatch: + noCatch = true; + break; + case AnnotationType.Solo: + isSolo = true; + break; + case AnnotationType.NodeTest: + nodeName = annotation.getArguments()[0] as string; + break; + case AnnotationType.Tags: + tags = annotation.getArguments().map((a) => a.toString()); + break; + case AnnotationType.Ignore: + isIgnore = true; + break; + case AnnotationType.BeforeEach: + case AnnotationType.AfterEach: + case AnnotationType.Setup: + case AnnotationType.TearDown: + testAnnotation = new RooibosAnnotation(file, annotation, annotationType, annotation.name, annotation.name); + break; + case AnnotationType.Describe: + case AnnotationType.TestSuite: + const groupName = annotation.getArguments()[0] as string; + blockAnnotation = new RooibosAnnotation(file, annotation, annotationType, annotation.name, groupName, isIgnore, isSolo, null, nodeName, tags, noCatch, noEarlyExit); + nodeName = null; + isSolo = false; + isIgnore = false; + break; + case AnnotationType.It: + const testName = annotation.getArguments()[0] as string; + if (!testName || testName.trim() === '') { + diagnosticNoTestNameDefined(file, annotation); + } + let newAnnotation = new RooibosAnnotation(file, annotation, annotationType, annotation.name, testName, isIgnore, isSolo, undefined, undefined, tags, noCatch); + if (testAnnotation) { + diagnosticMultipleTestOnFunctionDefined(file, newAnnotation.annotation); + } else { + testAnnotation = newAnnotation; + } + isSolo = false; + isIgnore = false; + break; + case AnnotationType.Params: + case AnnotationType.SoloParams: + case AnnotationType.IgnoreParams: + if (testAnnotation) { + testAnnotation.parseParams(file, annotation, annotationType, noCatch); + } else { + //error + } + break; + case AnnotationType.None: + default: + continue; + } + } + } + return { blockAnnotation: blockAnnotation, testAnnotation: testAnnotation }; + } + + public parseParams(file: BrsFile, annotation: AnnotationExpression, annotationType: AnnotationType, noCatch: boolean) { + let rawParams = JSON.stringify(annotation.getArguments()); + let isSolo = annotationType === AnnotationType.SoloParams; + let isIgnore = annotationType === AnnotationType.IgnoreParams; + if (isSolo) { + this.hasSoloParams = true; + } + try { + if (rawParams) { + this.params.push(new AnnotationParams(annotation, rawParams, annotation.range.start.line, annotation.getArguments() as any, isIgnore, isSolo, noCatch)); + } else { + diagnosticIllegalParams(file, annotation); + } + } catch (e) { + diagnosticIllegalParams(file, annotation); + } + } + +} + +export function getAnnotationType(text: string): AnnotationType { + return annotationLookup[text.toLowerCase()] || AnnotationType.None; +} diff --git a/bsc-plugin/src/lib/rooibos/CodeCoverageProcessor.spec.ts b/bsc-plugin/src/lib/rooibos/CodeCoverageProcessor.spec.ts new file mode 100644 index 00000000..c43cccb7 --- /dev/null +++ b/bsc-plugin/src/lib/rooibos/CodeCoverageProcessor.spec.ts @@ -0,0 +1,74 @@ +// import * as chai from 'chai'; +// import * as fs from 'fs-extra'; + +// import { Program, ProgramBuilder } from 'brighterscript'; + +// import { expect } from 'chai'; + +// import * as path from 'path'; + +// import { CodeCoverageProcessor } from './CodeCoverageProcessor'; +// import { ProcessorConfig } from './ProcessorConfig'; + +// import File from './File'; + +// const chaiSubset = require('chai-subset'); + +// chai.use(chaiSubset); +// let processor: CodeCoverageProcessor; +// let sourcePath = 'src/test/stubProject'; +// let targetPath = 'build'; + +// let bsConfig = require('/home/george/hope/open-source/rooibos/rooibos-roku-vsc-extension-plugin/src/test/stubProject/bsconfig.json' +// ); +// function clearFiles() { +// fs.removeSync(targetPath); +// } + +// function copyFiles() { +// try { +// fs.copySync(sourcePath, targetPath); +// } catch (err) { +// console.error(err); +// } +// } + +// describe('CodeCoverageProcessor tests', function() { +// beforeEach(() => { +// clearFiles(); +// copyFiles(); +// let _programBuilder = new ProgramBuilder(); +// bsConfig.rootDir = path.resolve('src/test/stubProject/src'); + +// processor = new CodeCoverageProcessor(_programBuilder.program); +// }); + +// describe('Process files valid test', function() { +// it('tests processor runs', async () => { +// let f: File; +// await processor.processFile(f); +// }); +// it('tests creates CodeCoverageSupport file', async () => { +// let f: File; +// await processor.processFile(f); +// let filePath = path.resolve(path.join(targetPath, 'source', 'CodeCoverageSupport.brs')); +// expect(fs.existsSync(filePath)).to.be.true; +// }); +// it('tests creates coverage component', async () => { +// let f: File; +// await processor.processFile(f); +// let filePath = path.resolve(path.join(targetPath, 'components', 'CodeCoverage.xml')); +// expect(fs.existsSync(filePath)).to.be.true; +// filePath = path.resolve(path.join(targetPath, 'components', 'CodeCoverage.brs')); +// expect(fs.existsSync(filePath)).to.be.true; +// }); +// }); + +// describe('specific file with lots of code use cases in it', function() { +// it('tests processor runs', async () => { +// let f: File; +// await processor.processFile(f); +// console.log('TODO - write tests - currently manually validating!!'); +// }); +// }); +// }); diff --git a/bsc-plugin/src/lib/rooibos/CodeCoverageProcessor.ts b/bsc-plugin/src/lib/rooibos/CodeCoverageProcessor.ts new file mode 100644 index 00000000..53922771 --- /dev/null +++ b/bsc-plugin/src/lib/rooibos/CodeCoverageProcessor.ts @@ -0,0 +1,128 @@ +/* eslint-disable @typescript-eslint/no-var-requires */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +import type { BrsFile, ProgramBuilder } from 'brighterscript'; +import type { RooibosConfig } from './RooibosConfig'; + +export class CodeCoverageProcessor { + + constructor(builder: ProgramBuilder) { + this._config = (builder.options as any).rooibos as RooibosConfig || {}; + this._fileId = 0; + try { + // this._coverageBrsTemplate = fs.readFileSync(path.join(__dirname, './CodeCoverageTemplate.brs'), 'utf8'); + // this._coverageComponentBrsTemplate = fs.readFileSync(path.join(__dirname, './CodeCoverage.brs'), 'utf8'); + // this._coverageComponentXmlTemplate = fs.readFileSync(path.join(__dirname, './CodeCoverage.xml'), 'utf8'); + // this._coverageSupportTemplate = fs.readFileSync(path.join(__dirname, './CodeCoverageSupport.brs'), 'utf8'); + } catch (e) { + // console.log('Error:', e.stack); + } + } + + private _config: RooibosConfig; + private _fileId: number; + private _coverageBrsTemplate: string; + + public generateMetadata() { + //DO when everythin is ran + this.createCoverageComponent(); + this.createCoverageSupport(); + } + + public addCodeCoverage(file: BrsFile) { + //not yet supported + if (false && this._config.isRecordingCodeCoverage) { + this._processFile(); + } + //if matches glob + // this._processFile(file); + // + } + + public _processFile() { + // this._fileId++; + // let fileContents = ''; + // let lines = file.getFileContents().split(/\r?\n/); + // let coverageMap: Map = new Map(); + // this.visitableLines = new Map(); + // this.getVisitableLinesForStatements(file.ast); + // //TODO - walks the ast + // for (let lineNumber = 0; lineNumber < lines.length; lineNumber++) { + // let line = lines[lineNumber]; + // let statement = this.visitableLines.get(lineNumber); + // let coverageType = CodeCoverageLineType.noCode; + // if (statement) { + // if (statement instanceof IfStatement) { + // let conditionStartPos = statement.condition.range.start.character; + // let conditionEndPos = statement.condition.range.end.character; + // let funcCall = this.getFuncCallText(lineNumber, CodeCoverageLineType.condition); + // let conditionText = line.substr(conditionStartPos, conditionEndPos - conditionStartPos); + // let restofLineText = line.substring(conditionEndPos); + // line = `${line.substr(0, conditionStartPos)} ${funcCall} and (${conditionText}) ${restofLineText}`; + // coverageType = CodeCoverageLineType.condition; + // } else if (statement instanceof IfStatement) { + // // let conditionStartPos = statement.condition.location.start.column; + // // let conditionEndPos = statement.condition.location.end.column; + // // let funcCall = this.getFuncCallText(lineNumber, CodeCoverageLineType.condition); + // // let conditionText = line.substr(conditionStartPos, conditionEndPos - conditionStartPos); + // // let restofLineText = line.substring(conditionEndPos); + // // line = `${line.substr(0, conditionStartPos)} ${funcCall} and (${conditionText}) ${restofLineText}`; + // // coverageType = CodeCoverageLineType.condition; + // } else { + // //all types that can be prefixed with the funcall and a colon (i.e for, while, return foreach, assign) + // let funcCall = this.getFuncCallText(lineNumber, CodeCoverageLineType.code); + // line = `${funcCall}: ${line}`; + // coverageType = CodeCoverageLineType.code; + // } + // } else { + // `could not ascertain symbol type for line "${line} - ignoring`); + // } + + // if (!line.endsWith('\n')) { + // line += '\n'; + // } + // fileContents += line; + // if (coverageType > CodeCoverageLineType.noCode) { + // coverageMap.set(lineNumber, coverageType); + // } + // } + // this._expectedCoverageMap[this._fileId.toString().trim()] = Array.from(coverageMap); + // this._filePathMap[this._fileId] = file.pkgUri; + // fileContents += this.getBrsAPIText(); + // file.setFileContents(fileContents); + //`Writing to ${file.fullPath}`); + // file.saveFileContents(); + } + + public getBrsAPIText(): string { + let template = this._coverageBrsTemplate.replace(/\#ID\#/g, this._fileId.toString().trim()); + return template; + } + + public createCoverageComponent() { + // //Write this out via program + // let targetPath = path.resolve(this._program.options.rootDir); + // let file = new File(path.resolve(path.join(targetPath), 'components'), 'components', 'CodeCoverage.xml', '.xml'); + // file.setFileContents(this._coverageComponentXmlTemplate); + //`Writing to ${file.fullPath}`); + // file.saveFileContents(); + + // file = new File(path.resolve(path.join(targetPath, 'components')), 'components', 'CodeCoverage.brs', '.brs'); + // let template = this._coverageComponentBrsTemplate; + // template = template.replace(/\#EXPECTED_MAP\#/g, JSON.stringify(this._expectedCoverageMap)); + // template = template.replace(/\#FILE_PATH_MAP\#/g, JSON.stringify(this._filePathMap)); + // file.setFileContents(template); + //`Writing to ${file.fullPath}`); + // file.saveFileContents(); + } + + public createCoverageSupport() { + // //write this out via program + // let targetPath = path.resolve(this._program.options.rootDir); + // let file = new File(path.resolve(path.join(targetPath), 'source'), 'source', 'CodeCoverageSupport.brs', '.brs'); + // file.setFileContents(this._coverageSupportTemplate); + //`Writing to ${file.fullPath}`); + // file.saveFileContents(); + } + + +} diff --git a/bsc-plugin/src/lib/rooibos/CodeCoverageType.ts b/bsc-plugin/src/lib/rooibos/CodeCoverageType.ts new file mode 100644 index 00000000..88f8372c --- /dev/null +++ b/bsc-plugin/src/lib/rooibos/CodeCoverageType.ts @@ -0,0 +1,6 @@ +export enum CodeCoverageLineType { + noCode = 0, + code = 1, + condition = 2, + branch = 3 +} diff --git a/bsc-plugin/src/lib/rooibos/FileFactory.ts b/bsc-plugin/src/lib/rooibos/FileFactory.ts new file mode 100644 index 00000000..32cff548 --- /dev/null +++ b/bsc-plugin/src/lib/rooibos/FileFactory.ts @@ -0,0 +1,103 @@ +import type { BrsFile, FileObj, Program, XmlFile } from 'brighterscript'; + +import * as path from 'path'; +import * as fs from 'fs'; + +export class FileFactory { + + constructor(options: any) { + if (options.frameworkSourcePath) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment + this.sourcePath = options.frameworkSourcePath; + } + } + + private frameworkFileNames = [ + 'BaseTestSuite', + 'CommonUtils', + 'Coverage', + 'Matchers', + 'Rooibos', + 'RuntimeConfig', + 'Stats', + 'Test', + 'TestGroup', + 'BaseTestReporter', + 'ConsoleTestReporter', + 'TestResult', + 'TestRunner', + 'Utils' + ]; + + public sourcePath = path.join(__dirname, '../framework'); + private targetPath = 'source/rooibos/'; + private targetCompsPath = 'components/rooibos/'; + + public getFrameworkFiles(): FileObj[] { + let files: FileObj[] = []; + + for (let fileName of this.frameworkFileNames) { + files.push({ src: path.resolve(path.join(this.sourcePath, `${fileName}.bs`)), dest: path.join(this.targetPath, `${fileName}.bs`) }); + } + files.push({ src: path.resolve(path.join(this.sourcePath, `RooibosScene.xml`)), dest: path.join(this.targetCompsPath, `RooibosScene.xml`) }); + return files; + } + + public addFrameworkFiles(program: Program) { + for (let fileName of this.frameworkFileNames) { + let sourcePath = path.resolve(path.join(this.sourcePath, `${fileName}.bs`)); + let fileContents = fs.readFileSync(sourcePath, 'utf8'); + let destPath = path.join(this.targetPath, `${fileName}.bs`); + let entry = { src: sourcePath, dest: destPath }; + + program.addOrReplaceFile(entry, fileContents); + } + + let sourcePath = path.resolve(path.join(this.sourcePath, `RooibosScene.xml`)); + let destPath = path.join(this.targetCompsPath, `RooibosScene.xml`); + let entry = { src: sourcePath, dest: destPath }; + program.addOrReplaceFile(entry, this.createTestXML('TestsScene', 'Scene')); + } + + public createTestXML(name: string, baseName: string, useBs = true): string { + let scriptImports = []; + for (let fileName of this.frameworkFileNames) { + scriptImports.push(`