@eagleoutice/flowr
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
39 lines • 1.8 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.FlowrAnalyzerMetaTestFilesPlugin = void 0;
const flowr_analyzer_file_plugin_1 = require("./flowr-analyzer-file-plugin");
const semver_1 = require("semver");
const flowr_file_1 = require("../../context/flowr-file");
const built_in_source_1 = require("../../../dataflow/internal/process/functions/call/built-in/built-in-source");
const TestPathPattern = /tests?/i;
/**
* This plugin provides supports for the identification of test files.
* If you use multiple plugins, this should be included *before* other plugins.
*/
class FlowrAnalyzerMetaTestFilesPlugin extends flowr_analyzer_file_plugin_1.FlowrAnalyzerFilePlugin {
name = 'flowr-analyzer-test-files-plugin';
description = 'This plugin provides support for loading test files.';
version = new semver_1.SemVer('0.1.0');
pathPattern;
/**
* Creates a new instance of the TEST file plugin.
* @param pathPattern - The pathPattern to identify TEST files, see {@link TestPathPattern} for the default pathPattern.
*/
constructor(pathPattern = TestPathPattern) {
super();
this.pathPattern = pathPattern;
}
applies(file) {
return this.pathPattern.test((0, built_in_source_1.platformDirname)(file.toString()));
}
/**
* Processes the given file, assigning it the {@link FileRole.Test} role.
* Given that the file may still need to be processed by other plugins, this method returns the `true` flag for that purpose.
*/
process(_ctx, file) {
file.assignRole(flowr_file_1.FileRole.Test);
return [file, true];
}
}
exports.FlowrAnalyzerMetaTestFilesPlugin = FlowrAnalyzerMetaTestFilesPlugin;
//# sourceMappingURL=flowr-analyzer-test-file-plugin.js.map