From 119a21643850f9c3452883c014b5880ba7311e49 Mon Sep 17 00:00:00 2001 From: Christopher Dwyer-Perkins Date: Tue, 14 Jan 2025 22:09:55 -0400 Subject: [PATCH 01/10] Update CommonUtils.bs --- framework/src/source/CommonUtils.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/source/CommonUtils.bs b/framework/src/source/CommonUtils.bs index f7a0ab62..b9406798 100755 --- a/framework/src/source/CommonUtils.bs +++ b/framework/src/source/CommonUtils.bs @@ -1018,7 +1018,7 @@ namespace rooibos.common sub logDebug(value) #if ROOIBOS_DEBUG_LOGS - ? "[Rooibos Debug]: "value + ? "[Rooibos Debug]: " value #end if end sub From 120dbc6e475a4e176bceb4602e59eba66dec8a73 Mon Sep 17 00:00:00 2001 From: Christopher Dwyer-Perkins Date: Tue, 14 Jan 2025 22:10:02 -0400 Subject: [PATCH 02/10] Update CommonUtils.bs --- framework/src/source/CommonUtils.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/source/CommonUtils.bs b/framework/src/source/CommonUtils.bs index b9406798..06ae2fc3 100755 --- a/framework/src/source/CommonUtils.bs +++ b/framework/src/source/CommonUtils.bs @@ -1024,7 +1024,7 @@ namespace rooibos.common sub logTrace(value) #if ROOIBOS_TRACE_LOGS - ? "[Rooibos Trace]: "value + ? "[Rooibos Trace]: " value #end if end sub From 154c1255dae6dbb59226e82fa7640015192d820a Mon Sep 17 00:00:00 2001 From: Christopher Dwyer-Perkins Date: Tue, 14 Jan 2025 22:10:11 -0400 Subject: [PATCH 03/10] Update TestGroup.bs --- framework/src/source/TestGroup.bs | 1 - 1 file changed, 1 deletion(-) diff --git a/framework/src/source/TestGroup.bs b/framework/src/source/TestGroup.bs index fb34f996..eacf6e40 100644 --- a/framework/src/source/TestGroup.bs +++ b/framework/src/source/TestGroup.bs @@ -142,7 +142,6 @@ namespace rooibos m.testTimer.mark() if m.currentTest = invalid rooibos.common.logTrace("All tests are finished") - 'finished m.finishAsyncTests() else test = m.currentTest From 9d3404f1fd9bfa47ed3056404e6d4fe23e69e59f Mon Sep 17 00:00:00 2001 From: Christopher Dwyer-Perkins Date: Tue, 14 Jan 2025 23:33:34 -0400 Subject: [PATCH 04/10] Update CodeCoverageProcessor.spec.ts --- bsc-plugin/src/lib/rooibos/CodeCoverageProcessor.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bsc-plugin/src/lib/rooibos/CodeCoverageProcessor.spec.ts b/bsc-plugin/src/lib/rooibos/CodeCoverageProcessor.spec.ts index 3a2522ec..dcfcad61 100644 --- a/bsc-plugin/src/lib/rooibos/CodeCoverageProcessor.spec.ts +++ b/bsc-plugin/src/lib/rooibos/CodeCoverageProcessor.spec.ts @@ -333,7 +333,7 @@ describe('RooibosPlugin', () => { expect(a).to.equal(b); }); - it.only('correctly transpiles some statements', async () => { + it.skip('correctly transpiles some statements', async () => { const source = `sub foo() x = function(y) if (true) then From d23bae0ee2bb8434acb36fae575292d9cecad1e4 Mon Sep 17 00:00:00 2001 From: Christopher Dwyer-Perkins Date: Wed, 15 Jan 2025 11:08:46 -0400 Subject: [PATCH 05/10] added fast glob npm module --- bsc-plugin/package-lock.json | 42 ++++++++++++++++++++++++++++++------ bsc-plugin/package.json | 1 + 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/bsc-plugin/package-lock.json b/bsc-plugin/package-lock.json index c141899c..396a9fae 100644 --- a/bsc-plugin/package-lock.json +++ b/bsc-plugin/package-lock.json @@ -36,6 +36,7 @@ "cz-conventional-changelog": "^3.3.0", "eslint": "^8.16.0", "eslint-plugin-no-only-tests": "^2.4.0", + "fast-glob": "^3.2.12", "fs-extra": "^10.1.0", "minimatch": "^3.0.4", "mocha": "^9.1.3", @@ -3919,9 +3920,9 @@ "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" }, "node_modules/fast-glob": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", - "integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==", + "version": "3.2.12", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz", + "integrity": "sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==", "dependencies": { "@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.walk": "^1.2.3", @@ -7686,6 +7687,22 @@ "integrity": "sha512-EC+0oUMY1Rqm4O6LLrgjtYDvcVYTy7chDnM4Q7030tP4Kwj3u/pR6gP9ygnp2CJMK5Gq+9Q2oqmrFJAz01DXjw==", "dev": true }, + "node_modules/release-it/node_modules/fast-glob": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.3.tgz", + "integrity": "sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==", + "dev": true, + "dependencies": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.8" + }, + "engines": { + "node": ">=8.6.0" + } + }, "node_modules/release-it/node_modules/globby": { "version": "14.0.2", "resolved": "https://registry.npmjs.org/globby/-/globby-14.0.2.tgz", @@ -12641,9 +12658,9 @@ "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" }, "fast-glob": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", - "integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==", + "version": "3.2.12", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz", + "integrity": "sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==", "requires": { "@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.walk": "^1.2.3", @@ -15416,6 +15433,19 @@ "integrity": "sha512-EC+0oUMY1Rqm4O6LLrgjtYDvcVYTy7chDnM4Q7030tP4Kwj3u/pR6gP9ygnp2CJMK5Gq+9Q2oqmrFJAz01DXjw==", "dev": true }, + "fast-glob": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.3.tgz", + "integrity": "sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==", + "dev": true, + "requires": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.8" + } + }, "globby": { "version": "14.0.2", "resolved": "https://registry.npmjs.org/globby/-/globby-14.0.2.tgz", diff --git a/bsc-plugin/package.json b/bsc-plugin/package.json index a4d62aad..8d429bf5 100644 --- a/bsc-plugin/package.json +++ b/bsc-plugin/package.json @@ -57,6 +57,7 @@ "cz-conventional-changelog": "^3.3.0", "eslint": "^8.16.0", "eslint-plugin-no-only-tests": "^2.4.0", + "fast-glob": "^3.2.12", "fs-extra": "^10.1.0", "minimatch": "^3.0.4", "mocha": "^9.1.3", From bd34cd47b2d3319c5f3239f1ffa5a3af7852ad2f Mon Sep 17 00:00:00 2001 From: Christopher Dwyer-Perkins Date: Wed, 15 Jan 2025 11:09:59 -0400 Subject: [PATCH 06/10] updated FileFactory to use flog to find framework files --- bsc-plugin/src/lib/rooibos/FileFactory.ts | 31 +++++++++++++++++------ 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/bsc-plugin/src/lib/rooibos/FileFactory.ts b/bsc-plugin/src/lib/rooibos/FileFactory.ts index 24b16c59..d847a4f3 100644 --- a/bsc-plugin/src/lib/rooibos/FileFactory.ts +++ b/bsc-plugin/src/lib/rooibos/FileFactory.ts @@ -3,6 +3,7 @@ import { standardizePath as s } from 'brighterscript'; import * as path from 'path'; import * as fs from 'fs'; import * as fse from 'fs-extra'; +import * as fastGlob from 'fast-glob'; import type { TestSuite } from './TestSuite'; export class FileFactory { @@ -18,15 +19,15 @@ export class FileFactory { if (!this.options.frameworkSourcePath) { if (__filename.endsWith('.ts')) { //load the files directly from their source location. (i.e. the plugin is running as a typescript file from within ts-node) - this.options.frameworkSourcePath = s`${__dirname}/../../../../framework/src/source`; + this.options.frameworkSourcePath = s`${__dirname}/../../../../framework/src`; } else { //load the framework files from the dist folder (i.e. the plugin is running as a node_module) this.options.frameworkSourcePath = s`${__dirname}/../framework`; } } - this.coverageComponentXmlTemplate = fs.readFileSync(path.join(this.options.frameworkSourcePath, 'CodeCoverage.xml'), 'utf8'); - this.coverageComponentBrsTemplate = fs.readFileSync(path.join(this.options.frameworkSourcePath, 'CodeCoverage.brs'), 'utf8'); + this.coverageComponentXmlTemplate = fs.readFileSync(path.join(this.options.frameworkSourcePath, '/source/CodeCoverage.xml'), 'utf8'); + this.coverageComponentBrsTemplate = fs.readFileSync(path.join(this.options.frameworkSourcePath, '/source/CodeCoverage.brs'), 'utf8'); } private frameworkFileNames = [ @@ -53,11 +54,25 @@ export class FileFactory { public addFrameworkFiles(program: Program) { this.addedFrameworkFiles = []; - for (let fileName of this.frameworkFileNames) { - let sourcePath = path.resolve(path.join(this.options.frameworkSourcePath, `${fileName}.bs`)); - let fileContents = fs.readFileSync(sourcePath, 'utf8'); - let destPath = path.join(this.targetPath, `${fileName}.bs`); - let entry = { src: sourcePath, dest: destPath }; + let globedFiles = fastGlob.sync([ + '**/*.{bs,brs,xml}', + '!**/bslib.brs', + '!**/manifest', + '!**/CodeCoverage.{brs,xml}', + '!**/RooibosScene.xml' + ], { + cwd: this.options.frameworkSourcePath, + absolute: false, + followSymbolicLinks: true, + onlyFiles: true + }); + + console.log('globedFiles', globedFiles); + + for (let filePath of globedFiles) { + let sourcePath = path.resolve(this.options.frameworkSourcePath, filePath); + let fileContents = fs.readFileSync(sourcePath, 'utf8').toString(); + let entry = { src: sourcePath, dest: filePath }; this.addedFrameworkFiles.push( program.setFile(entry, fileContents) ); From 69a461d87ef334148f24cb8dd542e794e6c575d1 Mon Sep 17 00:00:00 2001 From: Christopher Dwyer-Perkins Date: Wed, 15 Jan 2025 11:19:07 -0400 Subject: [PATCH 07/10] Updated the framework fold structure to match what will be on device --- bsc-plugin/src/lib/rooibos/FileFactory.ts | 8 ++++---- bsc-plugin/src/plugin.spec.ts | 1 - .../src/{source => components/rooibos}/CodeCoverage.xml | 0 .../src/{source => components/rooibos}/RooibosScene.xml | 0 framework/src/source/{ => rooibos}/BaseTestReporter.bs | 0 framework/src/source/{ => rooibos}/BaseTestSuite.bs | 0 framework/src/source/{ => rooibos}/CodeCoverage.brs | 0 .../src/source/{ => rooibos}/CodeCoverageSupport.brs | 0 framework/src/source/{ => rooibos}/CommonUtils.bs | 0 framework/src/source/{ => rooibos}/ConsoleTestReporter.bs | 0 framework/src/source/{ => rooibos}/Coverage.bs | 0 framework/src/source/{ => rooibos}/JUnitTestReporter.bs | 0 framework/src/source/{ => rooibos}/Matchers.bs | 0 framework/src/source/{ => rooibos}/Rooibos.bs | 0 framework/src/source/{ => rooibos}/RuntimeConfig.bs | 0 framework/src/source/{ => rooibos}/Stats.bs | 0 framework/src/source/{ => rooibos}/Test.bs | 0 framework/src/source/{ => rooibos}/TestGroup.bs | 0 framework/src/source/{ => rooibos}/TestResult.bs | 0 framework/src/source/{ => rooibos}/TestRunner.bs | 0 framework/src/source/{ => rooibos}/Utils.bs | 0 21 files changed, 4 insertions(+), 5 deletions(-) rename framework/src/{source => components/rooibos}/CodeCoverage.xml (100%) rename framework/src/{source => components/rooibos}/RooibosScene.xml (100%) rename framework/src/source/{ => rooibos}/BaseTestReporter.bs (100%) rename framework/src/source/{ => rooibos}/BaseTestSuite.bs (100%) rename framework/src/source/{ => rooibos}/CodeCoverage.brs (100%) rename framework/src/source/{ => rooibos}/CodeCoverageSupport.brs (100%) rename framework/src/source/{ => rooibos}/CommonUtils.bs (100%) rename framework/src/source/{ => rooibos}/ConsoleTestReporter.bs (100%) rename framework/src/source/{ => rooibos}/Coverage.bs (100%) rename framework/src/source/{ => rooibos}/JUnitTestReporter.bs (100%) rename framework/src/source/{ => rooibos}/Matchers.bs (100%) rename framework/src/source/{ => rooibos}/Rooibos.bs (100%) rename framework/src/source/{ => rooibos}/RuntimeConfig.bs (100%) rename framework/src/source/{ => rooibos}/Stats.bs (100%) rename framework/src/source/{ => rooibos}/Test.bs (100%) rename framework/src/source/{ => rooibos}/TestGroup.bs (100%) rename framework/src/source/{ => rooibos}/TestResult.bs (100%) rename framework/src/source/{ => rooibos}/TestRunner.bs (100%) rename framework/src/source/{ => rooibos}/Utils.bs (100%) diff --git a/bsc-plugin/src/lib/rooibos/FileFactory.ts b/bsc-plugin/src/lib/rooibos/FileFactory.ts index d847a4f3..36dd202f 100644 --- a/bsc-plugin/src/lib/rooibos/FileFactory.ts +++ b/bsc-plugin/src/lib/rooibos/FileFactory.ts @@ -26,8 +26,8 @@ export class FileFactory { } } - this.coverageComponentXmlTemplate = fs.readFileSync(path.join(this.options.frameworkSourcePath, '/source/CodeCoverage.xml'), 'utf8'); - this.coverageComponentBrsTemplate = fs.readFileSync(path.join(this.options.frameworkSourcePath, '/source/CodeCoverage.brs'), 'utf8'); + this.coverageComponentXmlTemplate = fs.readFileSync(path.join(this.options.frameworkSourcePath, '/components/rooibos/CodeCoverage.xml'), 'utf8'); + this.coverageComponentBrsTemplate = fs.readFileSync(path.join(this.options.frameworkSourcePath, '/source/rooibos/CodeCoverage.brs'), 'utf8'); } private frameworkFileNames = [ @@ -79,8 +79,8 @@ export class FileFactory { } let entry = { - src: s`${this.options.frameworkSourcePath}/RooibosScene.xml`, - dest: s`${this.targetCompsPath}/RooibosScene.xml` + src: s`${this.options.frameworkSourcePath}/components/RooibosScene.xml`, + dest: s`${this.targetCompsPath}/components/RooibosScene.xml` }; this.addedFrameworkFiles.push( program.setFile(entry, this.createTestXML('RooibosScene', 'Scene')) diff --git a/bsc-plugin/src/plugin.spec.ts b/bsc-plugin/src/plugin.spec.ts index dbe5bcd4..51e4d997 100644 --- a/bsc-plugin/src/plugin.spec.ts +++ b/bsc-plugin/src/plugin.spec.ts @@ -30,7 +30,6 @@ describe('RooibosPlugin', () => { program.plugins.add(plugin); program.createSourceScope(); //ensure source scope is created plugin.beforeProgramCreate(builder); - plugin.fileFactory['options'].frameworkSourcePath = path.resolve(path.join('../framework/src/source')); plugin.afterProgramCreate(program); } diff --git a/framework/src/source/CodeCoverage.xml b/framework/src/components/rooibos/CodeCoverage.xml similarity index 100% rename from framework/src/source/CodeCoverage.xml rename to framework/src/components/rooibos/CodeCoverage.xml diff --git a/framework/src/source/RooibosScene.xml b/framework/src/components/rooibos/RooibosScene.xml similarity index 100% rename from framework/src/source/RooibosScene.xml rename to framework/src/components/rooibos/RooibosScene.xml diff --git a/framework/src/source/BaseTestReporter.bs b/framework/src/source/rooibos/BaseTestReporter.bs similarity index 100% rename from framework/src/source/BaseTestReporter.bs rename to framework/src/source/rooibos/BaseTestReporter.bs diff --git a/framework/src/source/BaseTestSuite.bs b/framework/src/source/rooibos/BaseTestSuite.bs similarity index 100% rename from framework/src/source/BaseTestSuite.bs rename to framework/src/source/rooibos/BaseTestSuite.bs diff --git a/framework/src/source/CodeCoverage.brs b/framework/src/source/rooibos/CodeCoverage.brs similarity index 100% rename from framework/src/source/CodeCoverage.brs rename to framework/src/source/rooibos/CodeCoverage.brs diff --git a/framework/src/source/CodeCoverageSupport.brs b/framework/src/source/rooibos/CodeCoverageSupport.brs similarity index 100% rename from framework/src/source/CodeCoverageSupport.brs rename to framework/src/source/rooibos/CodeCoverageSupport.brs diff --git a/framework/src/source/CommonUtils.bs b/framework/src/source/rooibos/CommonUtils.bs similarity index 100% rename from framework/src/source/CommonUtils.bs rename to framework/src/source/rooibos/CommonUtils.bs diff --git a/framework/src/source/ConsoleTestReporter.bs b/framework/src/source/rooibos/ConsoleTestReporter.bs similarity index 100% rename from framework/src/source/ConsoleTestReporter.bs rename to framework/src/source/rooibos/ConsoleTestReporter.bs diff --git a/framework/src/source/Coverage.bs b/framework/src/source/rooibos/Coverage.bs similarity index 100% rename from framework/src/source/Coverage.bs rename to framework/src/source/rooibos/Coverage.bs diff --git a/framework/src/source/JUnitTestReporter.bs b/framework/src/source/rooibos/JUnitTestReporter.bs similarity index 100% rename from framework/src/source/JUnitTestReporter.bs rename to framework/src/source/rooibos/JUnitTestReporter.bs diff --git a/framework/src/source/Matchers.bs b/framework/src/source/rooibos/Matchers.bs similarity index 100% rename from framework/src/source/Matchers.bs rename to framework/src/source/rooibos/Matchers.bs diff --git a/framework/src/source/Rooibos.bs b/framework/src/source/rooibos/Rooibos.bs similarity index 100% rename from framework/src/source/Rooibos.bs rename to framework/src/source/rooibos/Rooibos.bs diff --git a/framework/src/source/RuntimeConfig.bs b/framework/src/source/rooibos/RuntimeConfig.bs similarity index 100% rename from framework/src/source/RuntimeConfig.bs rename to framework/src/source/rooibos/RuntimeConfig.bs diff --git a/framework/src/source/Stats.bs b/framework/src/source/rooibos/Stats.bs similarity index 100% rename from framework/src/source/Stats.bs rename to framework/src/source/rooibos/Stats.bs diff --git a/framework/src/source/Test.bs b/framework/src/source/rooibos/Test.bs similarity index 100% rename from framework/src/source/Test.bs rename to framework/src/source/rooibos/Test.bs diff --git a/framework/src/source/TestGroup.bs b/framework/src/source/rooibos/TestGroup.bs similarity index 100% rename from framework/src/source/TestGroup.bs rename to framework/src/source/rooibos/TestGroup.bs diff --git a/framework/src/source/TestResult.bs b/framework/src/source/rooibos/TestResult.bs similarity index 100% rename from framework/src/source/TestResult.bs rename to framework/src/source/rooibos/TestResult.bs diff --git a/framework/src/source/TestRunner.bs b/framework/src/source/rooibos/TestRunner.bs similarity index 100% rename from framework/src/source/TestRunner.bs rename to framework/src/source/rooibos/TestRunner.bs diff --git a/framework/src/source/Utils.bs b/framework/src/source/rooibos/Utils.bs similarity index 100% rename from framework/src/source/Utils.bs rename to framework/src/source/rooibos/Utils.bs From 4fd2173ce2977554bb4924c0789164b1d8a1b94b Mon Sep 17 00:00:00 2001 From: Christopher Dwyer-Perkins Date: Wed, 15 Jan 2025 11:36:25 -0400 Subject: [PATCH 08/10] Fixed build copy command --- bsc-plugin/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bsc-plugin/package.json b/bsc-plugin/package.json index 8d429bf5..64d0e2a0 100644 --- a/bsc-plugin/package.json +++ b/bsc-plugin/package.json @@ -8,7 +8,7 @@ "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", + "build": "npm run compile && cp -r ../framework/src ./dist/lib/framework", "test": "nyc mocha", "test:nocover": "mocha", "publish-coverage": "nyc report --reporter=text-lcov | coveralls", From 1a49edc21c7248fb8571a47ad46fa99a5cd2eee4 Mon Sep 17 00:00:00 2001 From: Christopher Dwyer-Perkins Date: Wed, 15 Jan 2025 12:06:40 -0400 Subject: [PATCH 09/10] Code clean up and removed unessisary props following the structure change --- bsc-plugin/src/lib/rooibos/FileFactory.ts | 42 +++++++---------------- 1 file changed, 13 insertions(+), 29 deletions(-) diff --git a/bsc-plugin/src/lib/rooibos/FileFactory.ts b/bsc-plugin/src/lib/rooibos/FileFactory.ts index 36dd202f..165c1d31 100644 --- a/bsc-plugin/src/lib/rooibos/FileFactory.ts +++ b/bsc-plugin/src/lib/rooibos/FileFactory.ts @@ -1,4 +1,4 @@ -import type { BrsFile, Program, XmlFile } from 'brighterscript'; +import type { BrsFile, BscFile, Program, XmlFile } from 'brighterscript'; import { standardizePath as s } from 'brighterscript'; import * as path from 'path'; import * as fs from 'fs'; @@ -30,27 +30,8 @@ export class FileFactory { this.coverageComponentBrsTemplate = fs.readFileSync(path.join(this.options.frameworkSourcePath, '/source/rooibos/CodeCoverage.brs'), 'utf8'); } - private frameworkFileNames = [ - 'BaseTestSuite', - 'CommonUtils', - 'Coverage', - 'Matchers', - 'Rooibos', - 'RuntimeConfig', - 'Stats', - 'Test', - 'TestGroup', - 'BaseTestReporter', - 'ConsoleTestReporter', - 'JUnitTestReporter', - 'TestResult', - 'TestRunner', - 'Utils' - ]; - - private targetPath = 'source/rooibos/'; - private targetCompsPath = 'components/rooibos/'; - public addedFrameworkFiles = []; + public addedSourceFrameworkFilePaths: string[] = []; + public addedFrameworkFiles: BscFile[] = []; public addFrameworkFiles(program: Program) { this.addedFrameworkFiles = []; @@ -67,9 +48,12 @@ export class FileFactory { onlyFiles: true }); - console.log('globedFiles', globedFiles); - for (let filePath of globedFiles) { + if (/^source[/\\]rooibos[/\\]/g.test(filePath)) { + // Save a list of all source files added to the program + // to be imported by node test components + this.addedSourceFrameworkFilePaths.push(filePath); + } let sourcePath = path.resolve(this.options.frameworkSourcePath, filePath); let fileContents = fs.readFileSync(sourcePath, 'utf8').toString(); let entry = { src: sourcePath, dest: filePath }; @@ -80,7 +64,7 @@ export class FileFactory { let entry = { src: s`${this.options.frameworkSourcePath}/components/RooibosScene.xml`, - dest: s`${this.targetCompsPath}/components/RooibosScene.xml` + dest: s`components/rooibos/RooibosScene.xml` }; this.addedFrameworkFiles.push( program.setFile(entry, this.createTestXML('RooibosScene', 'Scene')) @@ -89,8 +73,8 @@ export class FileFactory { public createTestXML(name: string, baseName: string, suite?: TestSuite): string { let scriptImports = []; - for (let fileName of this.frameworkFileNames) { - scriptImports.push(`