Skip to content

Commit

Permalink
Fix coverage files import (#232)
Browse files Browse the repository at this point in the history
* fix(code-coverage): use correct imports for framework files

* fix(code-coverage): improve default file exclusions

* fix(code-coverage): ignore main.brs and rooibos files
  • Loading branch information
arturocuya authored Jun 6, 2023
1 parent 64ccfcb commit c22ac5a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
9 changes: 5 additions & 4 deletions bsc-plugin/src/lib/rooibos/FileFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ import * as path from 'path';
import * as fs from 'fs';
import * as fse from 'fs-extra';

const frameworkSrc = path.resolve(__dirname, '../../../../framework/src/source');

export class FileFactory {
private coverageComponentXmlTemplate = fs.readFileSync(path.join(frameworkSrc, 'CodeCoverage.xml'), 'utf8');
private coverageComponentBrsTemplate = fs.readFileSync(path.join(frameworkSrc, 'CodeCoverage.brs'), 'utf8');
private coverageComponentXmlTemplate;
private coverageComponentBrsTemplate;

constructor(
private options?: {
Expand All @@ -25,6 +23,9 @@ export class FileFactory {
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');
}

private frameworkFileNames = [
Expand Down
18 changes: 12 additions & 6 deletions bsc-plugin/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,18 @@ export class RooibosPlugin implements CompilerPlugin {
'!**/roku_modules/**/*'];
}

const defaultCoverageExcluded = [
'**/*.spec.bs',
'**/roku_modules/**/*',
'**/source/main.bs',
'**/source/rooibos/**/*'
];

// Set default coverage exclusions, or merge with defaults if available.
if (config.coverageExcludedFiles === undefined) {
config.coverageExcludedFiles = [
'**/*.spec.bs',
'**/roku_modules/**/*'
];
config.coverageExcludedFiles = defaultCoverageExcluded;
} else {
config.coverageExcludedFiles.push(...defaultCoverageExcluded);
}

return config;
Expand Down Expand Up @@ -169,12 +176,11 @@ export class RooibosPlugin implements CompilerPlugin {
return true;
} else {
for (let filter of this.config.coverageExcludedFiles) {
if (minimatch(file.pathAbsolute, filter)) {
if (minimatch(file.pkgPath, filter)) {
return false;
}
}
}
// console.log('including ', file.pkgPath);
return true;
}
}
Expand Down

0 comments on commit c22ac5a

Please sign in to comment.