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..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",
@@ -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",
diff --git a/bsc-plugin/src/lib/rooibos/FileFactory.ts b/bsc-plugin/src/lib/rooibos/FileFactory.ts
index 24b16c59..71ddeaec 100644
--- a/bsc-plugin/src/lib/rooibos/FileFactory.ts
+++ b/bsc-plugin/src/lib/rooibos/FileFactory.ts
@@ -1,71 +1,64 @@
-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';
import * as fse from 'fs-extra';
+import * as fastGlob from 'fast-glob';
import type { TestSuite } from './TestSuite';
export class FileFactory {
private coverageComponentXmlTemplate;
private coverageComponentBrsTemplate;
-
- constructor(
- private options?: {
- frameworkSourcePath?: string;
- }
- ) {
- this.options = this.options ?? {};
- 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`;
- } 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`;
- }
+ private frameworkSourcePath: string;
+
+ constructor() {
+ 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.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.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.frameworkSourcePath, '/components/rooibos/CodeCoverage.xml'), 'utf8');
+ this.coverageComponentBrsTemplate = fs.readFileSync(path.join(this.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 = [];
- 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.frameworkSourcePath,
+ absolute: false,
+ followSymbolicLinks: true,
+ onlyFiles: true
+ });
+
+ 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.frameworkSourcePath, filePath);
+ let fileContents = fs.readFileSync(sourcePath, 'utf8').toString();
+ let entry = { src: sourcePath, dest: filePath };
this.addedFrameworkFiles.push(
program.setFile(entry, fileContents)
);
}
let entry = {
- src: s`${this.options.frameworkSourcePath}/RooibosScene.xml`,
- dest: s`${this.targetCompsPath}/RooibosScene.xml`
+ src: s`${this.frameworkSourcePath}/components/RooibosScene.xml`,
+ dest: s`components/rooibos/RooibosScene.xml`
};
this.addedFrameworkFiles.push(
program.setFile(entry, this.createTestXML('RooibosScene', 'Scene'))
@@ -74,8 +67,8 @@ export class FileFactory {
public createTestXML(name: string, baseName: string, suite?: TestSuite): string {
let scriptImports = [];
- for (let fileName of this.frameworkFileNames) {
- scriptImports.push(``);
+ for (let filePath of this.addedSourceFrameworkFilePaths) {
+ scriptImports.push(``);
}
// Add the test spec file rather then relying on auto imports
@@ -117,8 +110,8 @@ export class FileFactory {
public isIgnoredFile(file: BrsFile | XmlFile): boolean {
let name = file.pkgPath.toLowerCase();
- let result = this.frameworkFileNames.find((f) => {
- return name === path.join(this.targetPath, `${f}.bs`).toLowerCase();
+ let result = this.addedFrameworkFiles.find((f) => {
+ return name === f.pkgPath.toLowerCase();
}
);
return result !== undefined;
diff --git a/bsc-plugin/src/lib/rooibos/RooibosConfig.ts b/bsc-plugin/src/lib/rooibos/RooibosConfig.ts
index af5cdc68..48d0814b 100644
--- a/bsc-plugin/src/lib/rooibos/RooibosConfig.ts
+++ b/bsc-plugin/src/lib/rooibos/RooibosConfig.ts
@@ -32,10 +32,4 @@ export interface RooibosConfig {
reporters?: string[];
keepAppOpen?: boolean;
testSceneName?: string;
-
- /**
- * The path to the folder where the rooibos framework roku files reside.
- * @default `dist/lib/framework`
- */
- frameworkSourcePath?: string;
}
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/bsc-plugin/src/plugin.ts b/bsc-plugin/src/plugin.ts
index 027bebd0..520d83ed 100644
--- a/bsc-plugin/src/plugin.ts
+++ b/bsc-plugin/src/plugin.ts
@@ -35,7 +35,7 @@ export class RooibosPlugin implements CompilerPlugin {
this.config = this.getConfig((builder.options as any).rooibos || {});
- this.fileFactory = new FileFactory(this.config);
+ this.fileFactory = new FileFactory();
if (!this.session) {
this.session = new RooibosSession(builder, this.fileFactory);
this.codeCoverageProcessor = new CodeCoverageProcessor(builder, this.fileFactory);
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