diff --git a/bsc-plugin/package-lock.json b/bsc-plugin/package-lock.json
index c63d2780..a9e752a9 100644
--- a/bsc-plugin/package-lock.json
+++ b/bsc-plugin/package-lock.json
@@ -38,6 +38,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/package.json b/bsc-plugin/package.json
index b5de2c96..a0d1a148 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",
"postinstall": "ropm copy",
"test": "nyc mocha",
"test:nocover": "mocha",
@@ -59,6 +59,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/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
diff --git a/bsc-plugin/src/lib/rooibos/FileFactory.ts b/bsc-plugin/src/lib/rooibos/FileFactory.ts
index 3bac405a..71ddeaec 100644
--- a/bsc-plugin/src/lib/rooibos/FileFactory.ts
+++ b/bsc-plugin/src/lib/rooibos/FileFactory.ts
@@ -1,72 +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',
- 'MochaTestReporter',
- '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'))
@@ -75,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
@@ -118,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 245e98bd..a23df1ee 100644
--- a/bsc-plugin/src/lib/rooibos/RooibosConfig.ts
+++ b/bsc-plugin/src/lib/rooibos/RooibosConfig.ts
@@ -33,10 +33,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 92f397e7..c5c5fd96 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 7985e331..0685ade6 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 99%
rename from framework/src/source/CommonUtils.bs
rename to framework/src/source/rooibos/CommonUtils.bs
index f7a0ab62..06ae2fc3 100755
--- a/framework/src/source/CommonUtils.bs
+++ b/framework/src/source/rooibos/CommonUtils.bs
@@ -1018,13 +1018,13 @@ namespace rooibos.common
sub logDebug(value)
#if ROOIBOS_DEBUG_LOGS
- ? "[Rooibos Debug]: "value
+ ? "[Rooibos Debug]: " value
#end if
end sub
sub logTrace(value)
#if ROOIBOS_TRACE_LOGS
- ? "[Rooibos Trace]: "value
+ ? "[Rooibos Trace]: " value
#end if
end sub
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 99%
rename from framework/src/source/TestGroup.bs
rename to framework/src/source/rooibos/TestGroup.bs
index fb34f996..eacf6e40 100644
--- a/framework/src/source/TestGroup.bs
+++ b/framework/src/source/rooibos/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
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